Dapr is a portable, event-driven, serverless runtime for building distributed applications across cloud and edge.
Dapr SDK for Python allows you to implement the Virtual Actor model, based on the actor design pattern. This SDK can run locally, in a container and in any distributed systems environment.
This includes the following packages:
- dapr.actor: Actor Framework
- dapr.clients: Dapr clients for Dapr building blocks
- dapr.conf: Configuration
- dapr.serializers: serializer/deserializer
- dapr.proto: Dapr gRPC autogenerated gRPC clients
- dapr.ext.grpc: gRPC extension for Dapr
- dapr.ext.fastapi: FastAPI extension (actor) for Dapr
- flask.dapr: Flask extension (actor) for Dapr
- Official package
# Install Dapr client sdk
pip3 install dapr
# Install Dapr gRPC AppCallback service extension
pip3 install dapr-ext-grpc
# Install Dapr Fast Api extension for Actor
pip3 install dapr-ext-fastapi- Development package
# Install Dapr client sdk
pip3 install dapr
# Install Dapr gRPC AppCallback service extension
pip3 install dapr-ext-grpc-dev
# Install Dapr Fast Api extension for Actor
pip3 install dapr-ext-fastapi-devNote: Do not install both packages.
Go to Examples
-
Install uv
-
Clone python-sdk
git clone https://github.com/dapr/python-sdk.git
cd python-sdk- Install all packages and dev dependencies
uv sync --all-packages --group dev- Run linter and autofix
uv run ruff check --fix && uv run ruff format- Run unit tests
uv run python -m unittest discover -v ./tests- Run type check
uv run mypy- Run integration tests
uv run pytest tests/integration/- Validate the examples
uv run pytest tests/examples/If you need to run the examples or integration tests against a pre-released version of the runtime, you can use the following command:
- Get your daprd runtime binary from here for your platform.
- Copy the binary to your dapr home folder at $HOME/.dapr/bin/daprd.
Or using dapr cli directly:
dapr init --runtime-version <release version> - Now you can run the examples with
uv run pytest tests/examples/or the integration tests withuv run pytest tests/integration/.
Documentation is generated using Sphinx. Extensions used are mainly Napoleon (To process the Google Comment Style) and Autodocs (For automatically generating documentation). The .rst files are generated using Sphinx-Apidocs.
To generate documentation:
uv run --with sphinx sphinx-apidoc -E -o docs/actor dapr/actor
uv run --with sphinx sphinx-apidoc -E -o docs/clients dapr/clients
uv run --with sphinx sphinx-apidoc -E -o docs/proto dapr/proto
uv run --with sphinx sphinx-apidoc -E -o docs/serializers dapr/serializers
uv run --with sphinx make html -C docsThe generated files will be found in docs/_build.
uv sync --all-packages --group dev
export DAPR_BRANCH=release-1.17 # Optional, defaults to master
uv run ./tools/regen_grpcclient.shNeed help or have feedback on the SDK? Please open a GitHub issue or come chat with us in the #python-sdk channel of our Discord server (click here to join).
This project follows the CNCF Code of Conduct.