Skip to content

Conversation

pesap
Copy link
Collaborator

@pesap pesap commented Oct 13, 2025

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

  • Added a "Versioning and Upgrades" section to the main how-tos index, improving discoverability of versioning and upgrade topics (docs/source/how-tos/index.md).
  • Updated the references index to include all versioning and upgrade classes and functions, and added versioning and upgrader units to the navigation (docs/source/references/index.md). [1] [2]

API Reference Expansion

  • Added detailed API documentation for all versioning and upgrade classes and functions, including 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

  • Added a comprehensive how-to guide for version management, covering semantic, git-based, timestamp, file modification, and custom strategies, with code examples for each scenario (docs/source/how-tos/version-management.md).
  • Added a detailed how-to guide for upgrade management, including creating and applying upgrades, migration patterns, rollback, plugin registration, version constraints, error handling, validation, idempotency, and upgrade priorities (docs/source/how-tos/upgrade-data.md).

Concept and Best Practices Documentation

  • Introduced a dedicated versioning strategies reference, explaining the protocols, usage patterns, custom implementations, comparison conventions, object compatibility, and best practices for choosing and using versioning strategies (docs/source/references/versioning.md).

@Copilot Copilot AI review requested due to automatic review settings October 13, 2025 18:31
Copy link
Contributor

@Copilot Copilot AI left a 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
Copy link

Copilot AI Oct 13, 2025

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.

Suggested change
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.

original_data : Any
The original data before any upgrades.
"""
self.original_data = copy.deepcopy(original_data)
Copy link

Copilot AI Oct 13, 2025

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.

... data = result.rollback() # Back to original
"""
logger.info("Rolling back all upgrades to original state")
self.current_data = copy.deepcopy(self.original_data)
Copy link

Copilot AI Oct 13, 2025

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.

Suggested change
self.current_data = copy.deepcopy(self.original_data)
self.current_data = self.original_data

Copilot uses AI. Check for mistakes.

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 81.67939% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.63%. Comparing base (2f5f407) to head (93de217).

Files with missing lines Patch % Lines
src/r2x_core/versioning.py 72.72% 30 Missing ⚠️
src/r2x_core/system.py 9.09% 10 Missing ⚠️
src/r2x_core/store.py 20.00% 8 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants