Repository navigation
chore: remove deprecated Pydantic v1 API and add version tracking to subcontracts #88
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
Changes from 2 commits
a094779
52d71ee
1a9f069
eb3844a
319f818
c388454
2b4543b
8e2669e
5df4e46
143bec7
5fef3f4
798ed98
282901e
cbdc9d3
f15b929
6bcc5e5
33eb678
c1b2dcb
1c0b5ff
04c33b7
5d06825
4b7ffe3
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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # YAML Validation Allowlist | ||
| # | ||
| # This file defines exceptions to the manual YAML validation detection hook. | ||
| # These are legitimate utility functions and files that need to use yaml.safe_load() | ||
| # for valid architectural reasons (e.g., parsing before Pydantic validation). | ||
|
|
||
| # Files allowed to use yaml.safe_load() (utility modules) | ||
| allowed_files: | ||
| - "src/omnibase_core/utils/util_safe_yaml_loader.py" # YAML utility functions | ||
| - "src/omnibase_core/validation/contracts.py" # Contract validation utilities | ||
| - "src/omnibase_core/validation/contract_validator.py" # Contract validator - preprocesses YAML | ||
|
|
||
| # Specific filenames that are allowed (matched by basename) | ||
| allowed_filenames: | ||
| - "util_safe_yaml_loader.py" | ||
|
|
||
| # Function names allowed to use yaml.safe_load() | ||
| allowed_functions: | ||
| - "load_and_validate_yaml_model" # Utility function in contracts.py - uses Pydantic validation | ||
| - "validate_model_compliance" # Validator in contract_validator.py - inspects raw YAML | ||
| - "validate_contract_yaml" # Contract validator - preprocesses YAML before Pydantic validation | ||
| - "load_yaml_content" # Generic YAML loading utility | ||
| - "parse_yaml_safely" # Safe YAML parsing utility | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ from pathlib import Path | |
| from omnibase_core.models.core.model_mixin_metadata import ModelMixinMetadataCollection | ||
|
|
||
| # Load all mixin metadata | ||
| collection = ModelMixinMetadataCollection.load_from_yaml( | ||
| collection = ModelMixinMetadataCollection.from_yaml( | ||
|
Contributor
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. 🧩 Analysis chainVerify API rename is not a breaking change. The documentation shows Run the following script to verify whether If Also applies to: 68-68, 95-95 🏁 Script executed: #!/bin/bash
# Check if load_from_yaml still exists as deprecated method or alias
rg -n "def load_from_yaml" --type=py -C3
# Check for any deprecation decorators or warnings
rg -n "@deprecated|warnings.warn.*load_from_yaml" --type=py -C3Length of output: 1529 I need to verify this further by searching for where 🏁 Script executed: #!/bin/bash
# Find where from_yaml is defined
echo "=== Searching for from_yaml method definitions ==="
rg -n "def from_yaml" --type=py -B5 -A10
echo ""
echo "=== Searching for any reference to load_from_yaml (including strings, comments, etc) ==="
rg -n "load_from_yaml" --type=py -B2 -A2
echo ""
echo "=== Check ModelMixinMetadataCollection class specifically ==="
rg -n "class ModelMixinMetadataCollection" --type=py -A20Length of output: 20556 Let me check if 🏁 Script executed: #!/bin/bash
# Search git log for load_from_yaml to see if it was ever present
echo "=== Git history for load_from_yaml ==="
git log --all -S "def load_from_yaml" --oneline -- "*.py" | head -20
echo ""
echo "=== Check CHANGELOG for breaking changes ==="
if [ -f CHANGELOG.md ]; then
grep -i "load_from_yaml\|breaking\|rename" CHANGELOG.md | head -20
fi
echo ""
echo "=== Check for __all__ exports in model files ==="
rg -n "__all__" src/omnibase_core/models/core/model_mixin_metadata_collection.pyLength of output: 752 I need to examine the actual commits to understand how 🏁 Script executed: #!/bin/bash
# Show the actual changes in those commits
echo "=== Changes in commit a094779 related to yaml methods ==="
git show a094779 --format="" -- "src/omnibase_core/models/core/model_mixin_metadata_collection.py" 2>/dev/null | head -100
echo ""
echo "=== Changes in commit 77d7963 related to yaml methods ==="
git show 77d7963 --format="" -- "src/omnibase_core/models/core/model_mixin_metadata_collection.py" 2>/dev/null | head -100
echo ""
echo "=== Check if there's a deprecation alias or property ==="
rg -n "load_from_yaml|@deprecated|warnings.warn" --type=py src/omnibase_core/models/core/model_mixin_metadata_collection.py -B3 -A3
echo ""
echo "=== Look for any deprecation decorators in the entire models directory ==="
rg -n "@deprecated\|deprecate\|@property.*load" --type=py src/omnibase_core/models/ | head -20Length of output: 4318 Let me check which specific files had 🏁 Script executed: #!/bin/bash
# Find all model files that previously had load_from_yaml (from git history)
echo "=== All files that mention load_from_yaml in git history ==="
git log --all -S "load_from_yaml" --name-only --pretty=format: -- "*.py" | sort | uniq
echo ""
echo "=== Check if load_from_yaml appears in tests (to understand the old API) ==="
rg -n "def load_from_yaml|\.load_from_yaml\(" --type=py tests/ | head -30
echo ""
echo "=== Search for from_yaml in tests to see the new API usage ==="
rg -n "\.from_yaml\(" --type=py tests/ | head -20Length of output: 1854 Let me verify the current state of those two model files to confirm 🏁 Script executed: #!/bin/bash
# Check current state of model_mixin_metadata.py
echo "=== Current state of model_mixin_metadata.py ==="
rg -n "def.*from_yaml|def.*load_from_yaml" --type=py src/omnibase_core/models/core/model_mixin_metadata.py -A2
echo ""
echo "=== Current state of model_docker_compose_manifest.py ==="
rg -n "def.*from_yaml|def.*load_from_yaml" --type=py src/omnibase_core/models/docker/model_docker_compose_manifest.py -A2
echo ""
echo "=== Check git blame to see when load_from_yaml was removed from model_mixin_metadata.py ==="
git log --all --source --remotes -S "def load_from_yaml" --oneline -- "src/omnibase_core/models/core/model_mixin_metadata.py" | head -5
echo ""
echo "=== Check git blame for model_docker_compose_manifest.py ==="
git log --all --source --remotes -S "def load_from_yaml" --oneline -- "src/omnibase_core/models/docker/model_docker_compose_manifest.py" | head -5Length of output: 764 Update PR description to reflect API breaking change. Verification confirms that Either:
🤖 Prompt for AI Agents |
||
| Path("src/omnibase_core/mixins/mixin_metadata.yaml") | ||
| ) | ||
|
|
||
|
|
@@ -92,7 +92,7 @@ from omnibase_core.models.docker.model_docker_compose_manifest import ( | |
| ) | ||
|
|
||
| # Load from YAML | ||
| manifest = ModelDockerComposeManifest.load_from_yaml( | ||
| manifest = ModelDockerComposeManifest.from_yaml( | ||
| Path("docker-compose.yaml") | ||
| ) | ||
|
|
||
|
|
@@ -160,7 +160,7 @@ from omnibase_core.models.docker.model_docker_compose_manifest import ( | |
| ) | ||
|
|
||
| # Load manifest | ||
| manifest = ModelDockerComposeManifest.load_from_yaml( | ||
| manifest = ModelDockerComposeManifest.from_yaml( | ||
| Path("docker-compose.yaml") | ||
| ) | ||
|
|
||
|
|
@@ -188,7 +188,7 @@ from omnibase_core.models.docker.model_docker_compose_manifest import ( | |
| ) | ||
|
|
||
| # Load existing manifest | ||
| manifest = ModelDockerComposeManifest.load_from_yaml( | ||
| manifest = ModelDockerComposeManifest.from_yaml( | ||
| Path("docker-compose.yaml") | ||
| ) | ||
|
|
||
|
|
@@ -214,7 +214,7 @@ from omnibase_core.models.core.model_mixin_metadata import ( | |
| ) | ||
|
|
||
| # Load all available mixins | ||
| collection = ModelMixinMetadataCollection.load_from_yaml( | ||
| collection = ModelMixinMetadataCollection.from_yaml( | ||
| Path("src/omnibase_core/mixins/mixin_metadata.yaml") | ||
| ) | ||
|
|
||
|
|
@@ -257,7 +257,7 @@ class NodeDockerOrchestrator(NodeOrchestrator): | |
| super().__init__(container) | ||
|
|
||
| # Load and validate manifest | ||
| self.manifest = ModelDockerComposeManifest.load_from_yaml( | ||
| self.manifest = ModelDockerComposeManifest.from_yaml( | ||
| Path(container.get_config("docker_compose_path")) | ||
| ) | ||
|
|
||
|
|
@@ -327,7 +327,7 @@ from omnibase_core.models.docker.model_docker_compose_manifest import ( | |
| def test_load_and_validate_manifest(): | ||
| """Test loading and validating a docker-compose.yaml file.""" | ||
| # Load test fixture | ||
| manifest = ModelDockerComposeManifest.load_from_yaml( | ||
| manifest = ModelDockerComposeManifest.from_yaml( | ||
| Path("tests/fixtures/docker-compose.yaml") | ||
| ) | ||
|
|
||
|
|
@@ -346,23 +346,22 @@ def test_load_and_validate_manifest(): | |
|
|
||
| ## Related Documentation | ||
|
|
||
| - [Mixin System Architecture](../architecture/MIXIN_SYSTEM.md) - Complete mixin system documentation | ||
| - [Docker Integration Guide](../guides/DOCKER.md) - Using Docker models in ONEX workflows | ||
| - [Validation Framework](../guides/VALIDATION.md) - Pydantic validation patterns | ||
| - [Configuration Management](../guides/CONFIGURATION.md) - Managing system configuration | ||
| - [Mixin System Architecture](../architecture/MIXIN_ARCHITECTURE.md) - Complete mixin system documentation | ||
| - [Validation Framework](VALIDATION_FRAMEWORK.md) - Pydantic validation patterns | ||
| - [Configuration Management](../patterns/CONFIGURATION_MANAGEMENT.md) - Managing system configuration | ||
|
|
||
| ## Best Practices | ||
|
|
||
| ### 1. Always Validate on Load | ||
|
|
||
| ```python | ||
| # ✅ Good: Validate immediately after loading | ||
| manifest = ModelDockerComposeManifest.load_from_yaml(path) | ||
| manifest = ModelDockerComposeManifest.from_yaml(path) | ||
| if warnings := manifest.validate_dependencies(): | ||
| logger.warning(f"Validation warnings: {warnings}") | ||
|
|
||
| # ❌ Bad: Skip validation | ||
| manifest = ModelDockerComposeManifest.load_from_yaml(path) | ||
| manifest = ModelDockerComposeManifest.from_yaml(path) | ||
| # ... use manifest without validation | ||
| ``` | ||
|
|
||
|
|
@@ -413,7 +412,7 @@ manifest.save_to_yaml(Path("docker-compose.yaml")) | |
| ```python | ||
| # Solution: Check YAML syntax and schema compatibility | ||
| try: | ||
| manifest = ModelDockerComposeManifest.load_from_yaml(path) | ||
| manifest = ModelDockerComposeManifest.from_yaml(path) | ||
| except ValidationError as e: | ||
| print(f"Validation errors: {e.errors()}") | ||
| # Fix YAML structure based on error messages | ||
|
|
@@ -452,4 +451,4 @@ Planned improvements for manifest models: | |
| **See Also**: | ||
| - [Architecture Overview](../architecture/ONEX_FOUR_NODE_ARCHITECTURE.md) | ||
| - [Error Handling Best Practices](../conventions/ERROR_HANDLING_BEST_PRACTICES.md) | ||
| - [Testing Guide](../testing/README.md) | ||
| - [Testing Guide](../guides/TESTING_GUIDE.md) | ||
Uh oh!
There was an error while loading. Please reload this page.