dex-python-sdk 1.45.0__tar.gz → 1.45.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dex_python_sdk-1.45.0/README.md → dex_python_sdk-1.45.2/PKG-INFO +37 -2
- dex_python_sdk-1.45.0/PKG-INFO → dex_python_sdk-1.45.2/README.md +20 -19
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/__init__.py +18 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_pull_worker.py +30 -9
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_server_protocol.py +12 -1
- dex_python_sdk-1.45.2/dex/_task_queue_names.py +47 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_worker_dispatcher.py +2 -1
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/async_client.py +79 -3
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/async_worker.py +10 -2
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/client.py +79 -3
- dex_python_sdk-1.45.2/dex/dexpb/dex_pb2.py +457 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/dexpb/dex_pb2.pyi +16 -8
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/flow_options.py +59 -0
- dex_python_sdk-1.45.2/dex/flow_state.py +322 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/pull_registration.py +37 -9
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/worker.py +10 -2
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/worker_options.py +37 -1
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/pyproject.toml +1 -1
- dex_python_sdk-1.45.0/dex/dexpb/dex_pb2.py +0 -457
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/LEGACY_NOTICES.md +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/LICENSE +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_async_value_hydrator.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_async_worker_dispatcher.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_attribute_reads.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_credential_transport.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_flow_definition_upload.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_flow_service_tls.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_grpc_errors.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_invocation_context.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_message_size.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_native.pyi +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_utils.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_value_hydrator.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/_value_mapper.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/action.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/attribute.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/attribute_match.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/attribute_values.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/blob_cache.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/channel.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/client_options.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/codec.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/condition.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/context.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/credential.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/dexpb/__init__.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/dexpb/dex_pb2_grpc.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/flow.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/flow_config.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/flow_definition.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/flow_info.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/flow_result.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/flow_service_tls_options.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/join.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/py.typed +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/rpc_invoke_options.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/runtime_errors.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/step.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/step_execution.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/stream.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/subflow.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/timer.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/wait.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/dex/wait_options.py +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/Cargo.lock +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/Cargo.toml +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/Cargo.toml +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/LICENSE +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/README.md +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/config.rs +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/entry.rs +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/error.rs +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/format.rs +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/lib.rs +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/policy.rs +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/store.rs +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/tests/blob_cache_integration.rs +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/Cargo.toml +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/LICENSE +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/README.md +0 -0
- {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/src/lib.rs +0 -0
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dex-python-sdk
|
|
3
|
+
Version: 1.45.2
|
|
4
|
+
Requires-Dist: grpcio>=1.83.0
|
|
5
|
+
Requires-Dist: grpcio-status>=1.83.0
|
|
6
|
+
Requires-Dist: protobuf>=7.35.1
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: LEGACY_NOTICES.md
|
|
9
|
+
Summary: Python SDK for the Dex workflow engine
|
|
10
|
+
Author: Super Durable
|
|
11
|
+
License-Expression: LicenseRef-Sustainable-Use-1.0
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
14
|
+
Project-URL: Homepage, https://github.com/superdurable/dex/tree/main/sdk-python
|
|
15
|
+
Project-URL: Repository, https://github.com/superdurable/dex
|
|
16
|
+
|
|
1
17
|
|
|
2
18
|
# Dex SDK for Python
|
|
3
19
|
|
|
@@ -292,8 +308,8 @@ A permanent rejection before readiness raises `PullRegistrationError`, whose
|
|
|
292
308
|
Stopping before readiness raises `RuntimeError`.
|
|
293
309
|
|
|
294
310
|
Use `worker.pull_registration_state()` for subsequent readiness probes. Its
|
|
295
|
-
immutable `queues` expose `queue`, `has_registered_stream`,
|
|
296
|
-
`last_permanent_error`. After initial registration, `is_ready` stays true across
|
|
311
|
+
immutable `queues` expose `queue`, `has_registered_stream`,
|
|
312
|
+
`last_permanent_error`, and `task_queue`. After initial registration, `is_ready` stays true across
|
|
297
313
|
transient failures, reconnects, and stop. It becomes false only when a required slot kind
|
|
298
314
|
has a permanent error and no registered stream. Re-registration clears the
|
|
299
315
|
error. The startup wait keeps succeeding after initial registration, including
|
|
@@ -325,6 +341,24 @@ The Worker never declines a Step for capacity.
|
|
|
325
341
|
pull = PullWorkerOptions(max_concurrent_tasks=8, reserved_rpc_tasks=2)
|
|
326
342
|
```
|
|
327
343
|
|
|
344
|
+
### Named task queues
|
|
345
|
+
|
|
346
|
+
`PullWorkerOptions(task_queue="gpu")` makes a Worker poll the `gpu` task queue,
|
|
347
|
+
and `StartFlowOptions(task_queue="gpu")` starts a Flow on it. Only Workers on
|
|
348
|
+
that task queue that register the Flow type receive its Steps and RPCs. A Worker
|
|
349
|
+
polls one task queue; run one Worker per task queue to serve several. An empty
|
|
350
|
+
name selects the default task queue. A SubFlow inherits its parent's task queue
|
|
351
|
+
unless `SubFlowOptions.task_queue` names another one or `dex.default`. Named
|
|
352
|
+
task queues need Dex Server protocol version 5; see the `task_queue` doc
|
|
353
|
+
comments for name rules and failure behavior.
|
|
354
|
+
|
|
355
|
+
```python
|
|
356
|
+
gpu_worker = Worker(
|
|
357
|
+
registry, cache, WorkerOptions(pull=PullWorkerOptions(task_queue="gpu"))
|
|
358
|
+
)
|
|
359
|
+
client.start_flow(render_flow, "render-7", render_input, StartFlowOptions(task_queue="gpu"))
|
|
360
|
+
```
|
|
361
|
+
|
|
328
362
|
The `pull_reserved_rpc_declines` counter is deprecated and always zero. It stays
|
|
329
363
|
available for source compatibility. Registration snapshot `queues` and error
|
|
330
364
|
`queue` fields retain their names but now hold slot kind labels, `STEP_AND_RPC`
|
|
@@ -1152,3 +1186,4 @@ original terms as described in [LEGACY_NOTICES.md](LEGACY_NOTICES.md).
|
|
|
1152
1186
|
|
|
1153
1187
|
Searches return runs that match the query. Include `FlowType` when using shared
|
|
1154
1188
|
index slots, and keep the query and page size consistent across pages.
|
|
1189
|
+
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: dex-python-sdk
|
|
3
|
-
Version: 1.45.0
|
|
4
|
-
Requires-Dist: grpcio>=1.83.0
|
|
5
|
-
Requires-Dist: grpcio-status>=1.83.0
|
|
6
|
-
Requires-Dist: protobuf>=7.35.1
|
|
7
|
-
License-File: LICENSE
|
|
8
|
-
License-File: LEGACY_NOTICES.md
|
|
9
|
-
Summary: Python SDK for the Dex workflow engine
|
|
10
|
-
Author: Super Durable
|
|
11
|
-
License-Expression: LicenseRef-Sustainable-Use-1.0
|
|
12
|
-
Requires-Python: >=3.11
|
|
13
|
-
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
14
|
-
Project-URL: Homepage, https://github.com/superdurable/dex/tree/main/sdk-python
|
|
15
|
-
Project-URL: Repository, https://github.com/superdurable/dex
|
|
16
|
-
|
|
17
1
|
|
|
18
2
|
# Dex SDK for Python
|
|
19
3
|
|
|
@@ -308,8 +292,8 @@ A permanent rejection before readiness raises `PullRegistrationError`, whose
|
|
|
308
292
|
Stopping before readiness raises `RuntimeError`.
|
|
309
293
|
|
|
310
294
|
Use `worker.pull_registration_state()` for subsequent readiness probes. Its
|
|
311
|
-
immutable `queues` expose `queue`, `has_registered_stream`,
|
|
312
|
-
`last_permanent_error`. After initial registration, `is_ready` stays true across
|
|
295
|
+
immutable `queues` expose `queue`, `has_registered_stream`,
|
|
296
|
+
`last_permanent_error`, and `task_queue`. After initial registration, `is_ready` stays true across
|
|
313
297
|
transient failures, reconnects, and stop. It becomes false only when a required slot kind
|
|
314
298
|
has a permanent error and no registered stream. Re-registration clears the
|
|
315
299
|
error. The startup wait keeps succeeding after initial registration, including
|
|
@@ -341,6 +325,24 @@ The Worker never declines a Step for capacity.
|
|
|
341
325
|
pull = PullWorkerOptions(max_concurrent_tasks=8, reserved_rpc_tasks=2)
|
|
342
326
|
```
|
|
343
327
|
|
|
328
|
+
### Named task queues
|
|
329
|
+
|
|
330
|
+
`PullWorkerOptions(task_queue="gpu")` makes a Worker poll the `gpu` task queue,
|
|
331
|
+
and `StartFlowOptions(task_queue="gpu")` starts a Flow on it. Only Workers on
|
|
332
|
+
that task queue that register the Flow type receive its Steps and RPCs. A Worker
|
|
333
|
+
polls one task queue; run one Worker per task queue to serve several. An empty
|
|
334
|
+
name selects the default task queue. A SubFlow inherits its parent's task queue
|
|
335
|
+
unless `SubFlowOptions.task_queue` names another one or `dex.default`. Named
|
|
336
|
+
task queues need Dex Server protocol version 5; see the `task_queue` doc
|
|
337
|
+
comments for name rules and failure behavior.
|
|
338
|
+
|
|
339
|
+
```python
|
|
340
|
+
gpu_worker = Worker(
|
|
341
|
+
registry, cache, WorkerOptions(pull=PullWorkerOptions(task_queue="gpu"))
|
|
342
|
+
)
|
|
343
|
+
client.start_flow(render_flow, "render-7", render_input, StartFlowOptions(task_queue="gpu"))
|
|
344
|
+
```
|
|
345
|
+
|
|
344
346
|
The `pull_reserved_rpc_declines` counter is deprecated and always zero. It stays
|
|
345
347
|
available for source compatibility. Registration snapshot `queues` and error
|
|
346
348
|
`queue` fields retain their names but now hold slot kind labels, `STEP_AND_RPC`
|
|
@@ -1168,4 +1170,3 @@ original terms as described in [LEGACY_NOTICES.md](LEGACY_NOTICES.md).
|
|
|
1168
1170
|
|
|
1169
1171
|
Searches return runs that match the query. Include `FlowType` when using shared
|
|
1170
1172
|
index slots, and keep the query and page size consistent across pages.
|
|
1171
|
-
|
|
@@ -67,6 +67,16 @@ from dex.flow_info import (
|
|
|
67
67
|
SearchFlowEntry,
|
|
68
68
|
SearchFlowsPage,
|
|
69
69
|
)
|
|
70
|
+
from dex.flow_state import (
|
|
71
|
+
ActiveStepExecution,
|
|
72
|
+
ActiveStepExecutionPhase,
|
|
73
|
+
FlowState,
|
|
74
|
+
StepMethodFailureInfo,
|
|
75
|
+
StepMethodInvocation,
|
|
76
|
+
StepMethodInvocationPhase,
|
|
77
|
+
StepMethodName,
|
|
78
|
+
StepMethodPendingReason,
|
|
79
|
+
)
|
|
70
80
|
from dex.flow_options import (
|
|
71
81
|
FlowTimeoutHandlerOptions,
|
|
72
82
|
FlowTimeoutPolicy,
|
|
@@ -207,6 +217,14 @@ __all__ = [
|
|
|
207
217
|
"FlowNotActiveOrNotFoundError",
|
|
208
218
|
"FlowNotFoundError",
|
|
209
219
|
"FlowStatus",
|
|
220
|
+
"ActiveStepExecution",
|
|
221
|
+
"ActiveStepExecutionPhase",
|
|
222
|
+
"FlowState",
|
|
223
|
+
"StepMethodFailureInfo",
|
|
224
|
+
"StepMethodInvocation",
|
|
225
|
+
"StepMethodInvocationPhase",
|
|
226
|
+
"StepMethodName",
|
|
227
|
+
"StepMethodPendingReason",
|
|
210
228
|
"FlowTimeoutHandlerOptions",
|
|
211
229
|
"FlowTimeoutPolicy",
|
|
212
230
|
"HealthInfo",
|
|
@@ -51,6 +51,17 @@ _PERMANENT_CODES = {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
|
|
54
|
+
class TaskQueueRegistrationMismatchError(RuntimeError):
|
|
55
|
+
def __init__(self, requested_task_queue: str, registered_task_queue: str) -> None:
|
|
56
|
+
super().__init__(
|
|
57
|
+
f"Server registered the Worker task stream on task queue "
|
|
58
|
+
f"{registered_task_queue!r} instead of the requested task queue "
|
|
59
|
+
f"{requested_task_queue!r}"
|
|
60
|
+
)
|
|
61
|
+
self.requested_task_queue = requested_task_queue
|
|
62
|
+
self.registered_task_queue = registered_task_queue
|
|
63
|
+
|
|
64
|
+
|
|
54
65
|
def generate_app_worker_id() -> str:
|
|
55
66
|
identity = next(
|
|
56
67
|
(
|
|
@@ -118,6 +129,7 @@ class PullWorkerRuntime:
|
|
|
118
129
|
self._registry = registry
|
|
119
130
|
self.app_worker_id = app_worker_id or resolve_app_worker_id(registry, options)
|
|
120
131
|
self.flow_types = sorted(registry._registered_flows)
|
|
132
|
+
self.task_queue = options.task_queue
|
|
121
133
|
self._stop_on_permanent_stream_rejection = (
|
|
122
134
|
options.stop_on_permanent_stream_rejection
|
|
123
135
|
)
|
|
@@ -136,7 +148,7 @@ class PullWorkerRuntime:
|
|
|
136
148
|
self.queues = ("STEP_AND_RPC",) + (
|
|
137
149
|
("RPC_ONLY",) if self.reserved_rpc_tasks else ()
|
|
138
150
|
)
|
|
139
|
-
self.registration = _PullRegistration(self.queues)
|
|
151
|
+
self.registration = _PullRegistration(self.queues, self.task_queue)
|
|
140
152
|
self._has_checked_registration_limit = False
|
|
141
153
|
self.stop_drain_timeout = options.stop_drain_timeout.total_seconds() or 30
|
|
142
154
|
self._dispatcher = dispatcher
|
|
@@ -421,10 +433,13 @@ class PullStream:
|
|
|
421
433
|
self.is_draining = False
|
|
422
434
|
was_registered = False
|
|
423
435
|
error: grpc.RpcError | None = None
|
|
436
|
+
task_queue_mismatch: TaskQueueRegistrationMismatchError | None = None
|
|
424
437
|
try:
|
|
425
438
|
was_registered = await self._poll()
|
|
426
439
|
except grpc.RpcError as failure:
|
|
427
440
|
error = failure
|
|
441
|
+
except TaskQueueRegistrationMismatchError as failure:
|
|
442
|
+
task_queue_mismatch = failure
|
|
428
443
|
except Exception:
|
|
429
444
|
_LOGGER.exception(
|
|
430
445
|
"Worker task stream failed", extra={"queue": self.queue}
|
|
@@ -449,14 +464,11 @@ class PullStream:
|
|
|
449
464
|
)
|
|
450
465
|
if can_reject_token and credential is not None:
|
|
451
466
|
_reject_credential_token(credential, self._stream_metadata)
|
|
467
|
+
permanent_error: BaseException | None = task_queue_mismatch
|
|
468
|
+
if code in _PERMANENT_CODES and not should_retry_unauthenticated:
|
|
469
|
+
permanent_error = error
|
|
452
470
|
rejection = self.runtime.registration.record_stream_result(
|
|
453
|
-
self.queue,
|
|
454
|
-
self._is_registered,
|
|
455
|
-
(
|
|
456
|
-
error
|
|
457
|
-
if code in _PERMANENT_CODES and not should_retry_unauthenticated
|
|
458
|
-
else None
|
|
459
|
-
),
|
|
471
|
+
self.queue, self._is_registered, permanent_error
|
|
460
472
|
)
|
|
461
473
|
self._is_registered = False
|
|
462
474
|
self._stream_metadata = None
|
|
@@ -492,6 +504,9 @@ class PullStream:
|
|
|
492
504
|
elif code in _PERMANENT_CODES:
|
|
493
505
|
_LOGGER.error("Worker task stream rejected: %s", error)
|
|
494
506
|
backoff = 60
|
|
507
|
+
elif task_queue_mismatch is not None:
|
|
508
|
+
_LOGGER.error("Worker task stream rejected: %s", task_queue_mismatch)
|
|
509
|
+
backoff = 60
|
|
495
510
|
elif error is not None:
|
|
496
511
|
_LOGGER.warning("Worker task stream disconnected: %s", error)
|
|
497
512
|
if self.runtime._stopping is not None:
|
|
@@ -502,7 +517,7 @@ class PullStream:
|
|
|
502
517
|
)
|
|
503
518
|
except asyncio.TimeoutError:
|
|
504
519
|
pass
|
|
505
|
-
if code not in _PERMANENT_CODES:
|
|
520
|
+
if code not in _PERMANENT_CODES and task_queue_mismatch is None:
|
|
506
521
|
backoff = min(backoff * 2, 5)
|
|
507
522
|
|
|
508
523
|
async def _poll(self) -> bool:
|
|
@@ -538,6 +553,7 @@ class PullStream:
|
|
|
538
553
|
flow_types=self.runtime.flow_types,
|
|
539
554
|
sdk_name="python",
|
|
540
555
|
sdk_version=sdk_version(),
|
|
556
|
+
task_queue=self.runtime.task_queue,
|
|
541
557
|
)
|
|
542
558
|
)
|
|
543
559
|
)
|
|
@@ -577,6 +593,11 @@ class PullStream:
|
|
|
577
593
|
return False
|
|
578
594
|
if kind != "registered":
|
|
579
595
|
raise RuntimeError("Worker task stream did not register")
|
|
596
|
+
# An older Server ignores the request field and registers the default queue.
|
|
597
|
+
if frame.registered.task_queue != self.runtime.task_queue:
|
|
598
|
+
raise TaskQueueRegistrationMismatchError(
|
|
599
|
+
self.runtime.task_queue, frame.registered.task_queue
|
|
600
|
+
)
|
|
580
601
|
was_registered = True
|
|
581
602
|
if not self.runtime.accept_registration(frame.registered):
|
|
582
603
|
# Half-close, not reset, so an already sent task returns unused.
|
|
@@ -17,8 +17,9 @@ import grpc
|
|
|
17
17
|
from dex.dexpb import dex_pb2 as pb
|
|
18
18
|
|
|
19
19
|
MINIMUM_SUPPORTED_SERVER_PROTOCOL_VERSION = 4
|
|
20
|
-
MAXIMUM_SUPPORTED_SERVER_PROTOCOL_VERSION =
|
|
20
|
+
MAXIMUM_SUPPORTED_SERVER_PROTOCOL_VERSION = 5
|
|
21
21
|
HARD_DELETE_ATTRIBUTE_PROTOCOL_VERSION = 3
|
|
22
|
+
NAMED_TASK_QUEUE_PROTOCOL_VERSION = 5
|
|
22
23
|
LAST_SERVER_ZD_RELEASE_BEFORE_MINIMUM_PROTOCOL = "v0.1.16"
|
|
23
24
|
|
|
24
25
|
|
|
@@ -97,6 +98,16 @@ class NegotiatedServerProtocol:
|
|
|
97
98
|
f"protocol version is {self._version}: {', '.join(attribute_names)}"
|
|
98
99
|
)
|
|
99
100
|
|
|
101
|
+
def require_named_task_queue_support(self, task_queue: str) -> None:
|
|
102
|
+
if not task_queue or self._version >= NAMED_TASK_QUEUE_PROTOCOL_VERSION:
|
|
103
|
+
return
|
|
104
|
+
raise RuntimeError(
|
|
105
|
+
f"task queue {task_queue!r} requires Dex Server protocol version "
|
|
106
|
+
f"{NAMED_TASK_QUEUE_PROTOCOL_VERSION} or later, but the negotiated "
|
|
107
|
+
f"protocol version is {self._version}; upgrade the Server or use "
|
|
108
|
+
"the default task queue"
|
|
109
|
+
)
|
|
110
|
+
|
|
100
111
|
|
|
101
112
|
def server_info_request_error(
|
|
102
113
|
artifact_version: str, failure: grpc.RpcError
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Sustainable Use License 1.0.
|
|
4
|
+
# You may not use this file except in compliance with the License.
|
|
5
|
+
# See the LICENSE file in the repository root.
|
|
6
|
+
#
|
|
7
|
+
# SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
|
|
8
|
+
|
|
9
|
+
MAX_TASK_QUEUE_NAME_LENGTH = 63
|
|
10
|
+
RESERVED_TASK_QUEUE_PREFIX = "dex."
|
|
11
|
+
DEFAULT_TASK_QUEUE_ALIAS = "dex.default"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def registered_task_queue_name_error(name: str) -> str | None:
|
|
15
|
+
"""Check a task queue name that a Worker may register.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
None when ``name`` is valid, including the empty default task queue.
|
|
19
|
+
Otherwise a sentence that explains why the name is invalid.
|
|
20
|
+
"""
|
|
21
|
+
if not name:
|
|
22
|
+
return None
|
|
23
|
+
if name.startswith(RESERVED_TASK_QUEUE_PREFIX):
|
|
24
|
+
return 'task queue names starting with "dex." are reserved'
|
|
25
|
+
return _task_queue_characters_error(name)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def target_task_queue_name_error(name: str) -> str | None:
|
|
29
|
+
"""Check a task queue name that a started Flow or SubFlow may select.
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
None when ``name`` is valid: every registrable name plus
|
|
33
|
+
``dex.default``. Otherwise a sentence that explains why it is invalid.
|
|
34
|
+
"""
|
|
35
|
+
if name == DEFAULT_TASK_QUEUE_ALIAS:
|
|
36
|
+
return None
|
|
37
|
+
return registered_task_queue_name_error(name)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _task_queue_characters_error(name: str) -> str | None:
|
|
41
|
+
if len(name) > MAX_TASK_QUEUE_NAME_LENGTH:
|
|
42
|
+
return "task queue names have at most 63 characters"
|
|
43
|
+
if not name.isascii() or any(
|
|
44
|
+
not (character.isalnum() or character in "._-") for character in name
|
|
45
|
+
):
|
|
46
|
+
return "task queue names use only A-Z, a-z, 0-9, '.', '_', and '-'"
|
|
47
|
+
return None
|
|
@@ -742,8 +742,9 @@ class WorkerDispatcher:
|
|
|
742
742
|
mapped.flow_config_override.CopyFrom(
|
|
743
743
|
self._map_sub_flow_config(options.config_override)
|
|
744
744
|
)
|
|
745
|
+
self._server_protocol.require_named_task_queue_support(options.task_queue)
|
|
745
746
|
mapped.flow_config_override.worker_target.CopyFrom(
|
|
746
|
-
pb.WorkerTarget(is_pull_mode=True)
|
|
747
|
+
pb.WorkerTarget(is_pull_mode=True, task_queue=options.task_queue)
|
|
747
748
|
)
|
|
748
749
|
return mapped
|
|
749
750
|
|
|
@@ -65,6 +65,7 @@ from dex.flow_definition import (
|
|
|
65
65
|
)
|
|
66
66
|
from dex.flow_config import ActiveStepSearchMode, FlowConfig
|
|
67
67
|
from dex.flow_info import FlowInfo, FlowStatus, SearchFlowEntry, SearchFlowsPage
|
|
68
|
+
from dex.flow_state import FlowState, flow_state_from_proto
|
|
68
69
|
from dex.flow_options import (
|
|
69
70
|
FlowTimeoutPolicy,
|
|
70
71
|
IdReusePolicy,
|
|
@@ -239,8 +240,13 @@ class AsyncClient:
|
|
|
239
240
|
including a numeric or Boolean value for a hard-delete Attribute.
|
|
240
241
|
ValueError: If an initial Attribute uses a different ``hard_delete_on_null``
|
|
241
242
|
setting than the Flow's registered definition of that name.
|
|
242
|
-
RuntimeError: If the Server reports a protocol range without protocol 4
|
|
243
|
+
RuntimeError: If the Server reports a protocol range without protocol 4,
|
|
244
|
+
or ``options.task_queue`` is set and the Server protocol is older
|
|
245
|
+
than version 5. The request is not sent in either case.
|
|
243
246
|
DexServiceError: If FlowService rejects or cannot perform the request.
|
|
247
|
+
|
|
248
|
+
.. versionchanged:: 1.45.1
|
|
249
|
+
Sends ``options.task_queue`` and checks Server protocol 5 first.
|
|
244
250
|
"""
|
|
245
251
|
registered = self.registry._flow_for_instance(flow)
|
|
246
252
|
request = pb.StartFlowRequest(
|
|
@@ -282,13 +288,16 @@ class AsyncClient:
|
|
|
282
288
|
timeout_handler_options
|
|
283
289
|
)
|
|
284
290
|
start_attributes = request.flow_start_options.attributes
|
|
285
|
-
if
|
|
291
|
+
if options.task_queue or any(
|
|
292
|
+
write.is_hard_delete_on_null for write in start_attributes
|
|
293
|
+
):
|
|
286
294
|
await self._negotiate_server_protocol_for_operation(
|
|
287
295
|
"start_flow", flow_id, "none"
|
|
288
296
|
)
|
|
289
297
|
self._server_protocol.require_hard_delete_attribute_support(
|
|
290
298
|
start_attributes
|
|
291
299
|
)
|
|
300
|
+
self._server_protocol.require_named_task_queue_support(options.task_queue)
|
|
292
301
|
response = cast(
|
|
293
302
|
pb.StartFlowResponse,
|
|
294
303
|
await self._call(
|
|
@@ -726,6 +735,73 @@ class AsyncClient:
|
|
|
726
735
|
response.start_time.ToDatetime(tzinfo=timezone.utc),
|
|
727
736
|
)
|
|
728
737
|
|
|
738
|
+
async def get_flow_state(self, flow_id: str) -> FlowState:
|
|
739
|
+
"""Read the open Step executions, their latest failures, and the task queue.
|
|
740
|
+
|
|
741
|
+
.. versionadded:: 1.45.2
|
|
742
|
+
|
|
743
|
+
Use ``get_flow_state`` when a Flow is still running and you need to know
|
|
744
|
+
why. It tells a healthy Flow apart from a Flow whose active Step keeps
|
|
745
|
+
failing and retrying. Each ``ActiveStepExecution`` reports its Step type,
|
|
746
|
+
execution number, and phase. While a WaitFor or Execute call is open,
|
|
747
|
+
``invocation`` reports its attempt and whether it is pending, running, or
|
|
748
|
+
in retry backoff. ``last_failure`` reports the latest failed attempt of
|
|
749
|
+
that call: its attempt number, error type, message, and stack trace. A
|
|
750
|
+
Step that has not failed has no ``last_failure``.
|
|
751
|
+
|
|
752
|
+
The result also reports the Flow's task queue in ``task_queue``. ``""``
|
|
753
|
+
means the default task queue.
|
|
754
|
+
|
|
755
|
+
The call reads committed server state once and does not wait. No Worker
|
|
756
|
+
runs. Poll it, for example in a test harness, to wait for a Step to start
|
|
757
|
+
failing. Use ``wait_for_flow`` or ``wait_for_step_completion`` to wait for
|
|
758
|
+
completion instead. A closed run stays readable until Dex purges it and
|
|
759
|
+
reports no open Step executions.
|
|
760
|
+
|
|
761
|
+
Example:
|
|
762
|
+
.. code-block:: python
|
|
763
|
+
|
|
764
|
+
state = await client.get_flow_state("order-42")
|
|
765
|
+
print(f"task queue: {state.task_queue or 'default'}")
|
|
766
|
+
for step in state.active_step_executions:
|
|
767
|
+
failure = step.last_failure
|
|
768
|
+
if failure is None:
|
|
769
|
+
phase = step.invocation.phase if step.invocation else step.phase
|
|
770
|
+
print(f"{step.step_execution_id} is {phase.value}")
|
|
771
|
+
continue
|
|
772
|
+
next_attempt = step.invocation.attempt if step.invocation else None
|
|
773
|
+
print(
|
|
774
|
+
f"{step.step_execution_id} attempt {failure.attempt} failed "
|
|
775
|
+
f"with {failure.error_type}: {failure.detail}; "
|
|
776
|
+
f"next attempt {next_attempt}"
|
|
777
|
+
)
|
|
778
|
+
|
|
779
|
+
Args:
|
|
780
|
+
flow_id: The non-empty ID of an existing Flow.
|
|
781
|
+
|
|
782
|
+
Returns:
|
|
783
|
+
The open Step executions and the task queue of the current run, or of
|
|
784
|
+
the latest run when no run is open.
|
|
785
|
+
|
|
786
|
+
Raises:
|
|
787
|
+
ValueError: If ``flow_id`` is empty.
|
|
788
|
+
FlowNotFoundError: If ``flow_id`` does not exist.
|
|
789
|
+
DexServiceError: For other service or transport failures.
|
|
790
|
+
RuntimeError: If the Server reports a protocol range without protocol
|
|
791
|
+
4, or returns a malformed Step execution ID.
|
|
792
|
+
"""
|
|
793
|
+
response = cast(
|
|
794
|
+
pb.GetFlowStateResponse,
|
|
795
|
+
await self._call(
|
|
796
|
+
self._service.GetFlowState,
|
|
797
|
+
pb.GetFlowStateRequest(flow_id=require_name(flow_id)),
|
|
798
|
+
"get_flow_state",
|
|
799
|
+
flow_id,
|
|
800
|
+
"existing",
|
|
801
|
+
),
|
|
802
|
+
)
|
|
803
|
+
return flow_state_from_proto(flow_id, response)
|
|
804
|
+
|
|
729
805
|
async def get_attributes(
|
|
730
806
|
self,
|
|
731
807
|
flow_id: str,
|
|
@@ -1503,7 +1579,7 @@ class AsyncClient:
|
|
|
1503
1579
|
self._map_flow_config(options.config_override)
|
|
1504
1580
|
)
|
|
1505
1581
|
mapped.flow_config_override.worker_target.CopyFrom(
|
|
1506
|
-
pb.WorkerTarget(is_pull_mode=True)
|
|
1582
|
+
pb.WorkerTarget(is_pull_mode=True, task_queue=options.task_queue)
|
|
1507
1583
|
)
|
|
1508
1584
|
return mapped
|
|
1509
1585
|
|
|
@@ -173,11 +173,16 @@ class AsyncWorker:
|
|
|
173
173
|
Uploads the configured Flow definitions before opening task streams.
|
|
174
174
|
An upload failure is logged as a warning and does not fail start.
|
|
175
175
|
|
|
176
|
+
.. versionchanged:: 1.45.1
|
|
177
|
+
Fails before opening task streams when ``PullWorkerOptions.task_queue``
|
|
178
|
+
names a task queue and the Server protocol is older than version 5.
|
|
179
|
+
|
|
176
180
|
Raises:
|
|
177
181
|
PullRegistrationError: A permanent stream rejection stops this Worker.
|
|
178
182
|
RuntimeError: If lifecycle state is invalid, Server protocol 4 is
|
|
179
|
-
unsupported,
|
|
180
|
-
or index
|
|
183
|
+
unsupported, a named task queue needs Server protocol 5,
|
|
184
|
+
concurrency exceeds matching.maxConcurrentTasksCap, or index
|
|
185
|
+
synchronization fails.
|
|
181
186
|
"""
|
|
182
187
|
if self._has_start_called:
|
|
183
188
|
raise RuntimeError("Worker can only start once")
|
|
@@ -285,6 +290,9 @@ class AsyncWorker:
|
|
|
285
290
|
self._server_protocol.record_version(
|
|
286
291
|
negotiate_server_protocol(server_info, self._sdk_version)
|
|
287
292
|
)
|
|
293
|
+
self._server_protocol.require_named_task_queue_support(
|
|
294
|
+
self.options.pull.task_queue
|
|
295
|
+
)
|
|
288
296
|
except RuntimeError:
|
|
289
297
|
self._state = "stopped"
|
|
290
298
|
await self._close_failed_start_channel()
|
|
@@ -65,6 +65,7 @@ from dex.flow_definition import (
|
|
|
65
65
|
)
|
|
66
66
|
from dex.flow_config import ActiveStepSearchMode, FlowConfig
|
|
67
67
|
from dex.flow_info import FlowInfo, FlowStatus, SearchFlowEntry, SearchFlowsPage
|
|
68
|
+
from dex.flow_state import FlowState, flow_state_from_proto
|
|
68
69
|
from dex.flow_options import (
|
|
69
70
|
FlowTimeoutPolicy,
|
|
70
71
|
IdReusePolicy,
|
|
@@ -235,9 +236,14 @@ class Client:
|
|
|
235
236
|
including a numeric or Boolean value for a hard-delete Attribute.
|
|
236
237
|
ValueError: If an initial Attribute uses a different ``hard_delete_on_null``
|
|
237
238
|
setting than the Flow's registered definition of that name.
|
|
238
|
-
RuntimeError: If the Server reports a protocol range without protocol 4
|
|
239
|
+
RuntimeError: If the Server reports a protocol range without protocol 4,
|
|
240
|
+
or ``options.task_queue`` is set and the Server protocol is older
|
|
241
|
+
than version 5. The request is not sent in either case.
|
|
239
242
|
DexServiceError: If FlowService rejects or cannot perform the request.
|
|
240
243
|
|
|
244
|
+
.. versionchanged:: 1.45.1
|
|
245
|
+
Sends ``options.task_queue`` and checks Server protocol 5 first.
|
|
246
|
+
|
|
241
247
|
Examples:
|
|
242
248
|
>>> from dex import StartFlowOptions
|
|
243
249
|
>>> options = StartFlowOptions(
|
|
@@ -286,11 +292,14 @@ class Client:
|
|
|
286
292
|
timeout_handler_options
|
|
287
293
|
)
|
|
288
294
|
start_attributes = request.flow_start_options.attributes
|
|
289
|
-
if
|
|
295
|
+
if options.task_queue or any(
|
|
296
|
+
write.is_hard_delete_on_null for write in start_attributes
|
|
297
|
+
):
|
|
290
298
|
self._negotiate_server_protocol_for_operation("start_flow", flow_id, "none")
|
|
291
299
|
self._server_protocol.require_hard_delete_attribute_support(
|
|
292
300
|
start_attributes
|
|
293
301
|
)
|
|
302
|
+
self._server_protocol.require_named_task_queue_support(options.task_queue)
|
|
294
303
|
response = cast(
|
|
295
304
|
pb.StartFlowResponse,
|
|
296
305
|
self._call(self._service.StartFlow, request, "start_flow", flow_id, "none"),
|
|
@@ -741,6 +750,73 @@ class Client:
|
|
|
741
750
|
response.start_time.ToDatetime(tzinfo=timezone.utc),
|
|
742
751
|
)
|
|
743
752
|
|
|
753
|
+
def get_flow_state(self, flow_id: str) -> FlowState:
|
|
754
|
+
"""Read the open Step executions, their latest failures, and the task queue.
|
|
755
|
+
|
|
756
|
+
.. versionadded:: 1.45.2
|
|
757
|
+
|
|
758
|
+
Use ``get_flow_state`` when a Flow is still running and you need to know
|
|
759
|
+
why. It tells a healthy Flow apart from a Flow whose active Step keeps
|
|
760
|
+
failing and retrying. Each ``ActiveStepExecution`` reports its Step type,
|
|
761
|
+
execution number, and phase. While a WaitFor or Execute call is open,
|
|
762
|
+
``invocation`` reports its attempt and whether it is pending, running, or
|
|
763
|
+
in retry backoff. ``last_failure`` reports the latest failed attempt of
|
|
764
|
+
that call: its attempt number, error type, message, and stack trace. A
|
|
765
|
+
Step that has not failed has no ``last_failure``.
|
|
766
|
+
|
|
767
|
+
The result also reports the Flow's task queue in ``task_queue``. ``""``
|
|
768
|
+
means the default task queue.
|
|
769
|
+
|
|
770
|
+
The call reads committed server state once and does not wait. No Worker
|
|
771
|
+
runs. Poll it, for example in a test harness, to wait for a Step to start
|
|
772
|
+
failing. Use ``wait_for_flow`` or ``wait_for_step_completion`` to wait for
|
|
773
|
+
completion instead. A closed run stays readable until Dex purges it and
|
|
774
|
+
reports no open Step executions.
|
|
775
|
+
|
|
776
|
+
Example:
|
|
777
|
+
.. code-block:: python
|
|
778
|
+
|
|
779
|
+
state = client.get_flow_state("order-42")
|
|
780
|
+
print(f"task queue: {state.task_queue or 'default'}")
|
|
781
|
+
for step in state.active_step_executions:
|
|
782
|
+
failure = step.last_failure
|
|
783
|
+
if failure is None:
|
|
784
|
+
phase = step.invocation.phase if step.invocation else step.phase
|
|
785
|
+
print(f"{step.step_execution_id} is {phase.value}")
|
|
786
|
+
continue
|
|
787
|
+
next_attempt = step.invocation.attempt if step.invocation else None
|
|
788
|
+
print(
|
|
789
|
+
f"{step.step_execution_id} attempt {failure.attempt} failed "
|
|
790
|
+
f"with {failure.error_type}: {failure.detail}; "
|
|
791
|
+
f"next attempt {next_attempt}"
|
|
792
|
+
)
|
|
793
|
+
|
|
794
|
+
Args:
|
|
795
|
+
flow_id: The non-empty ID of an existing Flow.
|
|
796
|
+
|
|
797
|
+
Returns:
|
|
798
|
+
The open Step executions and the task queue of the current run, or of
|
|
799
|
+
the latest run when no run is open.
|
|
800
|
+
|
|
801
|
+
Raises:
|
|
802
|
+
ValueError: If ``flow_id`` is empty.
|
|
803
|
+
FlowNotFoundError: If ``flow_id`` does not exist.
|
|
804
|
+
DexServiceError: For other service or transport failures.
|
|
805
|
+
RuntimeError: If the Server reports a protocol range without protocol
|
|
806
|
+
4, or returns a malformed Step execution ID.
|
|
807
|
+
"""
|
|
808
|
+
response = cast(
|
|
809
|
+
pb.GetFlowStateResponse,
|
|
810
|
+
self._call(
|
|
811
|
+
self._service.GetFlowState,
|
|
812
|
+
pb.GetFlowStateRequest(flow_id=require_name(flow_id)),
|
|
813
|
+
"get_flow_state",
|
|
814
|
+
flow_id,
|
|
815
|
+
"existing",
|
|
816
|
+
),
|
|
817
|
+
)
|
|
818
|
+
return flow_state_from_proto(flow_id, response)
|
|
819
|
+
|
|
744
820
|
def get_attributes(
|
|
745
821
|
self,
|
|
746
822
|
flow_id: str,
|
|
@@ -1510,7 +1586,7 @@ class Client:
|
|
|
1510
1586
|
self._map_flow_config(options.config_override)
|
|
1511
1587
|
)
|
|
1512
1588
|
mapped.flow_config_override.worker_target.CopyFrom(
|
|
1513
|
-
pb.WorkerTarget(is_pull_mode=True)
|
|
1589
|
+
pb.WorkerTarget(is_pull_mode=True, task_queue=options.task_queue)
|
|
1514
1590
|
)
|
|
1515
1591
|
return mapped
|
|
1516
1592
|
|