Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
348 lines (324 loc) · 13.1 KB
/
Copy pathpyproject.toml
File metadata and controls
348 lines (324 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
[project]
name = "dapr"
dynamic = ["version"]
description = "The official release of Dapr Python SDK."
readme = "README.md"
requires-python = ">=3.10"
license = {text = "Apache-2.0"}
authors = [{name = "Dapr Authors", email = "dapr@dapr.io"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"protobuf>=6.33.5,<8.0.0",
"grpcio>=1.81.1,<2.0.0",
"grpcio-status>=1.81.1,<2.0.0",
"aiohttp>=3.9.5,<4.0.0",
"python-dateutil>=2.8.1,<3.0.0",
"typing-extensions>=4.4.0,<5.0.0",
]
[project.optional-dependencies]
fastapi = [
"fastapi>=0.60.1,<1.0.0",
"uvicorn>=0.11.6,<1.0.0",
]
flask = [
"Flask>=1.1.4,<4.0.0",
]
grpc = [
"cloudevents>=1.0.0,<2.0.0",
]
langgraph = [
"langgraph>=0.3.6,<2.0.0",
"langchain>=0.1.17,<2.0.0",
"python-ulid>=3.0.0,<5.0.0",
"msgpack>=1.0,<2.0",
]
strands = [
"strands-agents>=1.30.0,<2.0.0",
"python-ulid>=3.0.0,<5.0.0",
"msgpack>=1.0,<2.0",
]
# workflow has no third-party runtime deps beyond core dapr. The empty extra
# exists so users get a consistent `pip install dapr[<ext>]` shape and so the
# extra is reserved if workflow ever grows external deps.
workflow = []
# rag bundles only the embedder (the one adapter every rag pipeline needs);
# every cloud source, vector store, and parser is its own extra below so
# installing `dapr[rag]` never pulls in boto3/azure/pinecone/psycopg/
# unstructured a given user doesn't need. `pip install "dapr[rag,rag-s3,
# rag-pgvector]"` mirrors the S3 + pgvector example in dapr/ext/rag/AGENTS.md.
rag = [
"openai>=1.50.0,<2.0.0",
]
rag-langchain = [
"langchain-core>=0.3.0,<2.0.0",
]
rag-unstructured = [
"unstructured[md,pdf,docx]>=0.15.0,<1.0.0",
]
rag-s3 = [
"boto3>=1.34.0,<2.0.0",
]
rag-azure = [
"azure-storage-blob>=12.19.0,<13.0.0",
"azure-identity>=1.15.0,<2.0.0",
]
rag-pgvector = [
"psycopg[binary]>=3.1.0,<4.0.0",
]
rag-pinecone = [
"pinecone>=5.0.0,<8.0.0",
]
# Separate from rag-azure (azure-storage-blob/-identity): a different SDK
# package (azure-search-documents) for a different Azure service, needed only
# by AzureAISearchVectorStore. AzureOpenAIEmbedder/AzureOpenAIChatClient reuse
# `openai` (already in `rag`) and `azure-identity` (already in `rag-azure`),
# so they need no extra of their own.
# httpx is needed here specifically: Azure AI Search index aliases were
# briefly in the SDK as a beta feature (11.4.0b1) but removed before the
# stable 11.4.0 release and have not been restored in any version since
# (verified against the SDK's own CHANGELOG.md) -- alias management is
# implemented as direct REST calls (see vector_stores/azure_ai_search.py)
# since the typed client has no equivalent method.
rag-azure-search = [
"azure-search-documents>=11.5.0,<12.0.0",
"httpx>=0.27.0,<1.0.0",
]
# databricks is also empty on purpose: it schedules Dapr Workflow executions
# (via dapr.ext.workflow, already in core) from inside a Databricks Lakeflow
# pipeline. pyspark.pipelines is provided by that Databricks runtime itself —
# depending on a pip-installable "pyspark" here would be both unnecessary for
# real usage and insufficient for local imports, since pyspark.pipelines is
# not part of the open-source PyPI pyspark package. dapr.ext.databricks
# imports it lazily and raises a clear error if it's unavailable.
databricks = []
all = [
"dapr[fastapi,flask,grpc,langgraph,strands,workflow,databricks]",
"dapr[rag,rag-langchain,rag-s3,rag-azure,rag-azure-search,rag-pgvector,rag-pinecone]",
# rag-unstructured is deliberately NOT included here, unlike every other
# rag-* extra above. unstructured[pdf] pulls in a full ML stack (PyTorch,
# onnx/onnxruntime, transformers, ...): on a Linux CI job this raises the
# `all` install from roughly 82 MB to roughly 3.5 GB downloaded (7-8 GB on
# disk), and macOS/Windows pick up PyTorch too. `dev`/`tests` (below) both
# resolve to `dapr[all]`, so that weight would land on every contributor's
# `uv sync` and every CI job, for a parser no unit test actually exercises
# against the real package (see dapr/ext/rag/AGENTS.md's Testing section:
# UnstructuredParser's own tests run its OptionalDependencyError fallback
# path, not real parsing). Anyone who wants real `unstructured`-based
# parsing installs it explicitly: `pip install "dapr[rag-unstructured]"`.
]
[project.urls]
Documentation = "https://github.com/dapr/docs"
Source = "https://github.com/dapr/python-sdk"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.version]
source = "regex"
path = "VERSION"
pattern = '(?P<version>\S+)'
[tool.hatch.build.targets.wheel]
# IMPORTANT: do NOT introduce dapr/ext/__init__.py. `dapr.ext` is kept as an
# implicit PEP 420 namespace package so external plugins can publish their own
# distributions under `dapr.ext.*` without colliding with this wheel's
# `RECORD`. Materialising `dapr/ext/__init__.py` here would lock out every
# future externally-published dapr.ext.* plugin by claiming ownership of the
# namespace parent.
# TODO: drop flask_dapr in 1.22 (with the shim).
packages = ["dapr", "flask_dapr"]
# Repo-internal docs (contributor / AI-agent guidance) live next to the code
# for discoverability but should not ship in the published wheel.
exclude = [
"**/AGENTS.md",
"dapr/ext/*/README.md",
]
# No workspace members. Before the bundling, each extension was a separate
# workspace package under ext/. Now all extension code lives in the core
# `dapr` package and is opt-in via [project.optional-dependencies].
[tool.uv.workspace]
members = []
[tool.uv]
constraint-dependencies = [
# onnxruntime (pulled in transitively via rag-unstructured's unstructured[pdf]
# -> unstructured-inference, for PDF parsing) dropped cp310 wheels starting at
# 1.24.1 -- verified against PyPI's actual file listing, not just metadata.
# Pin to the last cp310-compatible release so `uv lock`/`uv sync` doesn't pick
# a version with no installable wheel for this project's Python 3.10 floor.
# python_version >= 3.11 is unaffected and resolves onnxruntime normally.
"onnxruntime<1.24; python_version < '3.11'",
]
[dependency-groups]
dev = [
# Pull in every extension's third-party deps so the full test suite runs
# in the dev env. `dapr` here resolves to this workspace project itself,
# so `dapr[all]` activates every extras list declared above.
"dapr[all]",
"mypy==2.3.0",
"mypy-extensions~=1.1.0",
"mypy-protobuf==5.0.0",
"grpcio-tools==1.81.1",
"types-python-dateutil~=2.9.0",
"types-grpcio-status~=1.0.0",
"coverage>=7.13.4,<7.16.0",
"wheel~=0.46.3",
"opentelemetry-sdk>=1.40,<1.45",
"opentelemetry-instrumentation-grpc~=0.61b0",
"opentelemetry-exporter-zipkin~=1.11.1",
"httpx~=0.28.1",
"cryptography>=49.0.0",
"redis>=7.4.0",
"Flask~=3.1.3",
"pytest>=9.0.2,<9.2.0",
"pytest-asyncio>=0.23",
"ruff==0.16.2",
"python-dotenv~=1.2.2",
"pydantic~=2.13.3",
"PyYAML~=6.0.3",
]
tests = [
{include-group = "dev"},
"mechanical-markdown~=0.8.0",
"langchain-ollama>=1.0.1,<1.2.0",
]
[tool.ruff]
target-version = "py310"
line-length = 100
fix = true
extend-exclude = [".github", "dapr/proto", "dapr/ext/workflow/_durabletask/internal/*_pb2*"]
# Honor extend-exclude even when ruff is invoked with explicit file paths
# (pre-commit hooks, lint-staged, manual debugging). Without this, ruff would
# happily lint and "fix" the generated `*_pb2.py` stubs and strip the
# `import attestation_pb2` lines that the protobuf descriptor pool needs.
force-exclude = true
[tool.ruff.lint]
select = [
"I", # isort
"W", # pycodestyle warnings
"F", # pyflakes
"E", # pycodestyle errors
# TODO: Add those back progressively as we fix the issues
# "C", # flake8-comprehensions
# "B", # flake8-bugbear
# "UP", # pyupgrade
]
# TODO: Add those back progressively as we fix the issues
ignore = ["E501", "E203", "E712", "E722", "E713"]
[tool.ruff.lint.isort]
# Extensions now live inside the core `dapr` wheel, so `dapr` and the
# `flask_dapr` shim are first-party, not third-party imports.
known-first-party = ["dapr", "flask_dapr"]
# Without this, same-package autodetection on files under `dapr/ext/*` keeps
# `dapr` in the third-party group, so the first-party setting above never
# takes effect for the bundled extensions.
detect-same-package = false
[tool.ruff.format]
quote-style = 'single'
[tool.mypy]
python_version = "3.10"
install_types = true
non_interactive = true
warn_unused_configs = true
warn_redundant_casts = true
show_error_codes = true
check_untyped_defs = true
namespace_packages = true
packages = [
"dapr",
"flask_dapr",
]
[[tool.mypy.overrides]]
module = ["dapr.proto.*"]
ignore_errors = true
[[tool.mypy.overrides]]
module = ["grpc.aio"]
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["langgraph.*", "langchain.*", "strands.*", "strands_agents.*"]
ignore_missing_imports = true
# dapr.ext.rag's optional adapters: some of these (boto3, langchain_core) are
# installed in CI/dev without inline type stubs or only via a transitive
# extra; others (azure-*, psycopg, pinecone, unstructured) may not be
# installed at all, since every dapr.ext.rag adapter guards its own optional
# import (see dapr/ext/rag/AGENTS.md) rather than requiring the full `rag-*`
# extra set. Unlike the fastapi/langgraph/strands/workflow modules below,
# dapr.ext.rag is new code and is NOT in the ignore_errors bucket -- it is
# expected to pass mypy cleanly.
[[tool.mypy.overrides]]
module = [
"boto3",
"boto3.*",
"botocore.*",
"azure.*",
"psycopg.*",
]
ignore_missing_imports = true
# unstructured (pdf/docx extras), openai, pinecone, and langchain-core all
# transitively pull in numpy -- openai, pinecone, and langchain-core each
# reference numpy array/vector types directly from their own inline stubs,
# and unstructured's pdf/docx extras drag in a large ML stack (pandas, spacy,
# transformers, onnx, ...) that does the same. dapr.ext.rag never imports
# numpy itself. Recent numpy versions bundle stubs/source using PEP 695
# generic syntax that mypy cannot parse under this project's python_version =
# "3.10" target, and unlike a normal type error, a syntax error aborts the
# *entire* mypy run, not just dapr.ext.rag. follow_imports = "skip" keeps
# mypy from following past the one place dapr.ext.rag actually imports each
# of these (parsing/unstructured.py, embedding/_openai_common.py,
# generation.py, vector_stores/pinecone.py, parsing/langchain.py) into that
# graph, so numpy's own files are never opened; ignore_missing_imports covers
# environments where a given package isn't installed at all (each is an
# optional dependency here). Verified (see the completion report) that a
# plain `import numpy` reached this way still crashes mypy even when numpy
# itself is separately skipped or stub-shadowed -- skipping has to happen at
# the direct import site, not at the transitively-reached destination.
[[tool.mypy.overrides]]
module = ["unstructured.*", "openai.*", "pinecone.*", "langchain_core.*"]
follow_imports = "skip"
ignore_missing_imports = true
# pyspark (and pyspark.pipelines specifically) is provided by the Databricks
# Lakeflow runtime, not a project dependency — see the `databricks` extra
# above. dapr.ext.databricks imports it lazily at call time; this override
# only lets mypy check the TYPE_CHECKING-only references to it.
[[tool.mypy.overrides]]
module = ["pyspark.*"]
ignore_missing_imports = true
# Bundling the extensions into the core wheel brings their source under mypy's
# namespace walk for the first time. These modules carry pre-existing type
# errors that were previously hidden by the separate-workspace-package layout.
# Ignored here to keep this packaging PR scope-limited; clean up in a follow-up.
# TODO: drop these overrides as each module's type errors are fixed.
[[tool.mypy.overrides]]
module = [
"dapr.ext.fastapi.*",
"dapr.ext.langgraph.*",
"dapr.ext.strands.*",
"dapr.ext.workflow.*",
]
ignore_errors = true
[tool.pytest.ini_options]
markers = [
'binary_store: tests requiring Dapr runtime 1.19 binary-store APIs',
'example_dir(name): set the example directory for the dapr fixture',
'perf: timing-sensitive dispatch regression tests',
'e2e: tests requiring a running Dapr sidecar',
'dapr_head: tests requiring a daprd built from dapr/dapr master, not a release',
]
pythonpath = ["."]
asyncio_mode = "auto"
[tool.coverage.run]
# Without `source`, files never imported by the test run are invisible to
# coverage and silently inflate the total reported to codecov.
source = ['dapr', 'flask_dapr']
# Leading ** keeps the pattern cwd-independent: coverage absolutizes
# non-wildcard patterns against the invocation directory, so a bare
# 'dapr/proto/**' only matches when run from the repo root.
omit = ['**/dapr/proto/**']