dex-python-sdk 1.45.1__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.1 → dex_python_sdk-1.45.2}/PKG-INFO +1 -1
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/__init__.py +18 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/async_client.py +68 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/client.py +68 -0
- dex_python_sdk-1.45.2/dex/flow_state.py +322 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/pyproject.toml +1 -1
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/LEGACY_NOTICES.md +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/LICENSE +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/README.md +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_async_value_hydrator.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_async_worker_dispatcher.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_attribute_reads.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_credential_transport.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_flow_definition_upload.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_flow_service_tls.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_grpc_errors.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_invocation_context.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_message_size.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_native.pyi +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_pull_worker.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_server_protocol.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_task_queue_names.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_utils.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_value_hydrator.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_value_mapper.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/_worker_dispatcher.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/action.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/async_worker.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/attribute.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/attribute_match.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/attribute_values.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/blob_cache.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/channel.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/client_options.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/codec.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/condition.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/context.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/credential.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/dexpb/__init__.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/dexpb/dex_pb2.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/dexpb/dex_pb2.pyi +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/dexpb/dex_pb2_grpc.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/flow.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/flow_config.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/flow_definition.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/flow_info.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/flow_options.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/flow_result.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/flow_service_tls_options.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/join.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/pull_registration.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/py.typed +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/rpc_invoke_options.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/runtime_errors.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/step.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/step_execution.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/stream.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/subflow.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/timer.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/wait.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/wait_options.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/worker.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/dex/worker_options.py +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/Cargo.lock +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/Cargo.toml +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/Cargo.toml +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/LICENSE +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/README.md +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/config.rs +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/entry.rs +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/error.rs +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/format.rs +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/lib.rs +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/policy.rs +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/store.rs +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/tests/blob_cache_integration.rs +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/Cargo.toml +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/LICENSE +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/README.md +0 -0
- {dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/src/lib.rs +0 -0
|
@@ -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",
|
|
@@ -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,
|
|
@@ -734,6 +735,73 @@ class AsyncClient:
|
|
|
734
735
|
response.start_time.ToDatetime(tzinfo=timezone.utc),
|
|
735
736
|
)
|
|
736
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
|
+
|
|
737
805
|
async def get_attributes(
|
|
738
806
|
self,
|
|
739
807
|
flow_id: str,
|
|
@@ -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,
|
|
@@ -749,6 +750,73 @@ class Client:
|
|
|
749
750
|
response.start_time.ToDatetime(tzinfo=timezone.utc),
|
|
750
751
|
)
|
|
751
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
|
+
|
|
752
820
|
def get_attributes(
|
|
753
821
|
self,
|
|
754
822
|
flow_id: str,
|
|
@@ -0,0 +1,322 @@
|
|
|
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 Sequence
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from datetime import datetime, timezone
|
|
14
|
+
from enum import Enum
|
|
15
|
+
|
|
16
|
+
from dex.dexpb import dex_pb2 as pb
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ActiveStepExecutionPhase(Enum):
|
|
20
|
+
"""Tell where an open Step execution stands.
|
|
21
|
+
|
|
22
|
+
.. versionadded:: 1.45.2
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
ACTIVE: The WaitFor or Execute method is pending, running, or waiting to
|
|
26
|
+
retry. Read ``ActiveStepExecution.invocation`` for details.
|
|
27
|
+
WAITING: WaitFor completed and the Step execution waits for its
|
|
28
|
+
conditions. No Step method call is open.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
ACTIVE = "active"
|
|
32
|
+
WAITING = "waiting"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class StepMethodName(Enum):
|
|
36
|
+
"""Name the Step method that an open Step method call runs.
|
|
37
|
+
|
|
38
|
+
.. versionadded:: 1.45.2
|
|
39
|
+
|
|
40
|
+
Attributes:
|
|
41
|
+
WAIT_FOR: The Step's ``wait_for`` method.
|
|
42
|
+
EXECUTE: The Step's ``execute`` method.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
WAIT_FOR = "wait_for"
|
|
46
|
+
EXECUTE = "execute"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class StepMethodInvocationPhase(Enum):
|
|
50
|
+
"""Tell where the current attempt of an open Step method call stands.
|
|
51
|
+
|
|
52
|
+
.. versionadded:: 1.45.2
|
|
53
|
+
|
|
54
|
+
Attributes:
|
|
55
|
+
PENDING: The attempt waits for its locks or for a Worker. Read
|
|
56
|
+
``StepMethodInvocation.pending_reason``.
|
|
57
|
+
RUNNING: A Worker received the attempt.
|
|
58
|
+
BACKOFF: The last attempt failed, and the next attempt waits for its
|
|
59
|
+
retry backoff.
|
|
60
|
+
UNSPECIFIED: The server reported no phase.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
PENDING = "pending"
|
|
64
|
+
RUNNING = "running"
|
|
65
|
+
BACKOFF = "backoff"
|
|
66
|
+
UNSPECIFIED = "unspecified"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class StepMethodPendingReason(Enum):
|
|
70
|
+
"""Tell why a pending Step method attempt has not reached a Worker yet.
|
|
71
|
+
|
|
72
|
+
.. versionadded:: 1.45.2
|
|
73
|
+
|
|
74
|
+
Attributes:
|
|
75
|
+
WAITING_FOR_WORKER: The attempt waits for a Worker of its Flow type.
|
|
76
|
+
WAITING_FOR_SUPPORTING_WORKER: Workers of the Flow type are connected,
|
|
77
|
+
but each one declined the Step type.
|
|
78
|
+
WAITING_FOR_LOCKS: Another Step or a transactional RPC holds one of the
|
|
79
|
+
attempt's locks, or an earlier Step waits for one of them.
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
WAITING_FOR_WORKER = "waiting_for_worker"
|
|
83
|
+
WAITING_FOR_SUPPORTING_WORKER = "waiting_for_supporting_worker"
|
|
84
|
+
WAITING_FOR_LOCKS = "waiting_for_locks"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@dataclass(frozen=True)
|
|
88
|
+
class StepMethodInvocation:
|
|
89
|
+
"""Describe the open WaitFor or Execute method call of an open Step execution.
|
|
90
|
+
|
|
91
|
+
.. versionadded:: 1.45.2
|
|
92
|
+
|
|
93
|
+
Attributes:
|
|
94
|
+
method: The Step method that this call runs.
|
|
95
|
+
phase: Where the current attempt stands.
|
|
96
|
+
attempt: The 1-based pending or running attempt. In the ``BACKOFF``
|
|
97
|
+
phase it is the next attempt, so it is one more than
|
|
98
|
+
``StepMethodFailureInfo.attempt``.
|
|
99
|
+
pending_reason: Why a ``PENDING`` attempt waits, or ``None`` in other
|
|
100
|
+
phases.
|
|
101
|
+
pending_since: When the current attempt became pending, as a
|
|
102
|
+
timezone-aware UTC datetime, or ``None`` in the ``BACKOFF`` phase.
|
|
103
|
+
attempt_started_at: When a Worker received the ``RUNNING`` attempt, as
|
|
104
|
+
a timezone-aware UTC datetime, or ``None`` in other phases.
|
|
105
|
+
backoff_fires_at: When the ``BACKOFF`` phase ends and the next attempt
|
|
106
|
+
becomes pending, as a timezone-aware UTC datetime, or ``None`` in
|
|
107
|
+
other phases.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
method: StepMethodName
|
|
111
|
+
phase: StepMethodInvocationPhase
|
|
112
|
+
attempt: int
|
|
113
|
+
pending_reason: StepMethodPendingReason | None
|
|
114
|
+
pending_since: datetime | None
|
|
115
|
+
attempt_started_at: datetime | None
|
|
116
|
+
backoff_fires_at: datetime | None
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@dataclass(frozen=True)
|
|
120
|
+
class StepMethodFailureInfo:
|
|
121
|
+
"""Describe the latest failed attempt of an open Step method call.
|
|
122
|
+
|
|
123
|
+
Dex keeps only the latest failure. It does not report when that attempt
|
|
124
|
+
failed. Read ``StepMethodInvocation.backoff_fires_at`` for when the next
|
|
125
|
+
attempt starts.
|
|
126
|
+
|
|
127
|
+
.. versionadded:: 1.45.2
|
|
128
|
+
|
|
129
|
+
Attributes:
|
|
130
|
+
attempt: The 1-based attempt that failed.
|
|
131
|
+
error_type: The error type the Worker reported. A Python Worker reports
|
|
132
|
+
the raised exception's module and qualified class name, such as
|
|
133
|
+
``billing.ChargeDeclinedError``. It is empty when Dex failed the attempt
|
|
134
|
+
itself, for example when no Worker was available.
|
|
135
|
+
detail: The failure message. It is the Worker's error message, or the
|
|
136
|
+
server's description when the Worker reported none.
|
|
137
|
+
stack_trace: The Worker-language stack trace, or ``""`` when the Worker
|
|
138
|
+
sent none.
|
|
139
|
+
backend_error: The Dex failure category, such as
|
|
140
|
+
``FLOW_ERROR_TYPE_WORKER_API_FAIL``. Use it only for logs. Its
|
|
141
|
+
spellings can differ between server versions.
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
attempt: int
|
|
145
|
+
error_type: str
|
|
146
|
+
detail: str
|
|
147
|
+
stack_trace: str
|
|
148
|
+
backend_error: str
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
@dataclass(frozen=True)
|
|
152
|
+
class ActiveStepExecution:
|
|
153
|
+
"""Describe one open Step execution in a ``FlowState``.
|
|
154
|
+
|
|
155
|
+
.. versionadded:: 1.45.2
|
|
156
|
+
|
|
157
|
+
Attributes:
|
|
158
|
+
step_execution_id: The Step execution ID, such as ``ChargeStep-1``. It
|
|
159
|
+
equals ``Context.step_execution_id`` inside the Step's handlers.
|
|
160
|
+
step_type: The registered Step type.
|
|
161
|
+
execution_number: The positive execution number of the Step type in this
|
|
162
|
+
run. Pass ``StepExecutionId(step_type, execution_number)`` to
|
|
163
|
+
``Client.wait_for_step_completion`` or ``Client.skip_timer`` to
|
|
164
|
+
address this Step execution.
|
|
165
|
+
phase: Whether a Step method call is open or the Step waits for its
|
|
166
|
+
conditions.
|
|
167
|
+
invocation: The open WaitFor or Execute method call, or ``None`` when
|
|
168
|
+
no call is open. No call is open in the ``WAITING`` phase.
|
|
169
|
+
last_failure: The latest failed attempt of the open Step method call,
|
|
170
|
+
or ``None`` when none failed. A value here while
|
|
171
|
+
``StepMethodInvocation.phase`` is ``BACKOFF``, or while a later
|
|
172
|
+
attempt is pending or running, means that the Step is retrying
|
|
173
|
+
after a failure.
|
|
174
|
+
"""
|
|
175
|
+
|
|
176
|
+
step_execution_id: str
|
|
177
|
+
step_type: str
|
|
178
|
+
execution_number: int
|
|
179
|
+
phase: ActiveStepExecutionPhase
|
|
180
|
+
invocation: StepMethodInvocation | None
|
|
181
|
+
last_failure: StepMethodFailureInfo | None
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@dataclass(frozen=True)
|
|
185
|
+
class FlowState:
|
|
186
|
+
"""Describe the live Step state and task queue of the current or latest run.
|
|
187
|
+
|
|
188
|
+
``Client.get_flow_state`` and ``AsyncClient.get_flow_state`` return it. Read
|
|
189
|
+
it to see which Step executions are open, whether one of them is retrying
|
|
190
|
+
after a failed attempt, and which task queue runs the Flow. See
|
|
191
|
+
``Client.get_flow_state`` for an example.
|
|
192
|
+
|
|
193
|
+
.. versionadded:: 1.45.2
|
|
194
|
+
|
|
195
|
+
Attributes:
|
|
196
|
+
active_step_executions: The open Step executions of the run, in server
|
|
197
|
+
order. It is empty when the run is closed or has no open Step
|
|
198
|
+
execution.
|
|
199
|
+
task_queue: The task queue whose Workers run this Flow's Steps and
|
|
200
|
+
RPCs. ``""`` means the default task queue. Dex fixes the task queue
|
|
201
|
+
when the Flow starts, so it does not change during a run. Read it
|
|
202
|
+
from a Client without a Worker to see which Workers must serve the
|
|
203
|
+
Flow. See ``StartFlowOptions.task_queue``.
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
active_step_executions: Sequence[ActiveStepExecution]
|
|
207
|
+
task_queue: str
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def flow_state_from_proto(flow_id: str, response: pb.GetFlowStateResponse) -> FlowState:
|
|
211
|
+
"""Map a GetFlowState response into the public FlowState."""
|
|
212
|
+
return FlowState(
|
|
213
|
+
active_step_executions=tuple(
|
|
214
|
+
_map_active_step_execution(flow_id, step)
|
|
215
|
+
for step in response.active_step_executions
|
|
216
|
+
),
|
|
217
|
+
task_queue=response.flow_config.worker_target.task_queue,
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def _map_active_step_execution(
|
|
222
|
+
flow_id: str, step: pb.ActiveStepExecutionState
|
|
223
|
+
) -> ActiveStepExecution:
|
|
224
|
+
step_type_part, separator, number_part = step.step_execution_id.rpartition("-")
|
|
225
|
+
execution_number = _parse_execution_number(number_part)
|
|
226
|
+
if separator == "" or step_type_part == "" or execution_number < 1:
|
|
227
|
+
raise RuntimeError(
|
|
228
|
+
f"Dex returned a malformed Step execution ID {step.step_execution_id!r} "
|
|
229
|
+
f"for Flow {flow_id}"
|
|
230
|
+
)
|
|
231
|
+
invocation = None
|
|
232
|
+
if step.HasField("wait_for_invocation"):
|
|
233
|
+
invocation = _map_invocation(StepMethodName.WAIT_FOR, step.wait_for_invocation)
|
|
234
|
+
elif step.HasField("execute_invocation"):
|
|
235
|
+
invocation = _map_invocation(StepMethodName.EXECUTE, step.execute_invocation)
|
|
236
|
+
return ActiveStepExecution(
|
|
237
|
+
step_execution_id=step.step_execution_id,
|
|
238
|
+
step_type=step.step_type,
|
|
239
|
+
execution_number=execution_number,
|
|
240
|
+
phase=(
|
|
241
|
+
ActiveStepExecutionPhase.WAITING
|
|
242
|
+
if step.phase == pb.ACTIVE_STEP_PHASE_WAITING
|
|
243
|
+
else ActiveStepExecutionPhase.ACTIVE
|
|
244
|
+
),
|
|
245
|
+
invocation=invocation,
|
|
246
|
+
last_failure=(
|
|
247
|
+
_map_failure(step.last_failure_info)
|
|
248
|
+
if step.HasField("last_failure_info")
|
|
249
|
+
else None
|
|
250
|
+
),
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _parse_execution_number(number_part: str) -> int:
|
|
255
|
+
"""Return the ASCII decimal number, or 0 when it is not a safe integer."""
|
|
256
|
+
is_ascii_decimal = number_part.isascii() and number_part.isdecimal()
|
|
257
|
+
if not is_ascii_decimal or len(number_part) > _MAX_SAFE_INTEGER_DIGITS:
|
|
258
|
+
return 0
|
|
259
|
+
execution_number = int(number_part)
|
|
260
|
+
return execution_number if execution_number <= _MAX_SAFE_INTEGER else 0
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def _map_invocation(
|
|
264
|
+
method: StepMethodName, invocation: pb.StepMethodInvocationState
|
|
265
|
+
) -> StepMethodInvocation:
|
|
266
|
+
return StepMethodInvocation(
|
|
267
|
+
method=method,
|
|
268
|
+
phase=_INVOCATION_PHASES.get(
|
|
269
|
+
invocation.phase, StepMethodInvocationPhase.UNSPECIFIED
|
|
270
|
+
),
|
|
271
|
+
attempt=invocation.attempt,
|
|
272
|
+
pending_reason=_PENDING_REASONS.get(invocation.pending_reason),
|
|
273
|
+
pending_since=(
|
|
274
|
+
invocation.pending_since_time.ToDatetime(tzinfo=timezone.utc)
|
|
275
|
+
if invocation.HasField("pending_since_time")
|
|
276
|
+
else None
|
|
277
|
+
),
|
|
278
|
+
attempt_started_at=(
|
|
279
|
+
invocation.attempt_started_time.ToDatetime(tzinfo=timezone.utc)
|
|
280
|
+
if invocation.HasField("attempt_started_time")
|
|
281
|
+
else None
|
|
282
|
+
),
|
|
283
|
+
backoff_fires_at=(
|
|
284
|
+
invocation.backoff_fires_at_time.ToDatetime(tzinfo=timezone.utc)
|
|
285
|
+
if invocation.HasField("backoff_fires_at_time")
|
|
286
|
+
else None
|
|
287
|
+
),
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def _map_failure(failure: pb.StepMethodFailure) -> StepMethodFailureInfo:
|
|
292
|
+
details = failure.details
|
|
293
|
+
return StepMethodFailureInfo(
|
|
294
|
+
attempt=failure.attempt,
|
|
295
|
+
error_type=details.original_worker_error_type,
|
|
296
|
+
detail=details.original_worker_error_detail or details.detail,
|
|
297
|
+
stack_trace=details.original_worker_error_stack_trace,
|
|
298
|
+
backend_error=failure.backend_error,
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
# Matches the TypeScript SDK, which rejects numbers above Number.MAX_SAFE_INTEGER.
|
|
303
|
+
_MAX_SAFE_INTEGER = 2**53 - 1
|
|
304
|
+
_MAX_SAFE_INTEGER_DIGITS = len(str(_MAX_SAFE_INTEGER))
|
|
305
|
+
|
|
306
|
+
_INVOCATION_PHASES = {
|
|
307
|
+
pb.STEP_METHOD_INVOCATION_PHASE_PENDING: StepMethodInvocationPhase.PENDING,
|
|
308
|
+
pb.STEP_METHOD_INVOCATION_PHASE_RUNNING: StepMethodInvocationPhase.RUNNING,
|
|
309
|
+
pb.STEP_METHOD_INVOCATION_PHASE_BACKOFF: StepMethodInvocationPhase.BACKOFF,
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
_PENDING_REASONS = {
|
|
313
|
+
pb.STEP_METHOD_PENDING_REASON_WAITING_FOR_WORKER: (
|
|
314
|
+
StepMethodPendingReason.WAITING_FOR_WORKER
|
|
315
|
+
),
|
|
316
|
+
pb.STEP_METHOD_PENDING_REASON_WAITING_FOR_SUPPORTING_WORKER: (
|
|
317
|
+
StepMethodPendingReason.WAITING_FOR_SUPPORTING_WORKER
|
|
318
|
+
),
|
|
319
|
+
pb.STEP_METHOD_PENDING_REASON_WAITING_FOR_LOCKS: (
|
|
320
|
+
StepMethodPendingReason.WAITING_FOR_LOCKS
|
|
321
|
+
),
|
|
322
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "dex-python-sdk"
|
|
3
3
|
# Publish uses tag sdk-python/v*; CI stamps this for release builds.
|
|
4
|
-
version = "1.45.
|
|
4
|
+
version = "1.45.2"
|
|
5
5
|
description = "Python SDK for the Dex workflow engine"
|
|
6
6
|
authors = [{name = "Super Durable"}]
|
|
7
7
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/config.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/format.rs
RENAMED
|
File without changes
|
|
File without changes
|
{dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache/src/policy.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/Cargo.toml
RENAMED
|
File without changes
|
{dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/LICENSE
RENAMED
|
File without changes
|
{dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/README.md
RENAMED
|
File without changes
|
{dex_python_sdk-1.45.1 → dex_python_sdk-1.45.2}/sdk-rust/crates/dex-blob-cache-python/src/lib.rs
RENAMED
|
File without changes
|