-
Notifications
You must be signed in to change notification settings - Fork 29
Update SDK to 2026-01-23 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
452d109
6d46afb
9214712
6b84070
d339a83
95e1ed5
c487f98
87df21e
bbad289
16e045b
32d6744
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,13 @@ cd "$(dirname "$0")" | |
| OUTPUT_DIR="src/ucp_sdk/models" | ||
|
|
||
| # Schema directory (relative to this script) | ||
| SCHEMA_DIR="../../spec/" | ||
| SCHEMA_DIR="ucp/source" | ||
| TEMP_SCHEMA_DIR="temp_schemas" | ||
|
|
||
| echo "Generating Pydantic models from $SCHEMA_DIR..." | ||
| echo "Preprocessing schemas..." | ||
| python3 preprocess_schemas.py | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| echo "Generating Pydantic models from preprocessed schemas..." | ||
|
|
||
| # Check if uv is installed | ||
| if ! command -v uv &> /dev/null; then | ||
|
|
@@ -23,14 +27,35 @@ fi | |
| rm -r -f "$OUTPUT_DIR" | ||
| mkdir -p "$OUTPUT_DIR" | ||
|
|
||
| # Create ruff configuration for generated code | ||
| cat > "$OUTPUT_DIR/ruff.toml" << 'EOF' | ||
| # Ruff configuration for generated models | ||
| # These are auto-generated files, so we're more lenient with style rules | ||
|
|
||
| line-length = 120 | ||
| target-version = "py311" | ||
|
|
||
| [lint] | ||
| select = ["E", "F", "I"] | ||
| ignore = ["E501"] | ||
|
|
||
| [lint.pydocstyle] | ||
| convention = "google" | ||
|
|
||
| [lint.per-file-ignores] | ||
| "__init__.py" = ["D104"] | ||
| "*.py" = ["D100", "D101", "D102", "D103", "D200", "D205", "D212"] | ||
| EOF | ||
|
|
||
| # Run generation using uv | ||
| # We use --use-schema-description to use descriptions from JSON schema as docstrings | ||
| # We use --field-constraints to include validation constraints (regex, min/max, etc.) | ||
| # Note: Formatters removed as they can hang on large schemas | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be better to comment that formatting is done as a post-processing step. We still want to reformat the code to minimize accidental whitespace changes. |
||
| uv run \ | ||
| --link-mode=copy \ | ||
| --extra-index-url https://pypi.org/simple python \ | ||
| -m datamodel_code_generator \ | ||
| --input "$SCHEMA_DIR" \ | ||
| --input "$TEMP_SCHEMA_DIR" \ | ||
| --input-file-type jsonschema \ | ||
| --output "$OUTPUT_DIR" \ | ||
| --output-model-type pydantic_v2.BaseModel \ | ||
|
|
@@ -41,7 +66,13 @@ uv run \ | |
| --disable-timestamp \ | ||
| --use-double-quotes \ | ||
| --no-use-annotated \ | ||
| --allow-extra-fields \ | ||
| --formatters ruff-format ruff-check | ||
| --allow-extra-fields | ||
|
|
||
| echo "Formatting generated models..." | ||
| uv run ruff format "$OUTPUT_DIR" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| uv run ruff check --fix --config "$OUTPUT_DIR/ruff.toml" "$OUTPUT_DIR" 2>&1 | grep -E "^(All checks passed|Fixed|Found)" || echo "Formatting complete" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we remove |
||
|
|
||
| # Clean up temporary schemas | ||
| rm -rf "$TEMP_SCHEMA_DIR" | ||
|
|
||
| echo "Done. Models generated in $OUTPUT_DIR" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding as a submodule instead.