-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(py): generate
types.py
from genkit-schema.json
using datamod…
…el-codegen #1807 ISSUE: #1807 CHANGELOG: - [ ] Add a bin/generate_schema_types script that generates the Pydantic types.py module. - [ ] Update the pre-commit hooks to ensure this file gets regenerated routinely. - [ ] Remove timestamp to ensure we do not treat a file with identical content differently preventing the hassles of updating this file per commit.
- Loading branch information
Showing
5 changed files
with
506 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright 2025 Google LLC | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -euo pipefail | ||
|
||
TOP_DIR=$(git rev-parse --show-toplevel) | ||
|
||
uv run --directory "$TOP_DIR/py" \ | ||
datamodel-codegen \ | ||
--collapse-root-models \ | ||
--disable-timestamp \ | ||
--enable-version-header \ | ||
--input "$TOP_DIR/genkit-tools/genkit-schema.json" \ | ||
--input-file-type jsonschema \ | ||
--output-model-type pydantic_v2.BaseModel \ | ||
--output "$TOP_DIR/py/packages/genkit/src/genkit/core/types.py" \ | ||
--target-python-version 3.12 \ | ||
--use-schema-description \ | ||
--use-standard-collections \ | ||
--use-union-operator | ||
|
||
addlicense \ | ||
-c "Google LLC" \ | ||
-s=only \ | ||
"$TOP_DIR/py/packages/genkit/src/genkit/core/types.py" | ||
|
||
uv run --directory "$TOP_DIR/py" \ | ||
ruff check --fix "${TOP_DIR}/py/packages/genkit/src/genkit/core/types.py" | ||
|
||
uv run --directory "$TOP_DIR/py" \ | ||
ruff format "${TOP_DIR}/py/packages/genkit/src/genkit/core/types.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.