-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Adding hook for plugins to upgrade either their raw data or the system #28
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
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.
Pull Request Overview
This pull request introduces comprehensive versioning and upgrade functionality to the r2x_core
framework, allowing plugins to manage data and system upgrades through flexible versioning strategies and automated upgrade workflows.
Key changes include:
- Implementation of versioning strategies for semantic versioning, git-based versioning, and file modification time tracking
- Development of an upgrade system supporting both data context (raw files/dictionaries) and system context (model instances) transformations
- Integration with the plugin system to enable automatic upgrade application during data loading and system deserialization
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/r2x_core/versioning.py |
New module implementing versioning strategy protocol and concrete implementations |
src/r2x_core/upgrader.py |
New module providing upgrade system with step definitions, execution, and rollback capabilities |
src/r2x_core/plugins.py |
Extended PluginManager to support upgrade step registration and retrieval |
src/r2x_core/system.py |
Added automatic system upgrade application during JSON deserialization |
src/r2x_core/store.py |
Added automatic data upgrade application during DataStore loading |
src/r2x_core/__init__.py |
Exposed new versioning and upgrade classes and functions in public API |
pyproject.toml |
Added packaging dependency for semantic version handling |
tests/ |
Comprehensive test coverage for versioning, upgrader, rollback, and plugin integration |
docs/ |
Extensive documentation including API references, how-to guides, and usage examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
from typing import Any, Protocol | ||
|
||
from loguru import logger | ||
from packaging.version import Version |
Copilot
AI
Oct 13, 2025
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.
Import should be guarded to handle ImportError gracefully. The packaging library is a new dependency and may not be available in all environments.
from packaging.version import Version | |
try: | |
from packaging.version import Version | |
except ImportError: | |
Version = None | |
logger.warning( | |
"The 'packaging' library is not installed. Semantic versioning features will not be available. " | |
"Install it with 'pip install packaging'." | |
) |
Copilot uses AI. Check for mistakes.
src/r2x_core/upgrader.py
Outdated
original_data : Any | ||
The original data before any upgrades. | ||
""" | ||
self.original_data = copy.deepcopy(original_data) |
Copilot
AI
Oct 13, 2025
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.
Deep copying large data structures on every UpgradeResult initialization could be expensive. Consider lazy initialization or shallow copy with deep copy only when rollback is actually needed.
Copilot uses AI. Check for mistakes.
src/r2x_core/upgrader.py
Outdated
... data = result.rollback() # Back to original | ||
""" | ||
logger.info("Rolling back all upgrades to original state") | ||
self.current_data = copy.deepcopy(self.original_data) |
Copilot
AI
Oct 13, 2025
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.
Another deep copy operation in rollback method. This could be optimized by storing the deep copy once and reusing it, or by implementing a more efficient rollback mechanism.
self.current_data = copy.deepcopy(self.original_data) | |
self.current_data = self.original_data |
Copilot uses AI. Check for mistakes.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #28 +/- ##
==========================================
- Coverage 97.94% 94.63% -3.32%
==========================================
Files 19 21 +2
Lines 1024 1285 +261
==========================================
+ Hits 1003 1216 +213
- Misses 21 69 +48 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This pull request introduces comprehensive documentation and practical guides for versioning and upgrade strategies in the
r2x_core
framework. It adds new "Versioning and Upgrades" sections to the documentation, provides detailed API references, and includes extensive how-to guides and usage examples for managing data and system upgrades. The changes are grouped as follows:Documentation Structure and Navigation
docs/source/how-tos/index.md
).versioning
andupgrader
units to the navigation (docs/source/references/index.md
). [1] [2]API Reference Expansion
VersioningStrategy
,SemanticVersioningStrategy
,GitVersioningStrategy
,FileModTimeStrategy
,UpgradeContext
,UpgradeStep
,UpgradeResult
, and key upgrade functions (apply_upgrade
,apply_upgrades
,apply_upgrades_with_rollback
) (docs/source/references/api.md
).How-To Guides and Usage Examples
docs/source/how-tos/version-management.md
).docs/source/how-tos/upgrade-data.md
).Concept and Best Practices Documentation
docs/source/references/versioning.md
).