dex-python-sdk 1.45.0__tar.gz → 1.45.1__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.
Files changed (80) hide show
  1. dex_python_sdk-1.45.0/README.md → dex_python_sdk-1.45.1/PKG-INFO +37 -2
  2. dex_python_sdk-1.45.0/PKG-INFO → dex_python_sdk-1.45.1/README.md +20 -19
  3. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_pull_worker.py +30 -9
  4. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_server_protocol.py +12 -1
  5. dex_python_sdk-1.45.1/dex/_task_queue_names.py +47 -0
  6. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_worker_dispatcher.py +2 -1
  7. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/async_client.py +11 -3
  8. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/async_worker.py +10 -2
  9. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/client.py +11 -3
  10. dex_python_sdk-1.45.1/dex/dexpb/dex_pb2.py +457 -0
  11. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/dexpb/dex_pb2.pyi +16 -8
  12. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/flow_options.py +59 -0
  13. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/pull_registration.py +37 -9
  14. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/worker.py +10 -2
  15. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/worker_options.py +37 -1
  16. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/pyproject.toml +1 -1
  17. dex_python_sdk-1.45.0/dex/dexpb/dex_pb2.py +0 -457
  18. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/LEGACY_NOTICES.md +0 -0
  19. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/LICENSE +0 -0
  20. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/__init__.py +0 -0
  21. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_async_value_hydrator.py +0 -0
  22. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_async_worker_dispatcher.py +0 -0
  23. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_attribute_reads.py +0 -0
  24. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_credential_transport.py +0 -0
  25. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_flow_definition_upload.py +0 -0
  26. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_flow_service_tls.py +0 -0
  27. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_grpc_errors.py +0 -0
  28. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_invocation_context.py +0 -0
  29. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_message_size.py +0 -0
  30. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_native.pyi +0 -0
  31. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_utils.py +0 -0
  32. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_value_hydrator.py +0 -0
  33. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/_value_mapper.py +0 -0
  34. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/action.py +0 -0
  35. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/attribute.py +0 -0
  36. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/attribute_match.py +0 -0
  37. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/attribute_values.py +0 -0
  38. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/blob_cache.py +0 -0
  39. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/channel.py +0 -0
  40. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/client_options.py +0 -0
  41. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/codec.py +0 -0
  42. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/condition.py +0 -0
  43. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/context.py +0 -0
  44. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/credential.py +0 -0
  45. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/dexpb/__init__.py +0 -0
  46. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/dexpb/dex_pb2_grpc.py +0 -0
  47. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/flow.py +0 -0
  48. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/flow_config.py +0 -0
  49. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/flow_definition.py +0 -0
  50. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/flow_info.py +0 -0
  51. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/flow_result.py +0 -0
  52. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/flow_service_tls_options.py +0 -0
  53. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/join.py +0 -0
  54. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/py.typed +0 -0
  55. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/rpc_invoke_options.py +0 -0
  56. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/runtime_errors.py +0 -0
  57. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/step.py +0 -0
  58. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/step_execution.py +0 -0
  59. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/stream.py +0 -0
  60. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/subflow.py +0 -0
  61. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/timer.py +0 -0
  62. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/wait.py +0 -0
  63. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/dex/wait_options.py +0 -0
  64. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/Cargo.lock +0 -0
  65. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/Cargo.toml +0 -0
  66. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/Cargo.toml +0 -0
  67. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/LICENSE +0 -0
  68. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/README.md +0 -0
  69. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/src/config.rs +0 -0
  70. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/src/entry.rs +0 -0
  71. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/src/error.rs +0 -0
  72. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/src/format.rs +0 -0
  73. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/src/lib.rs +0 -0
  74. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/src/policy.rs +0 -0
  75. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/src/store.rs +0 -0
  76. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache/tests/blob_cache_integration.rs +0 -0
  77. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache-python/Cargo.toml +0 -0
  78. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache-python/LICENSE +0 -0
  79. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/sdk-rust/crates/dex-blob-cache-python/README.md +0 -0
  80. {dex_python_sdk-1.45.0 → dex_python_sdk-1.45.1}/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.1
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`, and
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`, and
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
-
@@ -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 = 4
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
 
@@ -239,8 +239,13 @@ class AsyncClient:
239
239
  including a numeric or Boolean value for a hard-delete Attribute.
