dex-python-sdk 1.45.9__tar.gz → 1.45.17__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.9/README.md → dex_python_sdk-1.45.17/PKG-INFO +40 -0
- dex_python_sdk-1.45.9/PKG-INFO → dex_python_sdk-1.45.17/README.md +21 -17
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/__init__.py +30 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_async_value_hydrator.py +74 -28
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_grpc_errors.py +65 -0
- dex_python_sdk-1.45.17/dex/_payload_message_codec.py +1119 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_pull_worker.py +142 -23
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_value_hydrator.py +78 -28
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_value_mapper.py +14 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/async_client.py +136 -28
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/async_worker.py +12 -2
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/attribute.py +22 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/client.py +137 -28
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/client_options.py +10 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/dexpb/dex_pb2.py +83 -73
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/dexpb/dex_pb2.pyi +37 -0
- dex_python_sdk-1.45.17/dex/payload_encryption.py +1031 -0
- dex_python_sdk-1.45.17/dex/rpc_invoke_options.py +160 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/worker.py +15 -2
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/worker_options.py +11 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/pyproject.toml +8 -1
- dex_python_sdk-1.45.9/dex/rpc_invoke_options.py +0 -42
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/LEGACY_NOTICES.md +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/LICENSE +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_async_worker_dispatcher.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_attribute_reads.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_credential_transport.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_flow_definition_upload.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_flow_service_tls.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_history_point_mapping.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_invocation_context.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_message_size.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_native.pyi +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_pull_slot_streams.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_server_protocol.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_stop_flow_mapping.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_task_queue_names.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_utils.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/_worker_dispatcher.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/action.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/attribute_match.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/attribute_values.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/blob_cache.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/channel.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/codec.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/condition.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/context.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/credential.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/dexpb/__init__.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/dexpb/dex_pb2_grpc.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/flow.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/flow_config.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/flow_definition.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/flow_info.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/flow_options.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/flow_result.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/flow_service_tls_options.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/flow_state.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/graceful_completion_context.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/join.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/pull_registration.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/py.typed +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/runtime_errors.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/step.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/step_execution.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/stream.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/subflow.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/timer.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/wait.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/dex/wait_options.py +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/Cargo.lock +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/Cargo.toml +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/Cargo.toml +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/LICENSE +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/README.md +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/src/config.rs +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/src/entry.rs +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/src/error.rs +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/src/format.rs +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/src/lib.rs +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/src/policy.rs +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/src/store.rs +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache/tests/blob_cache_integration.rs +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache-python/Cargo.toml +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache-python/LICENSE +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache-python/README.md +0 -0
- {dex_python_sdk-1.45.9 → dex_python_sdk-1.45.17}/sdk-rust/crates/dex-blob-cache-python/src/lib.rs +0 -0
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dex-python-sdk
|
|
3
|
+
Version: 1.45.17
|
|
4
|
+
Requires-Dist: grpcio>=1.83.0
|
|
5
|
+
Requires-Dist: grpcio-status>=1.83.0
|
|
6
|
+
Requires-Dist: protobuf>=7.35.1
|
|
7
|
+
Requires-Dist: cryptography>=42.0.0 ; extra == 'encryption'
|
|
8
|
+
Provides-Extra: encryption
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: LEGACY_NOTICES.md
|
|
11
|
+
Summary: Python SDK for the Dex workflow engine
|
|
12
|
+
Author: Super Durable
|
|
13
|
+
License-Expression: LicenseRef-Sustainable-Use-1.0
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
16
|
+
Project-URL: Homepage, https://github.com/superdurable/dex/tree/main/sdk-python
|
|
17
|
+
Project-URL: Repository, https://github.com/superdurable/dex
|
|
18
|
+
|
|
1
19
|
|
|
2
20
|
# Dex SDK for Python
|
|
3
21
|
|
|
@@ -494,6 +512,27 @@ result = client.invoke_rpc(
|
|
|
494
512
|
registered ones. Locking and loading are independent; read-modify-write handlers
|
|
495
513
|
need both for the same instance.
|
|
496
514
|
|
|
515
|
+
`RPCInvokeOptions.request_id` sets a stable request ID for one call. With the
|
|
516
|
+
same request ID on every attempt on the same Flow run, Dex applies the RPC's
|
|
517
|
+
Flow state changes at most once. A repeat of a transactional or locking RPC
|
|
518
|
+
returns the recorded reply without running the handler again. A repeat of any
|
|
519
|
+
other RPC runs the handler again, and returns its new output when that attempt
|
|
520
|
+
changes no Flow state and records no event. Use a transactional or locking RPC,
|
|
521
|
+
for example when an event that is delivered at least once invokes an RPC.
|
|
522
|
+
`None`, the default, sends a new request ID on every call. The field's
|
|
523
|
+
docstring gives the deduplication window and the error that Dex Server 0.1.36
|
|
524
|
+
and earlier raise for a reused ID.
|
|
525
|
+
|
|
526
|
+
```python
|
|
527
|
+
options = dex.RPCInvokeOptions(request_id=f"{event.id}/increment_counter")
|
|
528
|
+
total = client.invoke_rpc(
|
|
529
|
+
counters.increment_counter,
|
|
530
|
+
event.flow_id,
|
|
531
|
+
event.delta,
|
|
532
|
+
options=options,
|
|
533
|
+
)
|
|
534
|
+
```
|
|
535
|
+
|
|
497
536
|
See the runnable [sequential chunking](../examples/python/dex_examples/patterns/sequentially-chunked-attribute-map)
|
|
498
537
|
and [hash partitioning](../examples/python/dex_examples/patterns/hash-partitioned-attribute-map)
|
|
499
538
|
patterns for complete async call sites.
|
|
@@ -1187,3 +1226,4 @@ original terms as described in [LEGACY_NOTICES.md](LEGACY_NOTICES.md).
|
|
|
1187
1226
|
|
|
1188
1227
|
Searches return runs that match the query. Include `FlowType` when using shared
|
|
1189
1228
|
index slots, and keep the query and page size consistent across pages.
|
|
1229
|
+
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: dex-python-sdk
|
|
3
|
-
Version: 1.45.9
|
|
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
|
|
|
@@ -510,6 +494,27 @@ result = client.invoke_rpc(
|
|
|
510
494
|
registered ones. Locking and loading are independent; read-modify-write handlers
|
|
511
495
|
need both for the same instance.
|
|
512
496
|
|
|
497
|
+
`RPCInvokeOptions.request_id` sets a stable request ID for one call. With the
|
|
498
|
+
same request ID on every attempt on the same Flow run, Dex applies the RPC's
|
|
499
|
+
Flow state changes at most once. A repeat of a transactional or locking RPC
|
|
500
|
+
returns the recorded reply without running the handler again. A repeat of any
|
|
501
|
+
other RPC runs the handler again, and returns its new output when that attempt
|
|
502
|
+
changes no Flow state and records no event. Use a transactional or locking RPC,
|
|
503
|
+
for example when an event that is delivered at least once invokes an RPC.
|
|
504
|
+
`None`, the default, sends a new request ID on every call. The field's
|
|
505
|
+
docstring gives the deduplication window and the error that Dex Server 0.1.36
|
|
506
|
+
and earlier raise for a reused ID.
|
|
507
|
+
|
|
508
|
+
```python
|
|
509
|
+
options = dex.RPCInvokeOptions(request_id=f"{event.id}/increment_counter")
|
|
510
|
+
total = client.invoke_rpc(
|
|
511
|
+
counters.increment_counter,
|
|
512
|
+
event.flow_id,
|
|
513
|
+
event.delta,
|
|
514
|
+
options=options,
|
|
515
|
+
)
|
|
516
|
+
```
|
|
517
|
+
|
|
513
518
|
See the runnable [sequential chunking](../examples/python/dex_examples/patterns/sequentially-chunked-attribute-map)
|
|
514
519
|
and [hash partitioning](../examples/python/dex_examples/patterns/hash-partitioned-attribute-map)
|
|
515
520
|
patterns for complete async call sites.
|
|
@@ -1203,4 +1208,3 @@ original terms as described in [LEGACY_NOTICES.md](LEGACY_NOTICES.md).
|
|
|
1203
1208
|
|
|
1204
1209
|
Searches return runs that match the query. Include `FlowType` when using shared
|
|
1205
1210
|
index slots, and keep the query and page size consistent across pages.
|
|
1206
|
-
|
|
@@ -100,6 +100,22 @@ from dex.flow_options import (
|
|
|
100
100
|
from dex.join import Join, JoinRound
|
|
101
101
|
from dex.flow_service_tls_options import FlowServiceTlsOptions
|
|
102
102
|
from dex.flow_result import FlowResult, StepCompletion
|
|
103
|
+
from dex.payload_encryption import (
|
|
104
|
+
DEFAULT_MAX_PAYLOAD_ENVELOPE_BYTES,
|
|
105
|
+
DEFAULT_MAX_PAYLOAD_PLAINTEXT_BYTES,
|
|
106
|
+
AesGcmPayloadCodec,
|
|
107
|
+
AsyncPayloadCodec,
|
|
108
|
+
FilePayloadEncryptionKeyProvider,
|
|
109
|
+
PayloadCodec,
|
|
110
|
+
PayloadCompression,
|
|
111
|
+
PayloadContext,
|
|
112
|
+
PayloadEncryptionError,
|
|
113
|
+
PayloadEncryptionKeyProvider,
|
|
114
|
+
PayloadEncryptionOptions,
|
|
115
|
+
PayloadErrorCategory,
|
|
116
|
+
is_valid_payload_key_id,
|
|
117
|
+
payload_envelope_aad,
|
|
118
|
+
)
|
|
103
119
|
from dex.pull_registration import (
|
|
104
120
|
PullQueueRegistrationState,
|
|
105
121
|
PullRegistrationError,
|
|
@@ -166,6 +182,20 @@ from dex.worker import Worker
|
|
|
166
182
|
from dex.worker_options import PullWorkerOptions, WorkerOptions
|
|
167
183
|
|
|
168
184
|
__all__ = [
|
|
185
|
+
"DEFAULT_MAX_PAYLOAD_ENVELOPE_BYTES",
|
|
186
|
+
"DEFAULT_MAX_PAYLOAD_PLAINTEXT_BYTES",
|
|
187
|
+
"AesGcmPayloadCodec",
|
|
188
|
+
"AsyncPayloadCodec",
|
|
189
|
+
"FilePayloadEncryptionKeyProvider",
|
|
190
|
+
"PayloadCodec",
|
|
191
|
+
"PayloadCompression",
|
|
192
|
+
"PayloadContext",
|
|
193
|
+
"PayloadEncryptionError",
|
|
194
|
+
"PayloadEncryptionKeyProvider",
|
|
195
|
+
"PayloadEncryptionOptions",
|
|
196
|
+
"PayloadErrorCategory",
|
|
197
|
+
"is_valid_payload_key_id",
|
|
198
|
+
"payload_envelope_aad",
|
|
169
199
|
"Action",
|
|
170
200
|
"ActionCondition",
|
|
171
201
|
"WORK_QUEUE_PERMISSIONS_INDEX_KEY",
|
|
@@ -15,7 +15,17 @@ from typing import cast
|
|
|
15
15
|
import grpc
|
|
16
16
|
|
|
17
17
|
from dex._message_size import is_grpc_message_size_error
|
|
18
|
-
from dex.
|
|
18
|
+
from dex._payload_message_codec import (
|
|
19
|
+
RESERVED_ENCODING_PREFIX,
|
|
20
|
+
AsyncPayloadMessageCodec,
|
|
21
|
+
PayloadScope,
|
|
22
|
+
)
|
|
23
|
+
from dex._value_hydrator import (
|
|
24
|
+
_MAX_LOAD_BLOBS_ENTRIES,
|
|
25
|
+
BlobHydrationError,
|
|
26
|
+
worker_request_payload_scope,
|
|
27
|
+
)
|
|
28
|
+
from dex.payload_encryption import PayloadContext
|
|
19
29
|
from dex.blob_cache import BlobCache
|
|
20
30
|
from dex.dexpb import dex_pb2 as pb
|
|
21
31
|
from dex.dexpb import dex_pb2_grpc
|
|
@@ -39,17 +49,56 @@ class AsyncValueHydrator:
|
|
|
39
49
|
self,
|
|
40
50
|
service: dex_pb2_grpc.FlowServiceStub,
|
|
41
51
|
cache: BlobCache,
|
|
52
|
+
payloads: AsyncPayloadMessageCodec | None = None,
|
|
42
53
|
) -> None:
|
|
43
54
|
self._service = service
|
|
44
55
|
self._cache = cache
|
|
56
|
+
self._payloads = payloads or AsyncPayloadMessageCodec(None)
|
|
45
57
|
|
|
46
|
-
async def hydrate(
|
|
47
|
-
|
|
58
|
+
async def hydrate(
|
|
59
|
+
self,
|
|
60
|
+
flow_id: str,
|
|
61
|
+
value: pb.Value,
|
|
62
|
+
payload_context: PayloadContext | None = None,
|
|
63
|
+
) -> pb.Value:
|
|
64
|
+
return (await self.hydrate_all(flow_id, [value], payload_context))[0]
|
|
48
65
|
|
|
49
66
|
async def hydrate_all(
|
|
50
67
|
self,
|
|
51
68
|
flow_id: str,
|
|
52
69
|
values: list[pb.Value],
|
|
70
|
+
payload_context: PayloadContext | None = None,
|
|
71
|
+
) -> list[pb.Value]:
|
|
72
|
+
"""Load blobs, then decrypt envelopes; the blob cache keeps ciphertext.
|
|
73
|
+
|
|
74
|
+
``payload_context`` defaults to ``flow_id`` with an unknown Flow type.
|
|
75
|
+
"""
|
|
76
|
+
hydrated = await self._hydrate_blobs(flow_id, values)
|
|
77
|
+
decoded = await self._payloads.decode_values(
|
|
78
|
+
hydrated, payload_context or PayloadContext("", flow_id)
|
|
79
|
+
)
|
|
80
|
+
for value in decoded:
|
|
81
|
+
self._validate_concrete(value)
|
|
82
|
+
return decoded
|
|
83
|
+
|
|
84
|
+
async def flow_result(
|
|
85
|
+
self,
|
|
86
|
+
flow_id: str,
|
|
87
|
+
result: pb.FlowResult,
|
|
88
|
+
payload_context: PayloadContext,
|
|
89
|
+
) -> pb.FlowResult:
|
|
90
|
+
values = [output.completed_step_output for output in result.results]
|
|
91
|
+
hydrated = await self._hydrate_blobs(flow_id, values)
|
|
92
|
+
mapped = pb.FlowResult()
|
|
93
|
+
mapped.CopyFrom(result)
|
|
94
|
+
for output, value in zip(mapped.results, hydrated):
|
|
95
|
+
output.completed_step_output.CopyFrom(value)
|
|
96
|
+
return await self._payloads.decode_message(
|
|
97
|
+
mapped, PayloadScope(payload_context)
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
async def _hydrate_blobs(
|
|
101
|
+
self, flow_id: str, values: list[pb.Value]
|
|
53
102
|
) -> list[pb.Value]:
|
|
54
103
|
return await self.hydrate_all_for_flows([(flow_id, value) for value in values])
|
|
55
104
|
|
|
@@ -85,7 +134,7 @@ class AsyncValueHydrator:
|
|
|
85
134
|
|
|
86
135
|
for blob in pending.values():
|
|
87
136
|
if blob.hydrated is None:
|
|
88
|
-
raise
|
|
137
|
+
raise BlobHydrationError(f"blob was not hydrated: {blob.blob_id}")
|
|
89
138
|
for index in blob.indexes:
|
|
90
139
|
hydrated[index] = blob.hydrated
|
|
91
140
|
return hydrated
|
|
@@ -107,7 +156,7 @@ class AsyncValueHydrator:
|
|
|
107
156
|
for message in channel_values.messages
|
|
108
157
|
]
|
|
109
158
|
values.extend(message.value for message in channel_messages)
|
|
110
|
-
hydrated = iter(await self.
|
|
159
|
+
hydrated = iter(await self._hydrate_blobs(request.context.flow_id, values))
|
|
111
160
|
result.step_input.CopyFrom(next(hydrated))
|
|
112
161
|
if has_heartbeat:
|
|
113
162
|
result.context.last_heartbeat_value.CopyFrom(next(hydrated))
|
|
@@ -120,7 +169,9 @@ class AsyncValueHydrator:
|
|
|
120
169
|
]
|
|
121
170
|
for message in result_messages:
|
|
122
171
|
message.value.CopyFrom(next(hydrated))
|
|
123
|
-
return
|
|
172
|
+
return await self._payloads.decode_message(
|
|
173
|
+
result, worker_request_payload_scope(request.flow_type, request.context)
|
|
174
|
+
)
|
|
124
175
|
|
|
125
176
|
async def execute_request(
|
|
126
177
|
self,
|
|
@@ -147,7 +198,7 @@ class AsyncValueHydrator:
|
|
|
147
198
|
values.extend(
|
|
148
199
|
completion.completed_step_output for completion in flow_result.results
|
|
149
200
|
)
|
|
150
|
-
hydrated = iter(await self.
|
|
201
|
+
hydrated = iter(await self._hydrate_blobs(request.context.flow_id, values))
|
|
151
202
|
if has_step_input:
|
|
152
203
|
result.step_input.CopyFrom(next(hydrated))
|
|
153
204
|
if has_heartbeat:
|
|
@@ -169,7 +220,9 @@ class AsyncValueHydrator:
|
|
|
169
220
|
for flow_result in result.condition_results.sub_flow_results:
|
|
170
221
|
for completion in flow_result.results:
|
|
171
222
|
completion.completed_step_output.CopyFrom(next(hydrated))
|
|
172
|
-
return
|
|
223
|
+
return await self._payloads.decode_message(
|
|
224
|
+
result, worker_request_payload_scope(request.flow_type, request.context)
|
|
225
|
+
)
|
|
173
226
|
|
|
174
227
|
async def rpc_request(
|
|
175
228
|
self,
|
|
@@ -187,7 +240,9 @@ class AsyncValueHydrator:
|
|
|
187
240
|
for message in channel_values.messages
|
|
188
241
|
]
|
|
189
242
|
values.extend(message.value for message in channel_messages)
|
|
190
|
-
hydrated_entries = iter(
|
|
243
|
+
hydrated_entries = iter(
|
|
244
|
+
await self._hydrate_blobs(request.context.flow_id, values)
|
|
245
|
+
)
|
|
191
246
|
if has_input:
|
|
192
247
|
result.input.CopyFrom(next(hydrated_entries))
|
|
193
248
|
for entry in result.attributes:
|
|
@@ -199,22 +254,9 @@ class AsyncValueHydrator:
|
|
|
199
254
|
]
|
|
200
255
|
for message in result_messages:
|
|
201
256
|
message.value.CopyFrom(next(hydrated_entries))
|
|
202
|
-
return
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
self,
|
|
206
|
-
flow_id: str,
|
|
207
|
-
outputs: list[pb.StepCompletionOutput],
|
|
208
|
-
) -> list[pb.StepCompletionOutput]:
|
|
209
|
-
values = [output.completed_step_output for output in outputs]
|
|
210
|
-
hydrated = await self.hydrate_all(flow_id, values)
|
|
211
|
-
results: list[pb.StepCompletionOutput] = []
|
|
212
|
-
for output, value in zip(outputs, hydrated):
|
|
213
|
-
result = pb.StepCompletionOutput()
|
|
214
|
-
result.CopyFrom(output)
|
|
215
|
-
result.completed_step_output.CopyFrom(value)
|
|
216
|
-
results.append(result)
|
|
217
|
-
return results
|
|
257
|
+
return await self._payloads.decode_message(
|
|
258
|
+
result, worker_request_payload_scope(request.flow_type, request.context)
|
|
259
|
+
)
|
|
218
260
|
|
|
219
261
|
async def _load_misses(self, misses: list[_PendingBlob]) -> None:
|
|
220
262
|
if not misses:
|
|
@@ -223,7 +265,7 @@ class AsyncValueHydrator:
|
|
|
223
265
|
for miss in misses:
|
|
224
266
|
concrete = values.get(miss.blob_id)
|
|
225
267
|
if concrete is None:
|
|
226
|
-
raise
|
|
268
|
+
raise BlobHydrationError(f"LoadBlobs omitted blob {miss.blob_id}")
|
|
227
269
|
self._validate_hydrated(miss, concrete)
|
|
228
270
|
miss.hydrated = concrete
|
|
229
271
|
self._write_cache(miss, concrete)
|
|
@@ -325,7 +367,7 @@ class AsyncValueHydrator:
|
|
|
325
367
|
def _validate_hydrated(blob: _PendingBlob, value: pb.Value) -> None:
|
|
326
368
|
expected = "obj_value" if blob.is_object else "string_value"
|
|
327
369
|
if value.WhichOneof("kind") != expected:
|
|
328
|
-
raise
|
|
370
|
+
raise BlobHydrationError(
|
|
329
371
|
f"blob {blob.blob_id} hydrated to {value.WhichOneof('kind')}"
|
|
330
372
|
)
|
|
331
373
|
AsyncValueHydrator._validate_concrete(value)
|
|
@@ -342,7 +384,11 @@ class AsyncValueHydrator:
|
|
|
342
384
|
raise ValueError("non-finite numbers are unsupported")
|
|
343
385
|
return
|
|
344
386
|
if kind == "obj_value":
|
|
345
|
-
|
|
387
|
+
encoding = value.obj_value.encoding
|
|
388
|
+
# Envelopes pass through so the payload codec can decrypt them.
|
|
389
|
+
if encoding not in ("json", "raw") and not encoding.startswith(
|
|
390
|
+
RESERVED_ENCODING_PREFIX
|
|
391
|
+
):
|
|
346
392
|
raise ValueError(
|
|
347
393
|
f"unsupported object encoding {value.obj_value.encoding}"
|
|
348
394
|
)
|
|
@@ -89,11 +89,46 @@ def retry_after(after_seconds: int, cause: BaseException) -> RetryAfterError:
|
|
|
89
89
|
return RetryAfterError(after_seconds=after_seconds, cause=cause)
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
_HAS_DEX_ERROR_DETAILS = "_has_dex_error_details"
|
|
93
|
+
|
|
94
|
+
|
|
92
95
|
def translate_rpc_error(
|
|
93
96
|
error: grpc.RpcError,
|
|
94
97
|
operation: str,
|
|
95
98
|
flow_id: str | None,
|
|
96
99
|
requirement: FlowTargetRequirement,
|
|
100
|
+
) -> DexServiceError:
|
|
101
|
+
translated = _translate_rpc_error(error, operation, flow_id, requirement)
|
|
102
|
+
if _service_error_response(error) is not None:
|
|
103
|
+
setattr(translated, _HAS_DEX_ERROR_DETAILS, True)
|
|
104
|
+
return translated
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def has_dex_error_details(error: DexServiceError) -> bool:
|
|
108
|
+
"""Return whether the status carried Dex details; only then is its text a read point."""
|
|
109
|
+
return getattr(error, _HAS_DEX_ERROR_DETAILS, False) is True
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _service_error_response(error: grpc.RpcError) -> pb.ServiceErrorResponse | None:
|
|
113
|
+
try:
|
|
114
|
+
status = rpc_status.from_call(cast(grpc.Call, error))
|
|
115
|
+
if status is None:
|
|
116
|
+
return None
|
|
117
|
+
for packed in status.details:
|
|
118
|
+
candidate = pb.ServiceErrorResponse()
|
|
119
|
+
if packed.Is(candidate.DESCRIPTOR):
|
|
120
|
+
packed.Unpack(candidate)
|
|
121
|
+
return candidate
|
|
122
|
+
except Exception:
|
|
123
|
+
return None
|
|
124
|
+
return None
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _translate_rpc_error(
|
|
128
|
+
error: grpc.RpcError,
|
|
129
|
+
operation: str,
|
|
130
|
+
flow_id: str | None,
|
|
131
|
+
requirement: FlowTargetRequirement,
|
|
97
132
|
) -> DexServiceError:
|
|
98
133
|
details: pb.ServiceErrorResponse | None = None
|
|
99
134
|
try:
|
|
@@ -152,6 +187,36 @@ def translate_rpc_error(
|
|
|
152
187
|
return DexServiceError(*parameters)
|
|
153
188
|
|
|
154
189
|
|
|
190
|
+
def service_error_texts(error: DexServiceError) -> tuple[str, str]:
|
|
191
|
+
"""Return the service detail and the Worker detail, which may be encrypted."""
|
|
192
|
+
worker_detail = (
|
|
193
|
+
error.worker_error_detail if isinstance(error, WorkerInvocationError) else ""
|
|
194
|
+
)
|
|
195
|
+
return error.detail, worker_detail
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def with_service_error_texts(
|
|
199
|
+
error: DexServiceError, detail: str, worker_detail: str
|
|
200
|
+
) -> DexServiceError:
|
|
201
|
+
"""Return ``error`` rebuilt with decrypted texts, or ``error`` when unchanged."""
|
|
202
|
+
if (detail, worker_detail) == service_error_texts(error):
|
|
203
|
+
return error
|
|
204
|
+
if isinstance(error, WorkerInvocationError):
|
|
205
|
+
return WorkerInvocationError(
|
|
206
|
+
error.code,
|
|
207
|
+
error.sub_status,
|
|
208
|
+
detail,
|
|
209
|
+
error.operation,
|
|
210
|
+
error.flow_id,
|
|
211
|
+
error.worker_code,
|
|
212
|
+
error.worker_error_type,
|
|
213
|
+
worker_detail,
|
|
214
|
+
)
|
|
215
|
+
return type(error)(
|
|
216
|
+
error.code, error.sub_status, detail, error.operation, error.flow_id
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
155
220
|
def translate_clone_fork_flow_error(
|
|
156
221
|
error: grpc.RpcError, source_flow_id: str, flow_id: str
|
|
157
222
|
) -> DexServiceError:
|