Add parent_instance_id to OrchestrationContext#168
Open
andystaples wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new parent_instance_id property to the Durable Task Python SDK’s OrchestrationContext, enabling orchestrator code to detect whether it is running as a sub-orchestration and, if so, identify the parent orchestration instance.
Changes:
- Added
OrchestrationContext.parent_instance_idas a new abstract property returningstr | None. - Implemented the property in the runtime orchestration context and populated it from
executionStarted.parentInstance.orchestrationInstance.instanceIdwhen present. - Added tests covering both sub-orchestration and top-level orchestration behavior, and documented the new API in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| durabletask/task.py | Introduces the new abstract parent_instance_id API on OrchestrationContext. |
| durabletask/worker.py | Implements and populates parent_instance_id in _RuntimeOrchestrationContext during executionStarted processing. |
| tests/durabletask/test_orchestration_executor.py | Adds unit tests validating parent_instance_id for sub-orchestrations and top-level orchestrations. |
| CHANGELOG.md | Documents the new OrchestrationContext.parent_instance_id property under ## Unreleased. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
Adds a
parent_instance_idproperty toOrchestrationContext. For a sub-orchestration, it returns the instance ID of the orchestration that scheduled it; for a top-level orchestration, it returnsNone.Changes
durabletask/task.py— new abstractparent_instance_idproperty onOrchestrationContext.durabletask/worker.py—_RuntimeOrchestrationContextimplements the property, backed by_parent_instance_id, populated fromexecutionStarted.parentInstance.orchestrationInstance.instanceId(guarded byHasField).tests/durabletask/test_orchestration_executor.py— two new tests: a sub-orchestration exposes its parent's instance ID, and a top-level orchestration returnsNone.CHANGELOG.md— added an entry under## Unreleased.Testing
python -m pytest tests/durabletask/test_orchestration_executor.py— all tests pass, including the two new ones.flake8clean on all changed files; no Pylance/type errors.