Dex SDK for Python
Python SDK for Dex workflow engine
New user contracts
The rewrite targets Python 3.11+ and exposes strongly typed workflow contracts
from dex. This phase includes definitions, attributes, channels, waits,
decisions, codecs, registry validation, synchronous client calls, and synchronous
worker handlers. Python owns its gRPC Client and Worker transport;
the shared Rust Core is used only for BlobCache.
from datetime import timedelta
import dex
counter = dex.Attribute("counter", int)
counters_by_region = dex.AttributeMap("counters-by-region", int)
class Run(dex.Step[str]):
def wait_for(
self, context: dex.Context, input: str
) -> dex.Wait:
return dex.Wait.all_of(
dex.Timer.by_duration(timedelta(seconds=1))
)
def execute(
self, context: dex.Context, input: str
) -> dex.StepDecision:
return dex.graceful_complete(input)
class CounterFlow(dex.Flow[str]):
run = Run()
def get_flow_type(self) -> str:
return "Counter"
def get_steps(self) -> dex.StepList[str]:
return dex.StepList.start_step(self.run)
def get_persistence_schema(self) -> dex.PersistenceSchema:
return dex.PersistenceSchema.of(counter, counters_by_region)
@dex.rpc(name="Increment")
def increment(
self, context: dex.Context, input: int
) -> dex.RPCResult[int]:
return dex.RPCResult(input + 1)
flow = CounterFlow()
registry = dex.Registry((flow,))
Registry derives codecs from declared Python types and handler annotations.
Built-in scalar types and dataclasses need no codec arguments. Register an
explicit codec only for a custom encoding or a type Registry cannot derive.
PersistenceSchema.of(...) accepts attributes and channels together and
partitions them by definition type.
Initial attributes retain their value types without a public wrapper class:
options = (
dex.StartFlowOptions()
.with_attribute(counter, 1)
.with_attribute(counters_by_region, "us-west", 1)
)
pip install dex-python-sdk==0.0.2
See samples for use case examples.
Requirements
- Python 3.11+
- Dex server
Concepts
Applications implement two generic interfaces from dex.contracts:
Flow[START_INPUT]returnsStepList.start_step(...), followed by optional.other_steps(...), from oneget_steps()method. TheStepListgeneric binds the Flow input to the starting Step input. UseStepList.empty()when a Flow has no Steps.Step[INPUT]implements synchronousexecuteand optionally synchronouswait_for.
StepOptions.wait_for_method_timeout and execute_method_timeout bound the
two handler calls. Timer and channel conditions determine how long a Step waits.
Registry validates every Flow, Step, RPC signature, durable name, lock, and
codec before Client or Worker startup. Client methods use these typed objects
instead of raw Flow, Step, or RPC strings.
The legacy IWF integration inventory is ported under
tests/integ. Its 58 executable scenarios
exercise the same workflows, client operations, and assertions as the Java
suite against an isolated dexcli dev environment.
Implementation status
The strongly typed contracts, registry, synchronous Client, Worker gRPC service, and Rust-backed BlobCache are implemented. Python owns its gRPC transport; the native bridge is limited to the shared BlobCache.
Running dex-server locally
Option 1: use docker compose
See dex README
Option 2: VSCode Dev Container
Dev Container is an easy way to get dex-server running locally. Follow these steps to launch a dev container:
- Install Docker, VSCode, and VSCode Dev Container plugin.
- Open the project in VSCode.
cd dex-python-sdk code .
- Launch the Remote-Containers: Reopen in Container command from Command Palette (Ctrl + Shift + P). You can also click in the bottom left corner to access the remote container menu.
- Once the dev container starts, dex-server will be listening on port 8801.
How To Contribute
This project uses uv for Python versions, dependencies, virtual environments, locking, building, and publishing.
To install requirements:
uv sync --locked
Run the complete Python SDK integration suite with an isolated Dex development environment:
./run-integration-tests.sh
Update IDL
Edit protos/dex.proto. Rename catalog: docs/design/idl-renames.md.
Generate stubs from IDL
make -C ../protos proto-python
Checked-in Python stubs land in dex/dexpb/.
Linting
To run linting for this project:
uv run --frozen pre-commit run --show-diff-on-failure --color=always --all-files
Code of Conduct
This project is governed by the Contributor Covenant v 1.4.1. (Review the Code of Conduct and remove this sentence before publishing your project.)
Publishing to PyPI
- Bump
versioninpyproject.toml, refreshuv.lock, and update thepip installline above. - Run Publish Python SDK to PyPI manually without
publishto validate all distributions. - Create a GitHub Release with tag
sdk-python/vX.Y.Z(for examplesdk-python/v0.0.2). - CI builds and smoke-tests Linux x86_64/ARM64, macOS x86_64/ARM64, and Windows x86_64 wheels, verifies the source distribution, and publishes them with
PYPI_TOKEN.
A manual run publishes only from main, when its version matches pyproject.toml and publish is explicitly selected.
See CONTRIBUTING.md for monorepo tag conventions.
License
Super Durable Source License 1.0, with legacy portions under their original terms as described in LEGACY_NOTICES.md.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dex_python_sdk-0.0.2.tar.gz.
File metadata
- Download URL: dex_python_sdk-0.0.2.tar.gz
- Upload date:
- Size: 138.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a9dfcf72f21a1a43a4b4c5feaf96224c7bca32a7b5567d347a23968e58da0ee
|
|
| MD5 |
47ca2b43f0a59ca181db89991684f2f8
|
|
| BLAKE2b-256 |
10ae364233fad2087051197944538b6b5b1943a00f02de502b49afcb9d13d1ce
|
File details
Details for the file dex_python_sdk-0.0.2-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: dex_python_sdk-0.0.2-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 563.4 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9186a48d2ef3de4789d7d605a0dc38ef7ca138a90d0fb30be0ad0a5d01081991
|
|
| MD5 |
a24be7dff831d33d75c00648d2233235
|
|
| BLAKE2b-256 |
c9a99b39f9c8f82f851ee5c88c944876e077b539d24edca4f42d005bffd489e4
|
File details
Details for the file dex_python_sdk-0.0.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: dex_python_sdk-0.0.2-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 719.9 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c27244ad42062fe54f5247933c72fd3f12c1d1f2f228c82733b224d51fa72cf3
|
|
| MD5 |
eab5770403f55ceba4880bb7e23e39c5
|
|
| BLAKE2b-256 |
ac649cbed47c3dd171c8b47705b366a284e185bd0fd519a810504868a36c49fd
|
File details
Details for the file dex_python_sdk-0.0.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: dex_python_sdk-0.0.2-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 717.8 kB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f32f924c0732e912e92063c4e6267655a0bd63b4ac1d34d44dd885a4943ed4d9
|
|
| MD5 |
8aa64142863fda45a3e6be430e45dfac
|
|
| BLAKE2b-256 |
357fe5263a24b82b872bc5306ff175dc75658a5e9d6db43d23cf4939d8192124
|
File details
Details for the file dex_python_sdk-0.0.2-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: dex_python_sdk-0.0.2-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 660.9 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9b25baf672de8e3cbdbc86d7f8cc3646287cd2f4531e2b0810a9b0b64a9898b
|
|
| MD5 |
bfb6429e49fcc841a8ce50103c5acfd8
|
|
| BLAKE2b-256 |
434bf8e14209c8340cec8247d1c45697f6faf0974bd72cb63cf2686f700fa24a
|
File details
Details for the file dex_python_sdk-0.0.2-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: dex_python_sdk-0.0.2-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 680.4 kB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd6654745af30ab078bbaeb047e4a9f14e52ebbc4a06f7590ea8d6e93a7ef45b
|
|
| MD5 |
0225332ba2f39e5030f47b651e02687e
|
|
| BLAKE2b-256 |
70c242fcdcbd2396b9fcef6bc38be5759285ca19fc88ba77cea68a11777390a1
|