-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyproject.toml
More file actions
480 lines (446 loc) · 14.2 KB
/
Copy pathpyproject.toml
File metadata and controls
480 lines (446 loc) · 14.2 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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
[project]
authors = [{ name = "Google" }]
dependencies = [
"dotpromptz==0.1.5",
"genkit",
"genkit-amazon-bedrock",
"genkit-anthropic",
"genkit-openai",
"genkit-django",
"genkit-evaluators",
"genkit-fastapi",
"genkit-flask",
"genkit-google-cloud",
"genkit-google-genai",
"genkit-middleware",
"genkit-ollama",
"genkit-vertexai",
]
description = "Workspace for Genkit packages"
license = "Apache-2.0"
name = "genkit-workspace"
readme = "README.md"
requires-python = ">=3.10"
version = "0.1.0"
[dependency-groups]
dev = [
"bpython>=0.25",
"ipython~=8.22; python_version <= '3.10'",
"ipython~=9.0.2; python_version >= '3.11'",
"jupyter>=1.1.1",
"mcp>=1.25.0",
"pytest-asyncio>=0.25.3",
"pytest>=8.3.4",
"pytest-cov>=6.0.0",
"datamodel-code-generator>=0.27.3",
"pytest-mock>=3.14.0",
"twine>=7.0.0",
"pip>=25.0.1",
"nox>=2025.2.9",
"nox-uv>=0.2.2",
"mkdocs-material>=9.7.7",
"mkdocstrings[python]>=1.0.6",
]
lint = [
"liccheck>=0.9.2",
"setuptools>=75.0.0,<82", # Required by liccheck (provides pkg_resources, removed in setuptools 82+)
"bandit>=1.7.0",
"deptry>=0.22.0",
"litestar>=2.20.0", # For web/typing.py type resolution
"mypy>=1.14.0",
"pip-audit>=2.7.0",
"pypdf>=6.7.5",
"pyrefly>=0.15.0",
"pyright>=1.1.392",
"pysentry-rs>=0.3.14",
"ruff>=0.9",
"strenum>=0.4.15",
"streamlit>=1.41.0",
"ty>=0.0.1",
"fastapi>=0.115.0",
"grpcio>=1.68.0",
"grpcio-reflection>=1.68.0",
"gunicorn>=22.0.0",
"hypercorn>=0.17.0",
"opentelemetry-exporter-otlp-proto-grpc>=1.20.0",
"opentelemetry-instrumentation-asgi>=0.41b0",
"opentelemetry-instrumentation-fastapi>=0.41b0",
"opentelemetry-instrumentation-grpc>=0.41b0",
"quart>=0.19.0",
"secure>=1.0.0",
"sentry-sdk>=2.0.0",
"structlog>=24.0.0",
]
# Pytest for unit testing and coverage.
[tool.pytest.ini_options]
addopts = [
"--cov",
#"--cov-report=", # Disable terminal report generation by pytest-cov
"-ra",
"-vv",
"--import-mode=importlib",
]
asyncio_default_fixture_loop_scope = "session"
filterwarnings = [
# Pydantic warns when a field named 'schema' shadows BaseModel.schema()
# We intentionally use 'schema' to match the JSON schema spec.
"ignore:Field name .schema. in .* shadows an attribute in parent .BaseModel.:UserWarning",
# dotpromptz uses the same pattern; not our code, suppress it too.
"ignore:Field name .schema. in .Prompt.*Config. shadows:UserWarning",
]
norecursedirs = [".git", ".tox", ".nox", ".venv", "build", "dist"]
python_files = ["*_test.py"]
pythonpath = ["."]
testpaths = ["packages", "samples", "tests", "tools"]
asyncio_mode = "strict"
[tool.coverage.report]
fail_under = 78
[tool.coverage.run]
omit = [
"**/__init__.py", # Often contains just imports
"**/_testing.py", # Internal test utilities
"**/constants.py", # Typically just constants
"**/typing.py", # Often auto-generated or complex types
"**/types.py", # Often auto-generated or complex types
]
source = ["packages"]
# uv based package management.
[tool.uv]
default-groups = ["dev", "lint"]
override-dependencies = ["werkzeug>=3.1.6"]
[[tool.uv.index]]
name = "pypi"
url = "https://pypi.org/simple"
default = true
[tool.uv.sources]
# Samples (alphabetical by package name from pyproject.toml)
agents = { workspace = true }
amazon-bedrock-sample = { workspace = true }
anthropic-sample = { workspace = true }
basic-flows = { workspace = true }
context = { workspace = true }
django-hello = { workspace = true }
dynamic-tools = { workspace = true }
evaluators = { workspace = true }
flask-hello = { workspace = true }
gemini-code-execution = { workspace = true }
gemini-context-caching = { workspace = true }
google-genai-media = { workspace = true }
middleware = { workspace = true }
ollama-sample = { workspace = true }
output-formats = { workspace = true }
prompts = { workspace = true }
tool-interrupts = { workspace = true }
tracing = { workspace = true }
vertexai-imagen = { workspace = true }
# Core packages
genkit = { workspace = true }
genkit-amazon-bedrock = { workspace = true }
genkit-anthropic = { workspace = true }
genkit-openai = { workspace = true }
genkit-django = { workspace = true }
genkit-evaluators = { workspace = true }
genkit-fastapi = { workspace = true }
genkit-flask = { workspace = true }
genkit-google-cloud = { workspace = true }
genkit-google-genai = { workspace = true }
genkit-middleware = { workspace = true }
genkit-ollama = { workspace = true }
genkit-vertexai = { workspace = true }
[tool.uv.workspace]
exclude = ["*/shared"]
members = ["packages/*", "samples/*"]
# Ruff checks and formatting.
[tool.ruff]
exclude = [
"packages/genkit/src/genkit/_core/_typing.py", # Generated by generate_schema_typing
"scripts/schema_to_typing.py", # Internal generator script
".git",
".mypy_cache",
".nox",
".pytest_cache",
".ruff_cache",
".tox",
".venv",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
indent-width = 4
line-length = 120
preview = true
target-version = "py310"
unsafe-fixes = true
[tool.ruff.lint]
fixable = ["ALL"]
ignore = [
"S101", # assert used - we use assert for type narrowing and tests
"S105", # hardcoded password string - false positives in tests
"S106", # hardcoded password func arg - false positives in tests
"S311", # random not for security - we don't use random for crypto
]
select = [
"E", # pycodestyle (errors)
"W", # pycodestyle (warnings)
"F", # pyflakes
"I", # isort (import sorting)
"UP", # pyupgrade (Python version upgrades)
"B", # flake8-bugbear (common bugs)
"N", # pep8-naming (naming conventions)
"D", # pydocstyle
"ANN", # flake8-annotations (type hints)
"F401", # unused imports
"F403", # wildcard imports
"F841", # unused variables
"S", # flake8-bandit (security)
"ASYNC", # flake8-async (async best practices)
"T20", # flake8-print (no print statements)
]
[tool.ruff.lint.per-file-ignores]
# Auto-generated file from schema
"packages/genkit/src/genkit/_core/_typing.py" = ["E501"]
# Base model uses **kwargs: Any to match pydantic signatures
"packages/genkit/src/genkit/_core/_base.py" = ["ANN401"]
# JSON Patch diff/apply operations require manipulating arbitrary Any JSON structures
"packages/genkit/src/genkit/_ai/_json_patch.py" = ["ANN401"]
# HTTP client uses **httpx_kwargs: Any to forward arbitrary options
"packages/genkit/src/genkit/_core/_http_client.py" = ["ANN401"]
# Span wrapper uses __getattr__ -> Any for dynamic delegation
"packages/genkit/src/genkit/_core/trace/_adjusting_exporter.py" = ["ANN401"]
# Re-export modules (F401 would flag imports used only for re-export)
"packages/genkit/src/genkit/_ai/__init__.py" = ["F401"]
"packages/genkit/src/genkit/_ai/_document.py" = ["F401"]
"packages/genkit/src/genkit/_ai/_model.py" = ["F401"]
"packages/genkit/src/genkit/_ai/_formats/__init__.py" = ["F401"]
"packages/genkit/src/genkit/_core/trace/__init__.py" = ["F401"]
# Test files don't need docstrings or type ceremony; test names/bodies are self-documenting
"**/tests/**/*.py" = ["D", "ANN"]
"packages/genkit/tests/typing/*.py" = ["D", "F821", "F841", "B018", "ANN"]
# Samples are demo code and can use blocking I/O, prints, top-level execution
"samples/**/*.py" = ["ANN", "D", "E402", "ASYNC", "T201"]
[tool.ruff.lint.isort]
combine-as-imports = true
force-single-line = false
known-first-party = ["genkit"]
section-order = [
"future",
"standard-library",
"third-party",
"first-party",
"local-folder",
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.format]
docstring-code-format = true
docstring-code-line-length = 120
indent-style = "space"
line-ending = "lf"
quote-style = "single"
skip-magic-trailing-comma = false
[tool.datamodel-codegen]
#collapse-root-models = true # Don't use; produces Any as types.
#strict-types = ["str", "int", "float", "bool", "bytes"] # Don't use; produces StrictStr, StrictInt, etc.
#use-subclass-enum = true
base-class = "genkit._core._base.GenkitModel"
capitalize-enum-members = true
disable-timestamp = true
enable-version-header = true
field-constraints = true
input = "../genkit-tools/genkit-schema.json"
input-file-type = "jsonschema"
output = "packages/genkit/src/genkit/_core/_typing.py"
output-model-type = "pydantic_v2.BaseModel"
snake-case-field = true
strict-nullable = true
target-python-version = "3.11"
use-default = false
use-schema-description = true
use-standard-collections = true
use-subclass-enum = true
use-union-operator = true
use-unique-items-as-set = true
[tool.liccheck]
authorized_licenses = [
"3-clause bsd",
"apache 2.0",
"apache software license",
"apache software",
"apache",
"apache-2.0",
"bsd license",
"bsd-3-clause",
"bsd",
"cmu license (mit-cmu)",
"isc license (iscl)",
"isc license",
"mit license",
"mit",
"mit-cmu",
"new bsd license",
"new bsd",
"psf-2.0",
"python software foundation license",
"simplified bsd",
"the unlicense (unlicense)", # TODO: verify.
"bsd-2-clause",
"apache license 2.0",
"apache-2.0 and mit",
"mpl-2.0 and mit", # tqdm uses this dual license
]
dependencies = true
unauthorized_licenses = [
"gnu lgpl",
"gpl v3",
"lgpl with exceptions or zpl",
"zpl 2.1",
"mpl",
]
[tool.liccheck.authorized_packages]
aiohappyeyeballs = "2.6.1" # Python Software Foundation (transitive dep of xai-sdk)
aiohttp = "3.13.3" # Apache-2.0 AND MIT (transitive dep of xai-sdk)
certifi = "2026.1.4" # TODO: Verify.
dependencies = true
dotpromptz-handlebars = "0.1.8" # Apache-2.0 "https://github.com/google/dotprompt/blob/main/LICENSE"
google-crc32c = "1.8.0" # Apache-2.0
mistralai = ">=1.9.11" # Apache-2.0 "https://github.com/mistralai/client-python/blob/main/LICENSE"
multidict = "6.7.0" # Apache-2.0
ollama = "0.5.1" # MIT "https://github.com/ollama/ollama-python/blob/main/LICENSE"
pyasn1 = "0.6.2" # BSD-2-Clause
# Ty (Astral/Ruff) type checking configuration.
# See: https://docs.astral.sh/ty/modules/#first-party-modules
[tool.ty.src]
# Auto-generated protobuf stubs use grpc.experimental implicit submodule
# access that ty warns about. We can't modify generated code.
exclude = [
"**/generated",
]
[tool.ty.environment]
root = [
# Core package
"packages/genkit/src",
# Integration packages
"packages/genkit-amazon-bedrock/src",
"packages/genkit-anthropic/src",
"packages/genkit-openai/src",
"packages/genkit-django/src",
"packages/genkit-evaluators/src",
"packages/genkit-fastapi/src",
"packages/genkit-flask/src",
"packages/genkit-google-cloud/src",
"packages/genkit-google-genai/src",
"packages/genkit-middleware/src",
"packages/genkit-ollama/src",
"packages/genkit-vertexai/src",
".", # For samples.shared and other root-level imports
]
# Pyright type checking configuration.
[tool.pyright]
exclude = [
"**/__pycache__",
".git",
".mypy_cache",
".nox",
".pytest_cache",
".ruff_cache",
".tox",
"build",
"dist",
]
extraPaths = [
"packages/genkit/src",
"packages/genkit-amazon-bedrock/src",
"packages/genkit-anthropic/src",
"packages/genkit-openai/src",
"packages/genkit-django/src",
"packages/genkit-evaluators/src",
"packages/genkit-fastapi/src",
"packages/genkit-flask/src",
"packages/genkit-google-cloud/src",
"packages/genkit-google-genai/src",
"packages/genkit-middleware/src",
"packages/genkit-ollama/src",
"packages/genkit-vertexai/src",
]
pythonVersion = "3.10"
reportMissingImports = true
reportMissingTypeStubs = false
typeCheckingMode = "basic"
venv = ".venv"
venvPath = "."
# Pyrefly type checking configuration (Meta's new type checker).
[tool.pyrefly]
project_excludes = [
"**/__pycache__",
".git",
".mypy_cache",
".nox",
".pytest_cache",
".ruff_cache",
".tox",
".venv",
"build",
"dist",
]
project_includes = [
# Core package
"packages/genkit/src/**/*.py",
]
# Search path for first-party code import resolution.
search-path = [
".",
"packages/genkit/src",
"packages/genkit-amazon-bedrock/src",
"packages/genkit-anthropic/src",
"packages/genkit-openai/src",
"packages/genkit-django/src",
"packages/genkit-evaluators/src",
"packages/genkit-fastapi/src",
"packages/genkit-flask/src",
"packages/genkit-google-cloud/src",
"packages/genkit-google-genai/src",
"packages/genkit-middleware/src",
"packages/genkit-ollama/src",
"packages/genkit-vertexai/src",
]
python_version = "3.10"
# Treat warnings as errors.
[tool.pyrefly.errors]
deprecated = "error"
redundant-cast = "error"
# Downgrade unused-type-ignore to avoid noise from comments that pyright needed but ty doesn't.
[tool.ty.rules]
unused-type-ignore-comment = "ignore"
# Relax invalid-argument-type in tests: config=dict is common, ModelRequest validates at runtime.
[[tool.ty.overrides]]
include = ["**/tests/**", "**/*_test.py", "samples/**", "tools/**"]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore"
no-matching-overload = "ignore"
# Vertex AI model_garden has relative imports ty struggles to resolve (PEP 420 / namespace).
[[tool.ty.overrides]]
include = ["packages/genkit-vertexai/**"]
[tool.ty.overrides.rules]
unresolved-import = "ignore"
# genkit._ai._formats._schema: dict.get with str keys from JSON schema traversal.
[[tool.ty.overrides]]
include = ["packages/genkit/src/genkit/_ai/_formats/_schema.py"]
[tool.ty.overrides.rules]
invalid-argument-type = "ignore"