Skip to content

Commit 1b7d7df

Browse files
committed
Migrate dev dependencies to pyproject.toml, remove dev-requirements.txt and update related files and workflows.
Dump flake8 and use ruff that covers format and linting. Update readme Signed-off-by: Filinto Duran <[email protected]>
1 parent a37c93b commit 1b7d7df

File tree

9 files changed

+60
-103
lines changed

9 files changed

+60
-103
lines changed

.flake8

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/workflows/pr-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Install dependencies
2929
run: |
3030
python -m pip install --upgrade pip
31-
pip install -r dev-requirements.txt
31+
pip install '.[dev]'
3232
- name: Lint with flake8
3333
run: |
3434
flake8 . --count --show-source --statistics --exit-zero

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,33 +162,48 @@ The following is more information about how to develop this project. Note that d
162162
### Generating protobufs
163163

164164
```sh
165-
pip3 install -r dev-requirements.txt
165+
# install dev dependencies for generating protobufs and running tests
166+
pip3 install '.[dev]'
167+
166168
make gen-proto
167169
```
168170

169171
This will download the `orchestrator_service.proto` from the `microsoft/durabletask-protobuf` repo and compile it using `grpcio-tools`. The version of the source proto file that was downloaded can be found in the file `durabletask/internal/PROTO_SOURCE_COMMIT_HASH`.
170172

171173
### Running unit tests
172174

173-
Unit tests can be run using the following command from the project root. Unit tests _don't_ require a sidecar process to be running.
175+
Unit tests can be run using the following command from the project root.
176+
Unit tests _don't_ require a sidecar process to be running.
177+
178+
To run on a specific python version (eg: 3.11), run the following command from the project root:
174179

175180
```sh
176-
make test-unit
181+
tox -e py311
177182
```
178183

179184
### Running E2E tests
180185

181-
The E2E (end-to-end) tests require a sidecar process to be running. You can use the Dapr sidecar for this or run a Durable Task test sidecar using the following command:
186+
The E2E (end-to-end) tests require a sidecar process to be running.
187+
188+
For non-multi app activities test you can use the Durable Task test sidecar using the following command:
182189

183190
```sh
184191
go install github.com/dapr/durabletask-go@main
185192
durabletask-go --port 4001
186193
```
187194

188-
To run the E2E tests, run the following command from the project root:
195+
Certain aspects like multi-app activities require the full dapr runtime to be running.
196+
197+
```shell
198+
dapr init || true
199+
200+
dapr run --app-id test-app --dapr-grpc-port 4001 --components-path ./examples/components/
201+
```
202+
203+
To run the E2E tests on a specific python version (eg: 3.11), run the following command from the project root:
189204

190205
```sh
191-
make test-e2e
206+
tox -e py311-e2e
192207
```
193208

194209
## Contributing

dev-requirements.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

durabletask/client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ def schedule_new_orchestration(
137137
) -> str:
138138
name = orchestrator if isinstance(orchestrator, str) else task.get_name(orchestrator)
139139

