Fix example bugs, improve docs, and add copilot instructions#107
Open
Fix example bugs, improve docs, and add copilot instructions#107
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a class-based entity dispatch bug in the core worker, updates several examples to run correctly against the local DTS emulator, and improves repository documentation and Markdown linting support.
Changes:
- Fix
_EntityExecutorto only passentity_inputto class-based entity methods when the method accepts an input parameter. - Correct example entity handlers and update sub-orchestration examples to avoid hardcoded TLS configuration.
- Refresh
examples/README.mdformatting/instructions and add Copilot + Markdown linting configuration.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
durabletask/worker.py |
Adjusts class-based entity method invocation to avoid passing input to no-arg operations. |
tests/durabletask/test_entity_executor.py |
Adds unit tests for class-based entity dispatch behavior (and function-based coverage). |
examples/entities/function_based_entity.py |
Fixes control-flow bug (if → elif) in the entity operation handler. |
examples/entities/function_based_entity_actions.py |
Adds missing "add" operation handler in the entity example. |
examples/sub-orchestrations-with-fan-out-fan-in/worker.py |
Makes secure_channel selection configurable based on endpoint. |
examples/sub-orchestrations-with-fan-out-fan-in/orchestrator.py |
Makes client secure_channel selection configurable based on endpoint. |
examples/README.md |
Rewrites example documentation with improved Markdown and setup/run instructions. |
dev-requirements.txt |
Adds pymarkdownlnt to dev dependencies. |
.pymarkdown.json |
Adds Markdown lint configuration. |
.github/copilot-instructions.md |
Adds repository conventions and guidance for Copilot usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
examples/sub-orchestrations-with-fan-out-fan-in/orchestrator.py
Outdated
Show resolved
Hide resolved
5fbfbf8 to
9182094
Compare
- Fix entity method dispatch in worker.py to inspect method signature before passing entity_input, so class-based entity methods that take no input (e.g. get()) work without requiring a dummy parameter - Fix function_based_entity.py: if -> elif for set operation - Fix function_based_entity_actions.py: add missing 'add' operation - Fix sub-orchestration examples: use dynamic secure_channel based on endpoint instead of hardcoded True - Rewrite examples/README.md with proper formatting, virtual env setup instructions, and local dev install steps - Add .github/copilot-instructions.md with project conventions - Add .pymarkdown.json config and pymarkdownlnt to dev-requirements.txt - Add unit tests for entity executor method dispatch
9182094 to
009f2ea
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
While testing the examples against the local DTS emulator, several bugs were found and fixed.
Bug Fixes
Framework fix in
durabletask/worker.py:entity_inputas an argument to class-based entity methods, even when no input was provided. Methods likedef get(self):that don't accept input would fail withTypeError: Counter.get() takes 1 positional argument but 2 were given. Fixed by usinginspect.signature()to check whether the method accepts parameters before passing the argument.Example fixes:
function_based_entity.py: Changediftoeliffor the set operation — it was falling through to the else branch and raisingValueErrorfunction_based_entity_actions.py: Added missing add operation handlersub-orchestrations-with-fan-out-fan-in/worker.pyandorchestrator.py: Changed hardcodedsecure_channel=Trueto dynamic detection based on endpoint, so these examples work with the local emulatorDocumentation Improvements
examples/README.mdwith proper markdown formatting, added virtual environment setup instructions, local dev install steps, and PowerShell equivalents for multiline commands.github/copilot-instructions.mdwith project conventions.pymarkdown.jsonconfig andpymarkdownlnttodev-requirements.txtfor markdown lintingTesting
All 10 examples verified passing against the local DTS emulator. All 13 unit tests pass. Also added 5 new unit tests for entities, which are passing.