dex-python-sdk 1.45.17__tar.gz → 1.45.18__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.17 → dex_python_sdk-1.45.18}/PKG-INFO +44 -26
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/README.md +43 -25
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/__init__.py +4 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_async_worker_dispatcher.py +7 -0
- dex_python_sdk-1.45.18/dex/_attribute_lock_requirement.py +110 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_attribute_reads.py +4 -2
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_pull_slot_streams.py +24 -22
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_stop_flow_mapping.py +2 -1
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_worker_dispatcher.py +33 -24
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/async_client.py +131 -21
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/attribute.py +149 -8
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/channel.py +44 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/client.py +129 -22
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/context.py +1 -2
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/dexpb/dex_pb2.py +218 -218
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/dexpb/dex_pb2.pyi +4 -2
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/flow.py +202 -3
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/flow_config.py +42 -11
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/runtime_errors.py +131 -1
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/step.py +2 -1
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/worker.py +4 -4
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/worker_options.py +108 -19
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/pyproject.toml +1 -1
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/LEGACY_NOTICES.md +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/LICENSE +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_async_value_hydrator.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_credential_transport.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_flow_definition_upload.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_flow_service_tls.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_grpc_errors.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_history_point_mapping.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_invocation_context.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_message_size.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_native.pyi +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_payload_message_codec.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_pull_worker.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_server_protocol.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_task_queue_names.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_utils.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_value_hydrator.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/_value_mapper.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/action.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/async_worker.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/attribute_match.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/attribute_values.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/blob_cache.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/client_options.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/codec.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/condition.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/credential.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/dexpb/__init__.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/dexpb/dex_pb2_grpc.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/flow_definition.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/flow_info.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/flow_options.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/flow_result.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/flow_service_tls_options.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/flow_state.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/graceful_completion_context.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/join.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/payload_encryption.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/pull_registration.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/py.typed +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/rpc_invoke_options.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/step_execution.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/stream.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/subflow.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/timer.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/wait.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/dex/wait_options.py +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/Cargo.lock +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/Cargo.toml +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/Cargo.toml +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/LICENSE +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/README.md +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/src/config.rs +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/src/entry.rs +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/src/error.rs +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/src/format.rs +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/src/lib.rs +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/src/policy.rs +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/src/store.rs +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache/tests/blob_cache_integration.rs +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache-python/Cargo.toml +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache-python/LICENSE +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache-python/README.md +0 -0
- {dex_python_sdk-1.45.17 → dex_python_sdk-1.45.18}/sdk-rust/crates/dex-blob-cache-python/src/lib.rs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dex-python-sdk
|
|
3
|
-
Version: 1.45.
|
|
3
|
+
Version: 1.45.18
|
|
4
4
|
Requires-Dist: grpcio>=1.83.0
|
|
5
5
|
Requires-Dist: grpcio-status>=1.83.0
|
|
6
6
|
Requires-Dist: protobuf>=7.35.1
|
|
@@ -233,31 +233,41 @@ finally:
|
|
|
233
233
|
worker_thread.join()
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
`max_concurrent_tasks
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
Set `min_open_slots`
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
236
|
+
Each slot stream is one long-lived execution slot serving the sticky queue and
|
|
237
|
+
every registered Flow type. Flow type names must be unique within a Dex server.
|
|
238
|
+
By default the Worker is adaptive. `max_concurrent_tasks`, the ceiling,
|
|
239
|
+
defaults to 100. `min_open_slots`, the floor, defaults to
|
|
240
|
+
`min(max_concurrent_tasks, max(reserved_rpc_tasks + 1, CPU count))`. Both count
|
|
241
|
+
the reserved RPC slots. On a machine with at least two CPUs, an idle Worker
|
|
242
|
+
with no options set therefore holds the CPU count of streams and grows up to
|
|
243
|
+
100 under load. It doubles its Step-and-RPC streams when a task takes the last
|
|
244
|
+
idle one and half-closes half of the idle surplus every 30 seconds. A Worker
|
|
245
|
+
that sets only `max_concurrent_tasks` is adaptive too.
|
|
246
|
+
`worker.pull_slot_stream_state()` returns a snapshot of the open, busy, and
|
|
247
|
+
idle streams.
|
|
248
|
+
|
|
249
|
+
Set `min_open_slots` equal to `max_concurrent_tasks` to keep a fixed Worker. A
|
|
250
|
+
fixed Worker opens exactly `max_concurrent_tasks` streams and keeps them open.
|
|
251
|
+
Set `max_concurrent_tasks` to the CPU count to keep the slot count of releases
|
|
252
|
+
before 1.45.18.
|
|
253
|
+
|
|
254
|
+
The Server reports its per-Worker limit, `matching.maxConcurrentTasksCap`, on
|
|
255
|
+
the first registration; zero means no limit. A ceiling above that limit is
|
|
256
|
+
clamped to it with a warning that names both values, and the unset floor and
|
|
257
|
+
RPC reserve are derived again from the clamped ceiling. The exception is an
|
|
258
|
+
explicit `max_concurrent_tasks` of a fixed Worker: start then fails. A fixed
|
|
259
|
+
Worker with `max_concurrent_tasks` unset, or an adaptive Worker with
|
|
260
|
+
`min_open_slots` unset, opens one stream first to learn the limit and opens the
|
|
261
|
+
others after its registration. After a failed check the Worker half-closes its streams, drops any task
|
|
262
|
+
they receive, and never reports readiness; registration waiters raise the limit
|
|
263
|
+
error. When a fixed Worker learns a lower limit on a later reconnect, it logs a
|
|
264
|
+
warning and keeps running.
|
|
257
265
|
|
|
258
266
|
```python
|
|
259
267
|
# Between 8 and 64 slot streams, one of them reserved for RPCs.
|
|
260
268
|
pull = PullWorkerOptions(max_concurrent_tasks=64, min_open_slots=8)
|
|
269
|
+
# Fixed: all 64 slot streams stay open.
|
|
270
|
+
fixed = PullWorkerOptions(max_concurrent_tasks=64, min_open_slots=64)
|
|
261
271
|
```
|
|
262
272
|
`idle_streams_per_queue` is deprecated, remains accepted, and has no effect.
|
|
263
273
|
Each slot executes every task it receives and never rejects a task for capacity.
|
|
@@ -344,14 +354,15 @@ prevents shutdown. The default is False and retries indefinitely. Always call
|
|
|
344
354
|
### Reserved RPC capacity
|
|
345
355
|
|
|
346
356
|
Set `reserved_rpc_tasks` when synchronous RPC latency must stay responsive
|
|
347
|
-
behind long-running Steps. When unset, it reserves one slot if the
|
|
348
|
-
limit
|
|
349
|
-
|
|
357
|
+
behind long-running Steps. When unset, it reserves one slot only if both the
|
|
358
|
+
resolved task limit and floor are at least two; otherwise it reserves zero. For
|
|
359
|
+
example, `max_concurrent_tasks=8` with `min_open_slots=1` reserves zero. Set it
|
|
360
|
+
explicitly to zero to opt out. With one slot and
|
|
350
361
|
no explicit reserve, Worker start logs one warning: RPCs may wait behind
|
|
351
362
|
long-running Steps; use a limit of at least two or set the reserve explicitly.
|
|
352
363
|
Flows must stay responsive because RPCs share Worker task capacity with Steps.
|
|
353
364
|
The value must be nonnegative and less than `max_concurrent_tasks` after its
|
|
354
|
-
|
|
365
|
+
default of 100 is resolved; invalid values fail construction. RPC and Step
|
|
355
366
|
handlers count together. Reserved slots register as `RPC_ONLY`; the remaining
|
|
356
367
|
slots register as `STEP_AND_RPC`. The Server assigns Steps only to the latter.
|
|
357
368
|
The Worker never declines a Step for capacity.
|
|
@@ -407,6 +418,13 @@ The call reads the current run, or the latest run when no run is open, and a
|
|
|
407
418
|
closed run stays readable until Dex purges it. Unlike a read inside an RPC
|
|
408
419
|
handler, it never sees writes that a running Step or RPC has not committed.
|
|
409
420
|
|
|
421
|
+
To work with one exact run of a Flow ID, such as a child run whose run ID the
|
|
422
|
+
caller recorded, pass the keyword argument `run_id` to `describe_flow`,
|
|
423
|
+
`get_attributes`, `wait_for_flow`, `stop_flow`, or `invoke_rpc`. These calls
|
|
424
|
+
address that run even when a newer run exists. A stop with a run ID never
|
|
425
|
+
affects a newer run. A closed run raises `FlowNotActiveOrNotFoundError` to a
|
|
426
|
+
stop, and a missing run raises the call's not-found error. Since 1.45.18.
|
|
427
|
+
|
|
410
428
|
The result `AttributeValues` is keyed by the reads passed to the call, and type
|
|
411
429
|
checkers infer each value type from its key. An unset Attribute or map instance
|
|
412
430
|
is absent: `values[key]` raises `KeyError`, `values.get(key)` returns `None`,
|
|
@@ -215,31 +215,41 @@ finally:
|
|
|
215
215
|
worker_thread.join()
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
`max_concurrent_tasks
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
Set `min_open_slots`
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
218
|
+
Each slot stream is one long-lived execution slot serving the sticky queue and
|
|
219
|
+
every registered Flow type. Flow type names must be unique within a Dex server.
|
|
220
|
+
By default the Worker is adaptive. `max_concurrent_tasks`, the ceiling,
|
|
221
|
+
defaults to 100. `min_open_slots`, the floor, defaults to
|
|
222
|
+
`min(max_concurrent_tasks, max(reserved_rpc_tasks + 1, CPU count))`. Both count
|
|
223
|
+
the reserved RPC slots. On a machine with at least two CPUs, an idle Worker
|
|
224
|
+
with no options set therefore holds the CPU count of streams and grows up to
|
|
225
|
+
100 under load. It doubles its Step-and-RPC streams when a task takes the last
|
|
226
|
+
idle one and half-closes half of the idle surplus every 30 seconds. A Worker
|
|
227
|
+
that sets only `max_concurrent_tasks` is adaptive too.
|
|
228
|
+
`worker.pull_slot_stream_state()` returns a snapshot of the open, busy, and
|
|
229
|
+
idle streams.
|
|
230
|
+
|
|
231
|
+
Set `min_open_slots` equal to `max_concurrent_tasks` to keep a fixed Worker. A
|
|
232
|
+
fixed Worker opens exactly `max_concurrent_tasks` streams and keeps them open.
|
|
233
|
+
Set `max_concurrent_tasks` to the CPU count to keep the slot count of releases
|
|
234
|
+
before 1.45.18.
|
|
235
|
+
|
|
236
|
+
The Server reports its per-Worker limit, `matching.maxConcurrentTasksCap`, on
|
|
237
|
+
the first registration; zero means no limit. A ceiling above that limit is
|
|
238
|
+
clamped to it with a warning that names both values, and the unset floor and
|
|
239
|
+
RPC reserve are derived again from the clamped ceiling. The exception is an
|
|
240
|
+
explicit `max_concurrent_tasks` of a fixed Worker: start then fails. A fixed
|
|
241
|
+
Worker with `max_concurrent_tasks` unset, or an adaptive Worker with
|
|
242
|
+
`min_open_slots` unset, opens one stream first to learn the limit and opens the
|
|
243
|
+
others after its registration. After a failed check the Worker half-closes its streams, drops any task
|
|
244
|
+
they receive, and never reports readiness; registration waiters raise the limit
|
|
245
|
+
error. When a fixed Worker learns a lower limit on a later reconnect, it logs a
|
|
246
|
+
warning and keeps running.
|
|
239
247
|
|
|
240
248
|
```python
|
|
241
249
|
# Between 8 and 64 slot streams, one of them reserved for RPCs.
|
|
242
250
|
pull = PullWorkerOptions(max_concurrent_tasks=64, min_open_slots=8)
|
|
251
|
+
# Fixed: all 64 slot streams stay open.
|
|
252
|
+
fixed = PullWorkerOptions(max_concurrent_tasks=64, min_open_slots=64)
|
|
243
253
|
```
|
|
244
254
|
`idle_streams_per_queue` is deprecated, remains accepted, and has no effect.
|
|
245
255
|
Each slot executes every task it receives and never rejects a task for capacity.
|
|
@@ -326,14 +336,15 @@ prevents shutdown. The default is False and retries indefinitely. Always call
|
|
|
326
336
|
### Reserved RPC capacity
|
|
327
337
|
|
|
328
338
|
Set `reserved_rpc_tasks` when synchronous RPC latency must stay responsive
|
|
329
|
-
behind long-running Steps. When unset, it reserves one slot if the
|
|
330
|
-
limit
|
|
331
|
-
|
|
339
|
+
behind long-running Steps. When unset, it reserves one slot only if both the
|
|
340
|
+
resolved task limit and floor are at least two; otherwise it reserves zero. For
|
|
341
|
+
example, `max_concurrent_tasks=8` with `min_open_slots=1` reserves zero. Set it
|
|
342
|
+
explicitly to zero to opt out. With one slot and
|
|
332
343
|
no explicit reserve, Worker start logs one warning: RPCs may wait behind
|
|
333
344
|
long-running Steps; use a limit of at least two or set the reserve explicitly.
|
|
334
345
|
Flows must stay responsive because RPCs share Worker task capacity with Steps.
|
|
335
346
|
The value must be nonnegative and less than `max_concurrent_tasks` after its
|
|
336
|
-
|
|
347
|
+
default of 100 is resolved; invalid values fail construction. RPC and Step
|
|
337
348
|
handlers count together. Reserved slots register as `RPC_ONLY`; the remaining
|
|
338
349
|
slots register as `STEP_AND_RPC`. The Server assigns Steps only to the latter.
|
|
339
350
|
The Worker never declines a Step for capacity.
|
|
@@ -389,6 +400,13 @@ The call reads the current run, or the latest run when no run is open, and a
|
|
|
389
400
|
closed run stays readable until Dex purges it. Unlike a read inside an RPC
|
|
390
401
|
handler, it never sees writes that a running Step or RPC has not committed.
|
|
391
402
|
|
|
403
|
+
To work with one exact run of a Flow ID, such as a child run whose run ID the
|
|
404
|
+
caller recorded, pass the keyword argument `run_id` to `describe_flow`,
|
|
405
|
+
`get_attributes`, `wait_for_flow`, `stop_flow`, or `invoke_rpc`. These calls
|
|
406
|
+
address that run even when a newer run exists. A stop with a run ID never
|
|
407
|
+
affects a newer run. A closed run raises `FlowNotActiveOrNotFoundError` to a
|
|
408
|
+
stop, and a missing run raises the call's not-found error. Since 1.45.18.
|
|
409
|
+
|
|
392
410
|
The result `AttributeValues` is keyed by the reads passed to the call, and type
|
|
393
411
|
checkers infer each value type from its key. An unset Attribute or map instance
|
|
394
412
|
is absent: `values[key]` raises `KeyError`, `values.get(key)` returns `None`,
|
|
@@ -140,6 +140,8 @@ from dex.runtime_errors import (
|
|
|
140
140
|
GracefulCompletionConditionUnsupportedError,
|
|
141
141
|
InvalidStepResultError,
|
|
142
142
|
LongPollTimeoutError,
|
|
143
|
+
MissingAttributeLockAccess,
|
|
144
|
+
MissingAttributeLockError,
|
|
143
145
|
RequestTimeoutError,
|
|
144
146
|
RpcLockConflictError,
|
|
145
147
|
ValueMappingError,
|
|
@@ -275,6 +277,8 @@ __all__ = [
|
|
|
275
277
|
"JoinRound",
|
|
276
278
|
"JsonCodec",
|
|
277
279
|
"LongPollTimeoutError",
|
|
280
|
+
"MissingAttributeLockAccess",
|
|
281
|
+
"MissingAttributeLockError",
|
|
278
282
|
"RequestTimeoutError",
|
|
279
283
|
"PersistenceSchema",
|
|
280
284
|
"RPCResult",
|
|
@@ -16,6 +16,10 @@ from inspect import isawaitable, isgenerator
|
|
|
16
16
|
from typing import Any, Callable
|
|
17
17
|
|
|
18
18
|
from dex._async_value_hydrator import AsyncValueHydrator
|
|
19
|
+
from dex._attribute_lock_requirement import (
|
|
20
|
+
check_rpc_required_locks,
|
|
21
|
+
check_step_required_locks,
|
|
22
|
+
)
|
|
19
23
|
from dex._invocation_context import InvocationContext, InvocationMethod
|
|
20
24
|
from dex._server_protocol import NegotiatedServerProtocol
|
|
21
25
|
from dex._value_mapper import ValueMapper
|
|
@@ -138,6 +142,7 @@ class AsyncWorkerDispatcher(WorkerDispatcher):
|
|
|
138
142
|
wait = await wait
|
|
139
143
|
if not isinstance(wait, Wait):
|
|
140
144
|
raise TypeError("wait_for must return Wait")
|
|
145
|
+
check_step_required_locks(flow, step, "wait_for", context)
|
|
141
146
|
response = pb.InvokeWaitForMethodResponse(
|
|
142
147
|
upsert_attributes=self._result_attribute_writes(context),
|
|
143
148
|
action_permission_mappings=self._result_action_permission_mappings(
|
|
@@ -248,6 +253,7 @@ class AsyncWorkerDispatcher(WorkerDispatcher):
|
|
|
248
253
|
decision = await decision
|
|
249
254
|
if not isinstance(decision, StepDecision):
|
|
250
255
|
raise TypeError("execute must return StepDecision")
|
|
256
|
+
check_step_required_locks(flow, step, "execute", context)
|
|
251
257
|
response = pb.InvokeExecuteMethodResponse(
|
|
252
258
|
step_decision=self._map_decision(flow, decision),
|
|
253
259
|
upsert_attributes=self._result_attribute_writes(context),
|
|
@@ -390,6 +396,7 @@ class AsyncWorkerDispatcher(WorkerDispatcher):
|
|
|
390
396
|
returned: Any = rpc.method(*arguments)
|
|
391
397
|
if isawaitable(returned):
|
|
392
398
|
returned = await returned
|
|
399
|
+
check_rpc_required_locks(flow, rpc, context)
|
|
393
400
|
try:
|
|
394
401
|
response = pb.InvokeWorkerRPCResponse(
|
|
395
402
|
upsert_attributes=self._result_attribute_writes(context),
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from collections.abc import Collection
|
|
12
|
+
from typing import Literal
|
|
13
|
+
from urllib.parse import unquote
|
|
14
|
+
|
|
15
|
+
from dex._invocation_context import InvocationContext
|
|
16
|
+
from dex.attribute import Attribute, AttributeMap, _required_write_lock_key
|
|
17
|
+
from dex.channel import Channel, ChannelMap
|
|
18
|
+
from dex.flow import _RegisteredFlow, _RegisteredRPC, _RegisteredStep, _StepLockKeys
|
|
19
|
+
from dex.runtime_errors import MissingAttributeLockAccess, MissingAttributeLockError
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def check_step_required_locks(
|
|
23
|
+
flow: _RegisteredFlow,
|
|
24
|
+
step: _RegisteredStep,
|
|
25
|
+
method: Literal["wait_for", "execute"],
|
|
26
|
+
context: InvocationContext,
|
|
27
|
+
) -> None:
|
|
28
|
+
"""Raise MissingAttributeLockError when a Step method lacks a declared lock.
|
|
29
|
+
|
|
30
|
+
Only the Step's registration-time locks count.
|
|
31
|
+
"""
|
|
32
|
+
lock_keys = flow.step_lock_keys.get(step.name, _StepLockKeys())
|
|
33
|
+
held_lock_keys = lock_keys.wait_for if method == "wait_for" else lock_keys.execute
|
|
34
|
+
missing = _missing_lock_accesses(flow, held_lock_keys, context)
|
|
35
|
+
if missing:
|
|
36
|
+
raise MissingAttributeLockError(flow.name, step.name, method, None, missing)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def check_rpc_required_locks(
|
|
40
|
+
flow: _RegisteredFlow,
|
|
41
|
+
rpc: _RegisteredRPC,
|
|
42
|
+
context: InvocationContext,
|
|
43
|
+
) -> None:
|
|
44
|
+
"""Raise MissingAttributeLockError when an RPC lacks a declared lock.
|
|
45
|
+
|
|
46
|
+
Only ``@rpc(lock_attributes=...)`` counts; call-time locks never reach the Worker.
|
|
47
|
+
"""
|
|
48
|
+
missing = _missing_lock_accesses(flow, rpc.locks, context)
|
|
49
|
+
if missing:
|
|
50
|
+
raise MissingAttributeLockError(flow.name, None, "rpc", rpc.name, missing)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _missing_lock_accesses(
|
|
54
|
+
flow: _RegisteredFlow,
|
|
55
|
+
held_lock_keys: Collection[str],
|
|
56
|
+
context: InvocationContext,
|
|
57
|
+
) -> list[MissingAttributeLockAccess]:
|
|
58
|
+
missing: list[MissingAttributeLockAccess] = []
|
|
59
|
+
for physical in context.attribute_writes:
|
|
60
|
+
name, instance = _split_physical_name(physical)
|
|
61
|
+
attribute = flow.persistence.get(name)
|
|
62
|
+
if not isinstance(attribute, (Attribute, AttributeMap)):
|
|
63
|
+
continue
|
|
64
|
+
lock_key = _required_write_lock_key(attribute, physical)
|
|
65
|
+
if lock_key is None or lock_key in held_lock_keys:
|
|
66
|
+
continue
|
|
67
|
+
is_own_lock = attribute.writes_require_lock is True
|
|
68
|
+
missing.append(
|
|
69
|
+
MissingAttributeLockAccess(
|
|
70
|
+
kind=(
|
|
71
|
+
"AttributeMap"
|
|
72
|
+
if isinstance(attribute, AttributeMap)
|
|
73
|
+
else "Attribute"
|
|
74
|
+
),
|
|
75
|
+
name=name,
|
|
76
|
+
instance=instance,
|
|
77
|
+
lock_attribute_name=name if is_own_lock else lock_key,
|
|
78
|
+
lock_instance=instance if is_own_lock else None,
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
published: set[str] = set()
|
|
82
|
+
for publication in context.publications:
|
|
83
|
+
physical = publication.channel_name
|
|
84
|
+
if physical in published:
|
|
85
|
+
continue
|
|
86
|
+
published.add(physical)
|
|
87
|
+
name, instance = _split_physical_name(physical)
|
|
88
|
+
channel = flow.persistence.get(name)
|
|
89
|
+
if not isinstance(channel, (Channel, ChannelMap)):
|
|
90
|
+
continue
|
|
91
|
+
lock_attribute = channel.publishes_require_lock
|
|
92
|
+
if lock_attribute is None or lock_attribute.name in held_lock_keys:
|
|
93
|
+
continue
|
|
94
|
+
missing.append(
|
|
95
|
+
MissingAttributeLockAccess(
|
|
96
|
+
kind="ChannelMap" if isinstance(channel, ChannelMap) else "Channel",
|
|
97
|
+
name=name,
|
|
98
|
+
instance=instance,
|
|
99
|
+
lock_attribute_name=lock_attribute.name,
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
return missing
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _split_physical_name(physical: str) -> tuple[str, str | None]:
|
|
106
|
+
"""Return the definition name and the decoded map instance of a stored key."""
|
|
107
|
+
name, separator, escaped_instance = physical.partition("/")
|
|
108
|
+
if not separator:
|
|
109
|
+
return name, None
|
|
110
|
+
return name, unquote(escaped_instance)
|
|
@@ -46,8 +46,10 @@ class AttributeReadPlan:
|
|
|
46
46
|
def keys(self) -> tuple[str, ...]:
|
|
47
47
|
return tuple(planned.key for planned in self.reads)
|
|
48
48
|
|
|
49
|
-
def request(self) -> pb.GetAttributesRequest:
|
|
50
|
-
return pb.GetAttributesRequest(
|
|
49
|
+
def request(self, run_id: str) -> pb.GetAttributesRequest:
|
|
50
|
+
return pb.GetAttributesRequest(
|
|
51
|
+
flow_id=self.flow_id, run_id=run_id, keys=self.keys
|
|
52
|
+
)
|
|
51
53
|
|
|
52
54
|
def service_error(
|
|
53
55
|
self, error: grpc.RpcError, service_method: str
|
|
@@ -21,7 +21,11 @@ import grpc
|
|
|
21
21
|
|
|
22
22
|
from dex.dexpb import dex_pb2 as pb
|
|
23
23
|
from dex.pull_registration import PullSlotStreamState
|
|
24
|
-
from dex.worker_options import
|
|
24
|
+
from dex.worker_options import (
|
|
25
|
+
_DEFAULT_MAX_CONCURRENT_TASKS,
|
|
26
|
+
PullWorkerOptions,
|
|
27
|
+
_resolve_open_slot_floor_and_reserve,
|
|
28
|
+
)
|
|
25
29
|
|
|
26
30
|
if TYPE_CHECKING:
|
|
27
31
|
from dex._pull_worker import PullStream, PullWorkerRuntime
|
|
@@ -95,15 +99,15 @@ class PullSlotStreams:
|
|
|
95
99
|
self.lock = threading.Lock()
|
|
96
100
|
self.settings = _PullSlotSettings()
|
|
97
101
|
configured_max_concurrent_tasks = (
|
|
98
|
-
options.max_concurrent_tasks or
|
|
102
|
+
options.max_concurrent_tasks or _DEFAULT_MAX_CONCURRENT_TASKS
|
|
99
103
|
)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
# The clamp at the first acknowledgement derives the defaults again with this count.
|
|
105
|
+
self._cpu_count = os.cpu_count() or 1
|
|
106
|
+
min_open_slots, reserved_rpc_tasks = _resolve_open_slot_floor_and_reserve(
|
|
107
|
+
configured_max_concurrent_tasks,
|
|
108
|
+
options.min_open_slots,
|
|
109
|
+
options.reserved_rpc_tasks,
|
|
110
|
+
self._cpu_count,
|
|
107
111
|
)
|
|
108
112
|
self.configured_max_concurrent_tasks = configured_max_concurrent_tasks
|
|
109
113
|
self.max_concurrent_tasks = configured_max_concurrent_tasks
|
|
@@ -226,13 +230,11 @@ class PullSlotStreams:
|
|
|
226
230
|
"is_max_concurrent_tasks_explicit": self.is_max_concurrent_tasks_explicit,
|
|
227
231
|
},
|
|
228
232
|
)
|
|
229
|
-
min_open_slots = (
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
self.
|
|
234
|
-
if self.is_reserved_rpc_tasks_explicit
|
|
235
|
-
else _default_reserved_rpc_tasks(ceiling, min_open_slots)
|
|
233
|
+
min_open_slots, reserved_rpc_tasks = _resolve_open_slot_floor_and_reserve(
|
|
234
|
+
ceiling,
|
|
235
|
+
self.min_open_slots if self.is_min_open_slots_explicit else 0,
|
|
236
|
+
self.reserved_rpc_tasks if self.is_reserved_rpc_tasks_explicit else None,
|
|
237
|
+
self._cpu_count,
|
|
236
238
|
)
|
|
237
239
|
if reserved_rpc_tasks >= ceiling:
|
|
238
240
|
return (
|
|
@@ -904,12 +906,12 @@ class PullSlotStreams:
|
|
|
904
906
|
return newest
|
|
905
907
|
|
|
906
908
|
def _is_cap_probe_pending_locked(self) -> bool:
|
|
907
|
-
#
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
909
|
+
# One stream until the first acknowledgement: F4, or an adaptive Worker whose floor follows the cap.
|
|
910
|
+
if self.has_checked_registration_limit:
|
|
911
|
+
return False
|
|
912
|
+
if self.is_adaptive:
|
|
913
|
+
return not self.is_min_open_slots_explicit
|
|
914
|
+
return not self.is_max_concurrent_tasks_explicit
|
|
913
915
|
|
|
914
916
|
def _step_slot_open_locked(self) -> int:
|
|
915
917
|
# S.
|
|
@@ -25,10 +25,11 @@ _COMPLETE_STOP_TYPES = frozenset({StopType.GRACEFUL_COMPLETE, StopType.FORCE_COM
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
def map_stop_flow_request(
|
|
28
|
-
flow_id: str, options: StopFlowOptions, values: ValueMapper
|
|
28
|
+
flow_id: str, run_id: str, options: StopFlowOptions, values: ValueMapper
|
|
29
29
|
) -> pb.StopFlowRequest:
|
|
30
30
|
request = pb.StopFlowRequest(
|
|
31
31
|
flow_id=require_name(flow_id),
|
|
32
|
+
run_id=run_id,
|
|
32
33
|
reason=options.reason or "",
|
|
33
34
|
stop_type=_STOP_TYPES[options.type],
|
|
34
35
|
)
|
|
@@ -13,6 +13,10 @@ from datetime import datetime, timedelta
|
|
|
13
13
|
from inspect import isawaitable, isgenerator
|
|
14
14
|
from typing import Any, Callable, Generator, cast
|
|
15
15
|
|
|
16
|
+
from dex._attribute_lock_requirement import (
|
|
17
|
+
check_rpc_required_locks,
|
|
18
|
+
check_step_required_locks,
|
|
19
|
+
)
|
|
16
20
|
from dex._invocation_context import InvocationContext, InvocationMethod
|
|
17
21
|
from dex._server_protocol import NegotiatedServerProtocol
|
|
18
22
|
from dex._value_hydrator import ValueHydrator
|
|
@@ -118,6 +122,7 @@ class WorkerDispatcher:
|
|
|
118
122
|
try:
|
|
119
123
|
if not isinstance(wait, Wait):
|
|
120
124
|
raise TypeError("wait_for must return Wait")
|
|
125
|
+
check_step_required_locks(flow, step, "wait_for", context)
|
|
121
126
|
response = pb.InvokeWaitForMethodResponse(
|
|
122
127
|
upsert_attributes=self._result_attribute_writes(context),
|
|
123
128
|
action_permission_mappings=self._result_action_permission_mappings(
|
|
@@ -184,6 +189,7 @@ class WorkerDispatcher:
|
|
|
184
189
|
try:
|
|
185
190
|
if not isinstance(decision, StepDecision):
|
|
186
191
|
raise TypeError("execute must return StepDecision")
|
|
192
|
+
check_step_required_locks(flow, step, "execute", context)
|
|
187
193
|
yield pb.InvokeExecuteMethodOutput(
|
|
188
194
|
result=pb.InvokeExecuteMethodResponse(
|
|
189
195
|
step_decision=self._map_decision(flow, decision),
|
|
@@ -308,6 +314,7 @@ class WorkerDispatcher:
|
|
|
308
314
|
raise TypeError(
|
|
309
315
|
"RPC returned an awaitable; use AsyncWorker for async handlers"
|
|
310
316
|
)
|
|
317
|
+
check_rpc_required_locks(flow, rpc, context)
|
|
311
318
|
try:
|
|
312
319
|
response = pb.InvokeWorkerRPCResponse(
|
|
313
320
|
upsert_attributes=self._result_attribute_writes(context),
|
|
@@ -414,6 +421,25 @@ class WorkerDispatcher:
|
|
|
414
421
|
return None, output.stream_write
|
|
415
422
|
raise TypeError("Step generator must yield StepOutput values")
|
|
416
423
|
|
|
424
|
+
def map_target_step_options(
|
|
425
|
+
self,
|
|
426
|
+
flow: _RegisteredFlow,
|
|
427
|
+
target: _RegisteredStep,
|
|
428
|
+
override: StepOptions | None,
|
|
429
|
+
) -> pb.StepOptions | None:
|
|
430
|
+
"""Map the options sent with a move to ``target``; ``override`` replaces them."""
|
|
431
|
+
if override is not None:
|
|
432
|
+
return self.map_step_options(flow, override)
|
|
433
|
+
snapshot = flow.step_options_snapshot(target)
|
|
434
|
+
if snapshot is None:
|
|
435
|
+
return self.map_step_options(flow, target.step.get_step_options())
|
|
436
|
+
mapped = self.map_step_options(flow, snapshot.options)
|
|
437
|
+
if mapped is None:
|
|
438
|
+
return None
|
|
439
|
+
mapped.wait_for_lock_attribute_keys.extend(snapshot.wait_for_lock_keys)
|
|
440
|
+
mapped.execute_lock_attribute_keys.extend(snapshot.execute_lock_keys)
|
|
441
|
+
return mapped
|
|
442
|
+
|
|
417
443
|
def map_step_options(
|
|
418
444
|
self,
|
|
419
445
|
flow: _RegisteredFlow,
|
|
@@ -467,13 +493,8 @@ class WorkerDispatcher:
|
|
|
467
493
|
pb.EXECUTE_METHOD_FAILURE_POLICY_PROCEED_TO_CONFIGURED_STEP
|
|
468
494
|
)
|
|
469
495
|
mapped.execute_failure_proceed_step_type = target.name
|
|
470
|
-
target_options = self.
|
|
471
|
-
flow,
|
|
472
|
-
(
|
|
473
|
-
options._execute_failure_options
|
|
474
|
-
if options._execute_failure_options is not None
|
|
475
|
-
else target.step.get_step_options()
|
|
476
|
-
),
|
|
496
|
+
target_options = self.map_target_step_options(
|
|
497
|
+
flow, target, options._execute_failure_options
|
|
477
498
|
)
|
|
478
499
|
if target_options is not None:
|
|
479
500
|
mapped.execute_failure_proceed_step_options.CopyFrom(target_options)
|
|
@@ -558,13 +579,8 @@ class WorkerDispatcher:
|
|
|
558
579
|
pb.EXECUTE_METHOD_FAILURE_POLICY_PROCEED_TO_CONFIGURED_STEP
|
|
559
580
|
)
|
|
560
581
|
mapped.failure_proceed_step_type = target.name
|
|
561
|
-
target_options = self.
|
|
562
|
-
flow,
|
|
563
|
-
(
|
|
564
|
-
options._failure_options
|
|
565
|
-
if options._failure_options is not None
|
|
566
|
-
else target.step.get_step_options()
|
|
567
|
-
),
|
|
582
|
+
target_options = self.map_target_step_options(
|
|
583
|
+
flow, target, options._failure_options
|
|
568
584
|
)
|
|
569
585
|
if target_options is not None:
|
|
570
586
|
mapped.failure_proceed_step_options.CopyFrom(target_options)
|
|
@@ -942,14 +958,7 @@ class WorkerDispatcher:
|
|
|
942
958
|
step_type=target.name,
|
|
943
959
|
step_input=self._values.encode(movement.input, target.input_codec),
|
|
944
960
|
)
|
|
945
|
-
options = self.
|
|
946
|
-
flow,
|
|
947
|
-
(
|
|
948
|
-
movement.options
|
|
949
|
-
if movement.options is not None
|
|
950
|
-
else target.step.get_step_options()
|
|
951
|
-
),
|
|
952
|
-
)
|
|
961
|
+
options = self.map_target_step_options(flow, target, movement.options)
|
|
953
962
|
if options is not None:
|
|
954
963
|
mapped.step_options.CopyFrom(options)
|
|
955
964
|
mapped.step_options.skip_wait_for = target.skips_wait_for
|
|
@@ -1096,8 +1105,8 @@ class _ConditionMapper:
|
|
|
1096
1105
|
),
|
|
1097
1106
|
sub_flow_index=len(self.sub_flows),
|
|
1098
1107
|
)
|
|
1099
|
-
step_options = self._dispatcher.
|
|
1100
|
-
target, target.start_step
|
|
1108
|
+
step_options = self._dispatcher.map_target_step_options(
|
|
1109
|
+
target, target.start_step, None
|
|
1101
1110
|
)
|
|
1102
1111
|
if step_options is not None:
|
|
1103
1112
|
mapped_sub_flow.step_options.CopyFrom(step_options)
|