140+
input_pb = (
141+
wrappers_pb2.StringValue(value=shared.to_json(input)) if input is not None else None
142+
)
143+
140144
req = pb.CreateInstanceRequest(
141145
name=name,
142146
instanceId=instance_id if instance_id else uuid.uuid4().hex,
143-
input=wrappers_pb2.StringValue(value=shared.to_json(input))
144-
if input is not None
145-
else None,
147+
input=input_pb,
146148
scheduledStartTimestamp=helpers.new_timestamp(start_at) if start_at else None,
147149
version=wrappers_pb2.StringValue(value=""),
148150
orchestrationIdReusePolicy=reuse_id_policy,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: dapr.io/v1alpha1
2+
kind: Component
3+
metadata:
4+
name: statestore
5+
spec:
6+
type: state.redis
7+
version: v1
8+
metadata:
9+
- name: redisHost
10+
value: localhost:6379
11+
- name: redisPassword
12+
value: ""
13+
- name: actorStateStore
14+
value: "true"
15+
- name: keyPrefix
16+
value: "workflow"

pyproject.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ markers = [
4949
"e2e: mark a test as an end-to-end test that requires a running sidecar"
5050
]
5151

52+
[project.optional-dependencies]
53+
dev = [
54+
"pytest",
55+
"pytest-asyncio>=0.23",
56+
"flake8==7.3.0",
57+
"tox>=4.0.0",
58+
"pytest-cov",
59+
"ruff",
60+
61+
# grpc gen
62+
"grpcio-tools==1.75.1",
63+
]
64+
5265
[tool.ruff]
5366
target-version = "py39" # TODO: update to py310 when we drop support for py39
5467
line-length = 100
@@ -59,7 +72,6 @@ select = [
5972
"E", # pycodestyle errors
6073
"W", # pycodestyle warnings
6174
"F", # pyflakes
62-
"I", # isort
6375
"C", # flake8-comprehensions
6476
"B", # flake8-bugbear
6577
"UP", # pyupgrade

requirements.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
autopep8
2-
grpcio>=1.60.0 # 1.60.0 is the version introducing protobuf 1.25.X support, newer versions are backwards compatible
3-
protobuf
4-
pytest
5-
pytest-cov
6-
asyncio
1+
# requirements in pyproject.toml

tox.ini

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ envlist =
66
flake8,
77
ruff,
88
mypy,
9+
# TODO: switch runner to uv (tox-uv plugin)
10+
runner = virtualenv
911

1012
[testenv]
1113
# you can run tox with the e2e pytest marker using tox factors:
@@ -16,7 +18,7 @@ envlist =
1618
# DAPR_GRPC_ENDPOINT=localhost:12345 tox -e py310-e2e -- -s
1719
setenv =
1820
PYTHONDONTWRITEBYTECODE=1
19-
deps = -rdev-requirements.txt
21+
deps = .[dev]
2022
commands =
2123
!e2e: pytest {posargs} -q -k "not e2e" --cov=durabletask --cov-branch --cov-report=term-missing --cov-report=xml
2224
e2e: pytest {posargs} -q -k e2e
@@ -25,79 +27,9 @@ commands_pre =
2527
allowlist_externals = pip3
2628
pass_env = DAPR_GRPC_ENDPOINT,DAPR_HTTP_ENDPOINT,DAPR_RUNTIME_HOST,DAPR_GRPC_PORT,DAPR_HTTP_PORT
2729

28-
[testenv:flake8]
29-
basepython = python3
30-
usedevelop = False
31-
deps =
32-
flake8==7.3.0
33-
pip
34-
commands =
35-
flake8 .
36-
3730
[testenv:ruff]
3831
basepython = python3
3932
usedevelop = False
40-
deps = ruff
4133
commands =
4234
ruff check --select I --fix
4335
ruff format
44-
45-
[testenv:examples]
46-
passenv = HOME
47-
basepython = python3
48-
changedir = ./examples/
49-
deps =
50-
mechanical-markdown
51-
commands =
52-
./validate.sh conversation
53-
./validate.sh crypto
54-
./validate.sh metadata
55-
./validate.sh error_handling
56-
./validate.sh pubsub-simple
57-
./validate.sh pubsub-streaming
58-
./validate.sh pubsub-streaming-async
59-
./validate.sh state_store
60-
./validate.sh state_store_query
61-
./validate.sh secret_store
62-
./validate.sh invoke-simple
63-
./validate.sh invoke-custom-data
64-
./validate.sh demo_actor
65-
./validate.sh invoke-binding
66-
./validate.sh grpc_proxying
67-
./validate.sh w3c-tracing
68-
./validate.sh distributed_lock
69-
./validate.sh configuration
70-
./validate.sh demo_workflow
71-
./validate.sh workflow
72-
./validate.sh jobs
73-
./validate.sh ../
74-
commands_pre =
75-
pip3 install -e {toxinidir}/
76-
allowlist_externals=*
77-
78-
[testenv:example-component]
79-
; This environment is used to validate a specific example component.
80-
; Usage: tox -e example-component -- component_name
81-
; Example: tox -e example-component -- conversation
82-
passenv = HOME
83-
basepython = python3
84-
changedir = ./examples/
85-
deps =
86-
mechanical-markdown
87-
commands =
88-
./validate.sh {posargs}
89-
90-
commands_pre =
91-
pip3 install -e {toxinidir}/
92-
allowlist_externals=*
93-
94-
[testenv:type]
95-
basepython = python3
96-
usedevelop = False
97-
deps = -rdev-requirements.txt
98-
commands =
99-
mypy --config-file mypy.ini
100-
commands_pre =
101-
pip3 install -e {toxinidir}/
102-
allowlist_externals=*
103-

0 commit comments

Comments
 (0)