240
240
  ValueError: If an initial Attribute uses a different ``hard_delete_on_null``
241
241
  setting than the Flow's registered definition of that name.
242
- RuntimeError: If the Server reports a protocol range without protocol 4.
242
+ RuntimeError: If the Server reports a protocol range without protocol 4,
243
+ or ``options.task_queue`` is set and the Server protocol is older
244
+ than version 5. The request is not sent in either case.
243
245
  DexServiceError: If FlowService rejects or cannot perform the request.
246
+
247
+ .. versionchanged:: 1.45.1
248
+ Sends ``options.task_queue`` and checks Server protocol 5 first.
244
249
  """
245
250
  registered = self.registry._flow_for_instance(flow)
246
251
  request = pb.StartFlowRequest(
@@ -282,13 +287,16 @@ class AsyncClient:
282
287
  timeout_handler_options
283
288
  )
284
289
  start_attributes = request.flow_start_options.attributes
285
- if any(write.is_hard_delete_on_null for write in start_attributes):
290
+ if options.task_queue or any(
291
+ write.is_hard_delete_on_null for write in start_attributes
292
+ ):
286
293
  await self._negotiate_server_protocol_for_operation(
287
294
  "start_flow", flow_id, "none"
288
295
  )
289
296
  self._server_protocol.require_hard_delete_attribute_support(
290
297
  start_attributes
291
298
  )
299
+ self._server_protocol.require_named_task_queue_support(options.task_queue)
292
300
  response = cast(
293
301
  pb.StartFlowResponse,
294
302
  await self._call(
@@ -1503,7 +1511,7 @@ class AsyncClient:
1503
1511
  self._map_flow_config(options.config_override)
1504
1512
  )
1505
1513
  mapped.flow_config_override.worker_target.CopyFrom(
1506
- pb.WorkerTarget(is_pull_mode=True)
1514
+ pb.WorkerTarget(is_pull_mode=True, task_queue=options.task_queue)
1507
1515
  )
1508
1516
  return mapped
1509
1517
 
@@ -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, concurrency exceeds matching.maxConcurrentTasksCap,
180
- or index synchronization fails.
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()
@@ -235,9 +235,14 @@ class Client:
235
235
  including a numeric or Boolean value for a hard-delete Attribute.
236
236
  ValueError: If an initial Attribute uses a different ``hard_delete_on_null``
237
237
  setting than the Flow's registered definition of that name.
238
- RuntimeError: If the Server reports a protocol range without protocol 4.
238
+ RuntimeError: If the Server reports a protocol range without protocol 4,
239
+ or ``options.task_queue`` is set and the Server protocol is older
240
+ than version 5. The request is not sent in either case.
239
241
  DexServiceError: If FlowService rejects or cannot perform the request.
240
242
 
243
+ .. versionchanged:: 1.45.1
244
+ Sends ``options.task_queue`` and checks Server protocol 5 first.
245
+
241
246
  Examples:
242
247
  >>> from dex import StartFlowOptions
243
248
  >>> options = StartFlowOptions(
@@ -286,11 +291,14 @@ class Client:
286
291
  timeout_handler_options
287
292
  )
288
293
  start_attributes = request.flow_start_options.attributes
289
- if any(write.is_hard_delete_on_null for write in start_attributes):
294
+ if options.task_queue or any(
295
+ write.is_hard_delete_on_null for write in start_attributes
296
+ ):
290
297
  self._negotiate_server_protocol_for_operation("start_flow", flow_id, "none")
291
298
  self._server_protocol.require_hard_delete_attribute_support(
292
299
  start_attributes
293
300
  )
301
+ self._server_protocol.require_named_task_queue_support(options.task_queue)
294
302
  response = cast(
295
303
  pb.StartFlowResponse,
296
304
  self._call(self._service.StartFlow, request, "start_flow", flow_id, "none"),
@@ -1510,7 +1518,7 @@ class Client:
1510
1518
  self._map_flow_config(options.config_override)
1511
1519
  )
1512
1520
  mapped.flow_config_override.worker_target.CopyFrom(
1513
- pb.WorkerTarget(is_pull_mode=True)
1521
+ pb.WorkerTarget(is_pull_mode=True, task_queue=options.task_queue)
1514
1522
  )
1515
1523
  return mapped
1516
1524