-
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?
Conversation
| The models are automatically generated from the JSON schemas in the UCP | ||
| Specification. | ||
|
|
||
| Clone the UCP main repository in the same folder: |
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.
| [project] | ||
| name = "ucp-sdk" | ||
| version = "0.1.0" | ||
| version = "0.2.0" |
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.
Should this get in sync with the spec version? 2026.01.23 ?
| # pylint: disable=all | ||
| # pyformat: disable | ||
| """ | ||
|
|
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.
Why move this to a temporarily generated file? These settings take effect across subdirectories too.
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.
Is this tool specific to the Python repo, or is is needed for Javascript as well? Should it live in the main ucp repo instead?
| # 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 comment
The 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.
|
|
||
| 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 comment
The reason will be displayed to describe this comment to others. Learn more.
uv run ... ?
|
|
||
| echo "Formatting generated models..." | ||
| uv run ruff format "$OUTPUT_DIR" | ||
| 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 comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove --config "$OUTPUT_DIR/ruff.toml" , won't it use the settings from pyproject.toml at the top?
|
|
||
| if __name__ == "__main__": | ||
| script_dir = Path(__file__).parent | ||
| input_schemas = script_dir / "ucp" / "source" |
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 taking command line arguments instead.
| --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 comment
The reason will be displayed to describe this comment to others. Learn more.
$OUTPUT_DIR can be omitted; the whole project will be reformatted.
This pull request introduces major improvements to the model generation workflow, schema preprocessing, and project structure for the UCP Python SDK. The most significant changes include the addition of a schema preprocessing script to resolve compatibility issues, updates to the model generation script to use preprocessed schemas, a refactor of capability and discovery profile models for clarity and separation, and enhanced formatting and linting for generated code.
Schema Preprocessing and Model Generation:
preprocess_schemas.pyscript to preprocess JSON schemas, resolving internal references and removing problematic definitions to ensure compatibility withdatamodel-code-generator. Thegenerate_models.shscript is updated to invoke this preprocessing step and to format/lint generated models using Ruff. [1] [2] [3] [4]Model and Schema Refactoring:
Formatting and Linting Improvements:
pyproject.tomland now generate a dedicatedruff.tomlin the models directory for more lenient linting of auto-generated code. The model generation script now applies formatting and lint fixes automatically. [1] [2] [3] [4]Documentation and Setup Updates:
README.mdto clarify repository cloning instructions and document the need to clone the main UCP repository for schema regeneration. [1] [2]Cleanup and Deprecation:
_internal.pymodels file, as its functionality has been replaced by the new schema-based model structure.