This is the Dapr SDK for Python, based on the auto-generated proto client.
For more info on Dapr and gRPC, visit this link.
The repository generates following package
- dapr
pip install dapr-clientNote: Depending on your OS, you may want to use pip3 instead of pip.
A client can be created as follows:
from dapr.proto.dapr.v1 import dapr_pb2 as messages
from dapr.proto.dapr.v1 import dapr_pb2_grpc as services
import grpc
from google.protobuf.any_pb2 import Any
channel = grpc.insecure_channel('localhost:50001')
client = services.DaprStub(channel)You can find a complete example here
You can execute this code using the local dapr runtime:
dapr run --protocol grpc --grpc-port=50001 python example.pyNote: Depending on your OS, you may want to use python3 instead of python.
Package can be generated as:
cd src
python setup.py sdist bdist_wheelNote: Depending on your OS, you may want to use python3 instead of python.
The package will be generated in src/dist directory. For more information on generating packages, see python documentation at https://packaging.python.org/tutorials/packaging-projects/
As a good practice create a python virtual environment:
python3 -m venv <env_name>
source <env_name>/bin/activateRun the following commands:
pip3 install -r grpc_requirements
sudo chmod +x protobuf.sh
. ./protobuf.shRun the following commands in powershell:
pip3 install -r grpc_requirements
.\protobuf.ps1Add absolute path of src folder as PYTHONPATH environment variable.
Note: To use the newly generated proto buf stubs and gRPC interface replace
daprdwithedgeversion ofdaprdbuilt from master branch. Refer this for instructions on how to builddaprdfrom master.