Add instance ID prefix orchestration queries - #251
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: abe44a4b-db94-4661-bb3b-2d7dd30b1e78
There was a problem hiding this comment.
Pull request overview
Adds a new public query filter to the core SDK to allow querying orchestrations by an instance ID prefix, wiring it through gRPC request serialization and validating behavior via tests and changelog documentation.
Changes:
- Added
OrchestrationQuery.instance_id_prefixas a public filter option. - Serialized the new filter to
InstanceQuery.instanceIdPrefixinbuild_query_instances_req. - Added tests for serialization and in-memory backend filtering; documented the new API in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/durabletask/test_batch_actions.py | Adds orchestration query-by-prefix test and serialization regression test. |
| durabletask/internal/client_helpers.py | Populates InstanceQuery.instanceIdPrefix from OrchestrationQuery.instance_id_prefix. |
| durabletask/client.py | Extends the public OrchestrationQuery dataclass with instance_id_prefix. |
| CHANGELOG.md | Documents the new user-facing query filter under ## Unreleased. |
Suppressed comments (1)
durabletask/client.py:199
OrchestrationQueryis a public dataclass; insertinginstance_id_prefixin the middle changes the positional argument order, which can break callers that instantiateOrchestrationQuerypositionally. To preserve backwards compatibility, append new fields at the end of the dataclass field list.
instance_id_prefix: str | None = None
# Some backends don't respond well with max_instance_count = None, so we use the integer limit for non-paginated
# results instead.
max_instance_count: int | None = (1 << 31) - 1
fetch_inputs_and_outputs: bool = False
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Bernd Verst (berndverst)
left a comment
There was a problem hiding this comment.
Requesting changes for the positional-constructor compatibility regression. The wire mapping and query behavior otherwise look sound.
| created_time_from: datetime | None = None | ||
| created_time_to: datetime | None = None | ||
| runtime_status: list[OrchestrationStatus] | None = None | ||
| instance_id_prefix: str | None = None |
There was a problem hiding this comment.
This inserts a field into the middle of a public dataclass's generated positional constructor. Existing OrchestrationQuery(None, None, None, None, True) calls now bind True to max_instance_count and leave fetch_inputs_and_outputs=False; numeric fourth arguments can reach StringValue as the prefix and raise TypeError. Please move instance_id_prefix after fetch_inputs_and_outputs and add a regression test for the original five-position mapping.
There was a problem hiding this comment.
Moved instance_id_prefix after the existing fields and added a regression test that verifies the original five-position constructor mapping.
| ADDED | ||
|
|
||
| - Added `OrchestrationQuery.instance_id_prefix` to retrieve orchestration | ||
| instances whose IDs begin with a specified prefix. |
There was a problem hiding this comment.
This API is also exposed through DurableTaskSchedulerClient and the sync/async Durable Functions clients by inheritance. The repository changelog policy therefore requires matching ## Unreleased entries in durabletask-azuremanaged/CHANGELOG.md and azure-functions-durable/CHANGELOG.md. Please document the inherited user-facing filter in both provider changelogs.
There was a problem hiding this comment.
Added matching ## Unreleased entries to the Durable Task Scheduler and Azure Functions Durable changelogs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: abe44a4b-db94-4661-bb3b-2d7dd30b1e78
|
Resolves one half of #222 |
Summary
instance_id_prefixtoOrchestrationQueryand serialize it toInstanceQuery.instanceIdPrefixValidation
python -m pytest tests/durabletask/test_batch_actions.pypython -m flake8 durabletaskpython -m flake8 tests/durabletask