-
Notifications
You must be signed in to change notification settings - Fork 0
Add d3sdk #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add d3sdk #4
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
0ef0d48
update python package config
TaegyunHa 5d8b389
add d3sdk
TaegyunHa a0b838a
Update README
TaegyunHa a310700
fix fstring conversion
TaegyunHa 53683ba
add register_module arg
DevTGHa d468306
add logger
DevTGHa e48bb90
add D3_PLUGIN_DEFAULT_PORT
DevTGHa ae97de5
rename test directory to tests
DevTGHa 3529688
Update readme
DevTGHa d37cc92
fix mypy
DevTGHa 6490096
update project name for pypi
DevTGHa 0c17b62
ruff format
DevTGHa fae4093
add twine for pypi
DevTGHa a4d62ec
update readme for published pypi package
DevTGHa f8c217f
Rephrase SDK to API
DevTGHa 28436c7
change naming from plugin to execute
DevTGHa 95dd216
reflect feedbacks
DevTGHa 17e64e6
validate arguments
DevTGHa 3959a4e
add github badge
DevTGHa 8fa83d9
Add changelog and contributing
DevTGHa 3ca2601
Update LICENSE
DevTGHa d99bb28
Update description of pyproject
DevTGHa 8f70087
fix test
DevTGHa cd8f880
fix type information being removed
DevTGHa 97419e4
fix args and kargs arguments
DevTGHa 117ba40
add override_module_name
DevTGHa 51289b2
raise RuntimeError if not in session
DevTGHa 985d887
Update CHANGELOG.md
DevTGHa 6674d83
remove all d3 implication in docstring
DevTGHa 53342f1
add support for args and kargs
DevTGHa ac3b315
fix module_name in build_payload
DevTGHa 6725873
Update pyproject.toml
DevTGHa 12da4bb
hide expensive logging under isEnableFor
DevTGHa f458cf3
fix default argument for constructor
DevTGHa d9a39ee
always intialise D3PluginClient
DevTGHa 720a7bb
british english
DevTGHa 9a9c3a2
fix for constructingn D3PluginClient
DevTGHa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,3 +172,6 @@ cython_debug/ | |
|
|
||
| # PyPI configuration file | ||
| .pypirc | ||
|
|
||
| # MacOS | ||
| .DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,7 @@ | ||
| { | ||
| "python.testing.unittestArgs": [ | ||
| "-v", | ||
| "-s", | ||
| ".", | ||
| "-p", | ||
| "test_*.py" | ||
| "python.testing.pytestArgs": [ | ||
| "tests" | ||
| ], | ||
| "python.testing.pytestEnabled": false, | ||
| "python.testing.unittestEnabled": true | ||
| "python.testing.pytestEnabled": true, | ||
| "python.testing.unittestEnabled": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [1.2.0] - 2025-12-02 | ||
|
|
||
| ### Added | ||
| - **Client API**: Metaclass-based remote method execution with `D3PluginClient` | ||
| - Support for both sync and async methods | ||
| - Automatic Python 2.7 code conversion for Designer compatibility | ||
| - Session management with context managers | ||
| - **Functional API**: Decorator-based remote execution | ||
| - `@d3pythonscript` decorator for one-off script execution | ||
| - `@d3function(module_name)` decorator for reusable module-based functions | ||
| - Function chaining support within modules | ||
| - **Session Management**: `D3Session` and `D3AsyncSession` classes | ||
| - `rpc()` method for simple return value retrieval | ||
| - `execute()` method for full response with logs and status | ||
| - Automatic module registration via context managers | ||
| - **Type Safety**: Full Pydantic models for all API interactions | ||
| - `PluginPayload`, `PluginResponse`, `RegisterPayload` | ||
| - Generic type support for type-safe return values | ||
| - **Logging**: Configurable logging with `enable_debug_logging()` | ||
| - NullHandler by default (library best practice) | ||
| - Granular module-level control | ||
| - **AST Utilities**: Python 3 to Python 2.7 code transformation | ||
| - F-string to `.format()` conversion | ||
| - Type annotation removal | ||
| - Async/await removal | ||
| - Automatic package import detection | ||
| - Comprehensive test suite with 99 tests covering all major functionality | ||
| - CI/CD with GitHub Actions (ruff, mypy, pytest) | ||
| - PEP 561 type hints marker (`py.typed`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,291 @@ | ||
| # Contributing to designer-plugin | ||
|
|
||
| Thank you for your interest in contributing to designer-plugin! This document provides guidelines and instructions for contributing. | ||
|
|
||
| ## Development Setup | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Python 3.11 or higher | ||
| - [uv](https://github.com/astral-sh/uv) package manager | ||
|
|
||
| ### Getting Started | ||
|
|
||
| 1. **Clone the repository:** | ||
| ```bash | ||
| git clone https://github.com/disguise-one/python-plugin.git | ||
| cd python-plugin | ||
| ``` | ||
|
|
||
| 2. **Install dependencies:** | ||
| ```bash | ||
| uv sync --dev | ||
| ``` | ||
|
|
||
| 3. **Install pre-commit hooks:** | ||
| ```bash | ||
| uv run pre-commit install | ||
| ``` | ||
|
|
||
| ## Development Workflow | ||
|
|
||
| ### Running Tests | ||
|
|
||
| Run the full test suite: | ||
| ```bash | ||
| uv run pytest | ||
| ``` | ||
|
|
||
| Run tests with verbose output: | ||
| ```bash | ||
| uv run pytest -v | ||
| ``` | ||
|
|
||
| Run specific test file: | ||
| ```bash | ||
| uv run pytest tests/test_core.py | ||
| ``` | ||
|
|
||
| ### Code Quality Checks | ||
|
|
||
| **Linting:** | ||
| ```bash | ||
| uv run ruff check | ||
| ``` | ||
|
|
||
| **Auto-fix linting issues:** | ||
| ```bash | ||
| uv run ruff check --fix | ||
| ``` | ||
|
|
||
| **Formatting:** | ||
| ```bash | ||
| uv run ruff format | ||
| ``` | ||
|
|
||
| **Type checking:** | ||
| ```bash | ||
| uv run mypy | ||
| ``` | ||
|
|
||
| **Run all checks:** | ||
| ```bash | ||
| uv run ruff check && uv run ruff format --check && uv run mypy && uv run pytest | ||
| ``` | ||
|
|
||
| ### Pre-commit Hooks | ||
|
|
||
| Pre-commit hooks are configured to automatically run: | ||
| - `ruff check --fix` - Linting with auto-fix | ||
| - `ruff format` - Code formatting | ||
|
|
||
| These run automatically on `git commit`. To run manually: | ||
| ```bash | ||
| uv run pre-commit run --all-files | ||
| ``` | ||
|
|
||
| ## Code Style | ||
|
|
||
| ### General Guidelines | ||
|
|
||
| - Follow PEP 8 style guidelines | ||
| - Use type hints for all function signatures | ||
| - Write docstrings for all public APIs | ||
| - Prefer explicit over implicit | ||
|
|
||
| ### Type Hints | ||
|
|
||
| All code must include type hints: | ||
| ```python | ||
| def my_function(name: str, count: int = 0) -> dict[str, int]: | ||
| """Do something useful. | ||
|
|
||
| Args: | ||
| name: The name parameter. | ||
| count: The count parameter. | ||
|
|
||
| Returns: | ||
| A dictionary mapping name to count. | ||
| """ | ||
| return {name: count} | ||
| ``` | ||
|
|
||
| ### Docstrings | ||
|
|
||
| Use Google-style docstrings: | ||
| ```python | ||
| def example_function(param1: str, param2: int) -> bool: | ||
| """Brief description of the function. | ||
|
|
||
| More detailed explanation if needed. Can span | ||
| multiple lines. | ||
|
|
||
| Args: | ||
| param1: Description of param1. | ||
| param2: Description of param2. | ||
|
|
||
| Returns: | ||
| Description of return value. | ||
|
|
||
| Raises: | ||
| ValueError: When param2 is negative. | ||
| """ | ||
| if param2 < 0: | ||
| raise ValueError("param2 must be non-negative") | ||
| return True | ||
| ``` | ||
|
|
||
| ### Code Organization | ||
|
|
||
| - Group related functionality together | ||
| - Use clear, descriptive names | ||
| - Avoid circular imports | ||
|
|
||
| ## Testing Guidelines | ||
|
|
||
| ### Test Structure | ||
|
|
||
| - Place tests in the `tests/` directory | ||
| - Name test files `test_*.py` | ||
| - Name test classes `Test*` | ||
| - Name test functions `test_*` | ||
|
|
||
| ### Writing Tests | ||
|
|
||
| ```python | ||
| class TestMyFeature: | ||
| """Test suite for my feature.""" | ||
|
|
||
| def test_basic_functionality(self) -> None: | ||
| """Test basic functionality works correctly.""" | ||
| result = my_function("test", 42) | ||
| assert result == {"test": 42} | ||
|
|
||
| def test_error_handling(self) -> None: | ||
| """Test error handling for invalid input.""" | ||
| with pytest.raises(ValueError): | ||
| my_function("test", -1) | ||
| ``` | ||
|
|
||
| ### Test Coverage | ||
|
|
||
| - Aim for high test coverage | ||
| - Test both success and error cases | ||
| - Test edge cases and boundary conditions | ||
| - Use mocks for external dependencies | ||
|
|
||
| ## Pull Request Process | ||
|
|
||
| ### Before Submitting | ||
|
|
||
| 1. **Create a feature branch:** | ||
| ```bash | ||
| git checkout -b feature/my-new-feature | ||
| ``` | ||
|
|
||
| 2. **Make your changes:** | ||
| - Write code | ||
| - Add tests | ||
| - Update documentation | ||
|
|
||
| 3. **Run all checks:** | ||
| ```bash | ||
| uv run ruff check . && uv run ruff format --check . && uv run mypy && uv run pytest | ||
| ``` | ||
|
|
||
| 4. **Commit your changes:** | ||
| ```bash | ||
| git add . | ||
| git commit -m "Add my new feature" | ||
| ``` | ||
|
|
||
| Commit messages should: | ||
| - Use present tense ("Add feature" not "Added feature") | ||
| - Be clear and descriptive | ||
| - Reference issue numbers if applicable | ||
|
|
||
| 5. **Push to your fork:** | ||
| ```bash | ||
| git push origin feature/my-new-feature | ||
| ``` | ||
|
|
||
| ### Submitting the PR | ||
|
|
||
| 1. Open a Pull Request on GitHub | ||
| 2. Fill out the PR template | ||
| 3. Link any related issues | ||
| 4. Wait for CI checks to pass | ||
| 5. Address review feedback | ||
|
|
||
| ### PR Requirements | ||
|
|
||
| - All tests must pass | ||
| - Code must pass linting and type checking | ||
| - New features must include tests | ||
| - Documentation must be updated | ||
|
|
||
| ## Reporting Issues | ||
|
|
||
| ### Bug Reports | ||
|
|
||
| When reporting bugs, please include: | ||
| - Description of the issue | ||
| - Steps to reproduce | ||
| - Expected behaviour | ||
| - Actual behaviour | ||
| - Python version | ||
| - Package version | ||
| - Minimal code example (if applicable) | ||
|
|
||
| ### Feature Requests | ||
|
|
||
| When requesting features, please include: | ||
| - Clear description of the feature | ||
| - Use case and motivation | ||
| - Example API or usage (if applicable) | ||
| - Any alternatives you've considered | ||
|
|
||
| ## Documentation | ||
|
|
||
| ### Updating Documentation | ||
|
|
||
| - Update README.md for user facing changes | ||
| - Update docstrings for API changes | ||
| - Update CHANGELOG.md following Keep a Changelog format | ||
| - Add examples for new features | ||
|
|
||
| ### Documentation Style | ||
|
|
||
| - Write clear, concise documentation | ||
| - Include code examples | ||
| - Explain the "why" not just the "what" | ||
| - Keep documentation up to date with code | ||
|
|
||
| ## Release Process | ||
|
|
||
| Releases are managed by project maintainers: | ||
|
|
||
| 1. Update version in `pyproject.toml` | ||
| 2. Update `CHANGELOG.md` | ||
| 3. Create git tag: `git tag -a v1.2.0 -m "Release v1.2.0"` | ||
| 4. Push tag: `git push origin v1.2.0` | ||
| 5. Build distributions: `uv build` | ||
| 6. Upload to PyPI: `twine upload dist/*` | ||
|
|
||
| ## Code of Conduct | ||
|
|
||
| - Be respectful and inclusive | ||
| - Focus on constructive feedback | ||
| - Help others learn and grow | ||
| - Assume good intentions | ||
|
|
||
| ## Questions? | ||
|
|
||
| If you have questions about contributing: | ||
| - Open a [GitHub Issue](https://github.com/disguise-one/python-plugin/issues) | ||
| - Check existing issues and PRs | ||
| - Review the documentation | ||
|
|
||
| ## License | ||
|
|
||
| By contributing, you agree that your contributions will be licensed under the MIT License. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.