iiasa / ixmp

The ix modeling platform for integrated and cross-cutting scenario analysis
https://docs.messageix.org/ixmp
Apache License 2.0
36 stars 110 forks source link

Record Python package versions in GDX files #502

Closed khaeru closed 6 months ago

khaeru commented 6 months ago

This PR provides the basic functionality for addressing iiasa/message_ix#747.

The GAMSModel class gains an attribute/parameter (record_version_packages) and a method (record_versions()); the latter is called from within the run() method. This adds a set to the Scenario that is to be solved, with entries like:

Set ixmp_version(*,*) Versions of Python packages used to generate this model /
'message_ix'.'3-7-1-dev55+g2e0a9c49', 
'ixmp'.'3-7-1-dev67+g6cab755-d20231122'
'notapackage'.'(not installed)' /;

(The list of included packages is according to record_version_packages, so can be extended by downstream packages, like message-ix, that use or subclass GAMSModel.)

How to review

Read the diff and note that the CI checks all pass.

Test together with a message_ix PR to be opened next.

PR checklist

khaeru commented 6 months ago

@glatterf42 FYI. I'll request your review once the checklist is complete.

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (41f8a96) 98.9% compared to head (36b6c16) 98.9%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #502 +/- ## ===================================== Coverage 98.9% 98.9% ===================================== Files 44 44 Lines 4758 4792 +34 ===================================== + Hits 4706 4741 +35 + Misses 52 51 -1 ``` | [Files](https://app.codecov.io/gh/iiasa/ixmp/pull/502?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa) | Coverage Δ | | |---|---|---| | [ixmp/backend/jdbc.py](https://app.codecov.io/gh/iiasa/ixmp/pull/502?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-aXhtcC9iYWNrZW5kL2pkYmMucHk=) | `97.4% <100.0%> (+0.1%)` | :arrow_up: | | [ixmp/model/gams.py](https://app.codecov.io/gh/iiasa/ixmp/pull/502?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-aXhtcC9tb2RlbC9nYW1zLnB5) | `100.0% <100.0%> (ø)` | | | [ixmp/report/operator.py](https://app.codecov.io/gh/iiasa/ixmp/pull/502?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-aXhtcC9yZXBvcnQvb3BlcmF0b3IucHk=) | `99.0% <ø> (ø)` | | | [ixmp/tests/backend/test\_jdbc.py](https://app.codecov.io/gh/iiasa/ixmp/pull/502?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-aXhtcC90ZXN0cy9iYWNrZW5kL3Rlc3RfamRiYy5weQ==) | `100.0% <100.0%> (ø)` | | | [ixmp/tests/core/test\_scenario.py](https://app.codecov.io/gh/iiasa/ixmp/pull/502?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-aXhtcC90ZXN0cy9jb3JlL3Rlc3Rfc2NlbmFyaW8ucHk=) | `100.0% <100.0%> (ø)` | |