single source of truth for version management#231
single source of truth for version management#231ParticularlyPythonicBS merged 1 commit intounstablefrom
Conversation
WalkthroughCentralizes runtime version metadata in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
🧰 Additional context used🧠 Learnings (2)📚 Learning: 2025-11-03T22:55:02.519ZApplied to files:
📚 Learning: 2025-10-27T15:53:41.829ZApplied to files:
🪛 Ruff (0.14.6)temoa/__about__.py9-12: Avoid specifying long messages outside the exception class (TRY003) ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
pyproject.toml(2 hunks)temoa/__about__.py(1 hunks)temoa/__init__.py(1 hunks)temoa/_internal/temoa_sequencer.py(1 hunks)temoa/cli.py(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-03T22:55:02.519Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 186
File: temoa/_internal/temoa_sequencer.py:60-63
Timestamp: 2025-11-03T22:55:02.519Z
Learning: In `TemoaSequencer.__init__`, when a `mode_override` is provided, it must be written back to `self.config.scenario_mode` (not just stored in `self.temoa_mode`) because `HybridLoader.create_data_dict()` has strict consistency checks that validate `config.scenario_mode` matches the presence/absence of `myopic_index`. Without this synchronization, MYOPIC mode would fail with a RuntimeError when the loader is instantiated.
Applied to files:
temoa/__init__.py
📚 Learning: 2025-10-27T15:53:41.829Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 177
File: temoa/model_checking/commodity_network.py:26-33
Timestamp: 2025-10-27T15:53:41.829Z
Learning: The Temoa project requires Python 3.12 or above as the minimum supported version, so PEP 695 `type` syntax for type aliases is appropriate and preferred over `TypeAlias`.
Applied to files:
temoa/__about__.py
🔇 Additional comments (4)
pyproject.toml (1)
3-3: Centralized dynamic version configuration looks consistentUsing
dynamic = ["version"]and pointing the build backend attemoa/__about__.pycleanly centralizes version metadata and aligns with the single–source‑of‑truth goal. I don’t see issues with this configuration.Also applies to: 81-82
temoa/cli.py (1)
15-15: Version flag now correctly reflects the centralized package versionImporting
__version__fromtemoa.__about__and printing it in_version_callbackties the CLI--versionoutput directly to the single version source, which is exactly what this PR aims for.Also applies to: 104-108
temoa/_internal/temoa_sequencer.py (1)
13-18: Sequencer preflight checks now read from the unified version metadataSwitching
DB_MAJOR_VERSION,MIN_DB_MINOR_VERSION,MIN_PYTHON_MAJOR, andMIN_PYTHON_MINORto import fromtemoa.__about__keeps all version requirements in one place without changing semantics of the checks.temoa/__init__.py (1)
11-12: Public version exports correctly delegated totemoa.__about__Importing
TEMOA_MAJOR,TEMOA_MINOR, and__version__fromtemoa.__about__while keeping them in__all__preserves the public API and ensures all consumers see the centralized version metadata.
0e6a81a to
6979ca5
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/source/conf.py (1)
10-21: Move__version__import belowsys.pathsetup to avoid doc build import errorsThe
from temoa.__about__ import __version__at line 10 runs before thesys.path.insert(...)calls at lines 18-20 that add the repository root to the import path. Asphinx-buildrun from a fresh checkout withouttemoainstalled will fail because the localtemoapackage cannot be found.Reorder the import after
sys.pathis configured to support both workflows (installed package and in-tree builds):-import tomlkit - -from temoa.__about__ import __version__ +import tomlkit @@ -# this first import is to provide path the temoa package, which is referenced throughout -# and must be included separately from path the source files so that it is properly recognized -sys.path.insert(0, os.path.abspath('../../')) -# this addition provided direct abbreviated link to the modules in the model -sys.path.insert(1, os.path.abspath('../../temoa/temoa_model')) +# this first import is to provide path the temoa package, which is referenced throughout +# and must be included separately from path the source files so that it is properly recognized +sys.path.insert(0, os.path.abspath('../../')) +# this addition provided direct abbreviated link to the modules in the model +sys.path.insert(1, os.path.abspath('../../temoa/temoa_model')) + +from temoa.__about__ import __version__
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
docs/source/conf.py(3 hunks)pyproject.toml(2 hunks)temoa/__about__.py(1 hunks)temoa/__init__.py(1 hunks)temoa/_internal/temoa_sequencer.py(1 hunks)temoa/cli.py(2 hunks)temoa/version_information.py(0 hunks)
💤 Files with no reviewable changes (1)
- temoa/version_information.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-27T15:53:41.829Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 177
File: temoa/model_checking/commodity_network.py:26-33
Timestamp: 2025-10-27T15:53:41.829Z
Learning: The Temoa project requires Python 3.12 or above as the minimum supported version, so PEP 695 `type` syntax for type aliases is appropriate and preferred over `TypeAlias`.
Applied to files:
temoa/__about__.py
📚 Learning: 2025-11-03T22:55:02.519Z
Learnt from: ParticularlyPythonicBS
Repo: TemoaProject/temoa PR: 186
File: temoa/_internal/temoa_sequencer.py:60-63
Timestamp: 2025-11-03T22:55:02.519Z
Learning: In `TemoaSequencer.__init__`, when a `mode_override` is provided, it must be written back to `self.config.scenario_mode` (not just stored in `self.temoa_mode`) because `HybridLoader.create_data_dict()` has strict consistency checks that validate `config.scenario_mode` matches the presence/absence of `myopic_index`. Without this synchronization, MYOPIC mode would fail with a RuntimeError when the loader is instantiated.
Applied to files:
temoa/__init__.py
🪛 Ruff (0.14.6)
temoa/__about__.py
9-12: Avoid specifying long messages outside the exception class
(TRY003)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: setup and test (macos-latest, 3.13)
- GitHub Check: setup and test (windows-latest, 3.13)
- GitHub Check: setup and test (macos-latest, 3.12)
🔇 Additional comments (5)
temoa/cli.py (1)
15-15: CLI version display correctly centralized ontemoa.__about__.__version__Importing
__version__fromtemoa.__about__and using it directly in_version_callbackcleanly aligns the CLI with the new single source of truth, with no functional issues beyond the intended change to show the full version string.Also applies to: 104-108
pyproject.toml (1)
3-3: Dynamic Hatch-based versioning correctly wired totemoa/__about__.pySwitching
[project]todynamic = ["version"]and pointing[tool.hatch.version].pathattemoa/__about__.pyis consistent with centralizing__version__there; this should keep the package metadata, CLI, and docs all in sync off the same value.Please verify once by building the project with your usual tool (e.g.,
hatch buildoruv build) and confirming that the built wheel/sdist reports the same version aspython -c "import temoa; print(temoa.__version__)".Also applies to: 81-83
temoa/_internal/temoa_sequencer.py (1)
13-18: Sequencer version checks now correctly source constants fromtemoa.__about__Importing
DB_MAJOR_VERSION,MIN_DB_MINOR_VERSION,MIN_PYTHON_MAJOR, andMIN_PYTHON_MINORfromtemoa.__about__keeps the existing pre-flight checks intact while aligning them with the new single source of truth for version metadata. The surrounding logic in_run_preliminary_checksandbuild_modelremains unchanged and still enforces the same constraints. Based on learnings, themode_override–config.scenario_modesynchronization is also unaffected by this import swap.Also applies to: 71-77, 108-110
temoa/__init__.py (1)
11-12: Public version API cleanly re-exported fromtemoa.__about__Importing
TEMOA_MAJOR,TEMOA_MINOR, and__version__fromtemoa.__about__and keeping them in__all__preserves the existingtemoa.__version__/TEMOA_MAJOR/TEMOA_MINORAPI while routing everything through the new shared metadata module.Also applies to: 35-62
temoa/__about__.py (1)
1-24: Centralized version metadata and parsing logic look robust and consistentDefining
__version__here and derivingTEMOA_MAJOR/TEMOA_MINORvia a regex anchored at the numericX.Yprefix gives a resilient way to handle pre-release/dev suffixes while still producing integer major/minor values. The explicitValueErroron unexpected formats and the consolidated minimum Python/database version constants make this a solid single source of truth for versioning across the project.
6979ca5 to
6401ee6
Compare
uses the standardized
__about__to store metadata instead ofversion_dataand uses it as a single source of versioning info throughout the codebaseSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.