iiasa / message-ix-models

Tools for the MESSAGEix-GLOBIOM family of models
https://docs.messageix.org/models
Apache License 2.0
17 stars 34 forks source link

Update MESSAGEix-Materials with new steel technologies #218

Closed GamzeUnlu95 closed 1 month ago

GamzeUnlu95 commented 3 months ago

This PR updates MESSAGEix-Materials to version 1.1.0. The model changes are documented in doc/material/v1.1.0.rst:

The PR also adds tests to the MESSAGEix-Materials build on bare RES. Solving is not possible at the moment and can be added with a follow-up PR.

How to review

The PR is rebased on the most recent version of the main branch. The build, solve, and report functionalities are tested and work without problems. Reviewers can:

PR checklist

GamzeUnlu95 commented 3 months ago

I understand for the versioning, we can create a separate "What's New" section in doc/material/index.rst and describe the changes that were made there without specifying a model version for materials separately.

glatterf42 commented 3 months ago

I understand for the versioning, we can create a separate "What's New" section in doc/material/index.rst and describe the changes that were made there without specifying a model version for materials separately.

You could do that, but I think it's preferable to keep the change notes in one place. So please consider creating a new subsection in doc/whatsnew.rst. This could be a list of indented bullet points as for tools-costs, but it could also be its own subsection of the v2024... heading (see e.g. here for how to do that).

khaeru commented 3 months ago

You could do that, but I think it's preferable to keep the change notes in one place. So please consider creating a new subsection in doc/whatsnew.rst. This could be a list of indented bullet points as for tools-costs, but it could also be its own subsection of the v2024... heading (see e.g. here for how to do that).

To recap the rationale from this Slack message:

So my suggestion was:

khaeru commented 2 months ago

@macflo8 @GamzeUnlu95 per discussion at today's MESSAGE meeting, can I suggest to include (as part of this currently active PR) something like the following on the page doc/material/index.rst —perhaps in the section "Code reference"?

.. note::
   See also :pull:`130`/the archived branch `materials-migrate <https://github.com/iiasa/message-ix-models/tree/migrate-materials>`_ for a distinct version of :mod:`.material`.
   That earlier PR was superseded by :pull:`188`, but may contain usable code or data related to:

   - A
   - B
   - C

This will help reader know that the branch is available, and decide whether they should look at it.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 86.88172% with 61 lines in your changes missing coverage. Please review.

Project coverage is 75.5%. Comparing base (1e5d8d9) to head (8f20625). Report is 86 commits behind head on main.

Files with missing lines Patch % Lines
message_ix_models/model/material/cli.py 25.0% 21 Missing :warning:
message_ix_models/model/material/util.py 40.7% 16 Missing :warning:
message_ix_models/model/material/build.py 82.2% 11 Missing :warning:
message_ix_models/model/material/data_methanol.py 91.3% 8 Missing :warning:
message_ix_models/model/material/data_aluminum.py 97.8% 2 Missing :warning:
message_ix_models/model/material/data_util.py 93.7% 1 Missing :warning:
...l/material/material_demand/material_demand_calc.py 96.9% 1 Missing :warning:
...ssage_ix_models/tests/model/material/test_build.py 95.2% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #218 +/- ## ======================================= + Coverage 66.5% 75.5% +8.9% ======================================= Files 205 203 -2 Lines 15837 15503 -334 ======================================= + Hits 10541 11707 +1166 + Misses 5296 3796 -1500 ``` | [Files with missing lines](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa) | Coverage Δ | | |---|---|---| | [message\_ix\_models/model/bare.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fbare.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvYmFyZS5weQ==) | `100.0% <100.0%> (ø)` | | | [message\_ix\_models/model/config.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fconfig.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvY29uZmlnLnB5) | `100.0% <100.0%> (ø)` | | | [...ssage\_ix\_models/model/material/data\_ammonia\_new.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fmaterial%2Fdata_ammonia_new.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvbWF0ZXJpYWwvZGF0YV9hbW1vbmlhX25ldy5weQ==) | `94.1% <100.0%> (+85.3%)` | :arrow_up: | | [message\_ix\_models/model/material/data\_cement.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fmaterial%2Fdata_cement.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvbWF0ZXJpYWwvZGF0YV9jZW1lbnQucHk=) | `74.2% <100.0%> (+63.2%)` | :arrow_up: | | [message\_ix\_models/model/material/data\_generic.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fmaterial%2Fdata_generic.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvbWF0ZXJpYWwvZGF0YV9nZW5lcmljLnB5) | `98.5% <100.0%> (+83.3%)` | :arrow_up: | | [message\_ix\_models/model/material/data\_petro.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fmaterial%2Fdata_petro.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvbWF0ZXJpYWwvZGF0YV9wZXRyby5weQ==) | `78.8% <100.0%> (+68.7%)` | :arrow_up: | | [...sage\_ix\_models/model/material/data\_power\_sector.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fmaterial%2Fdata_power_sector.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvbWF0ZXJpYWwvZGF0YV9wb3dlcl9zZWN0b3IucHk=) | `85.5% <100.0%> (+78.9%)` | :arrow_up: | | [message\_ix\_models/model/material/data\_steel.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fmaterial%2Fdata_steel.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvbWF0ZXJpYWwvZGF0YV9zdGVlbC5weQ==) | `87.0% <100.0%> (+77.6%)` | :arrow_up: | | [message\_ix\_models/testing/\_\_init\_\_.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Ftesting%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvdGVzdGluZy9fX2luaXRfXy5weQ==) | `79.0% <100.0%> (-16.9%)` | :arrow_down: | | [message\_ix\_models/tests/model/test\_bare.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree&filepath=message_ix_models%2Ftests%2Fmodel%2Ftest_bare.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvdGVzdHMvbW9kZWwvdGVzdF9iYXJlLnB5) | `100.0% <ø> (ø)` | | | ... and [10 more](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa) | | ... and [9 files with indirect coverage changes](https://app.codecov.io/gh/iiasa/message-ix-models/pull/218/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa)
macflo8 commented 1 month ago

I have rewritten the initial commit history of this PR to remove some unnecessary files. I have also refactored the build functions a bit to make it testable. I made a make_spec() function, borrowed from the transport module and adjusted for materials, that is used for running and testing the MESSAGEix-Materials build. Almost all changes are within the material directories except for 2 small changes to make the new tests pass.

The version documentation for MESSAGEix-Materials 1.1.0 is in a separate file in doc/material. The style is based on the pandas-dev whatsnew docs. @khaeru The reference to #130 has also been added.

For some reason that I could not trace, one test is failing for the Ubuntu and Windows Python 3.12 setup. Besides that I think the PR is ready to be merged if @khaeru / @glatterf42 agree.

macflo8 commented 1 month ago

@measrainsey and I were able to resolve the issue with the failing test in the Python 3.12 setups. There were some odd entries in the relation set B.yaml that look like line counters. Apparently the file is parsed differently with Python 3.12 if these line counters are there. After removing them (see commit here), all tests pass. I am not sure if these line counters are needed. Maybe @khaeru can confirm?

khaeru commented 1 month ago

@measrainsey and I were able to resolve the issue with the failing test in the Python 3.12 setups. There were some odd entries in the relation set B.yaml that look like line counters. Apparently the file is parsed differently with Python 3.12 if these line counters are there. After removing them (see commit here), all tests pass. I am not sure if these line counters are needed. Maybe @khaeru can confirm?

Wow, great catch! I think that is mea culpa—they look like scrollback counters from Tmux on my system. I guess they were originally included when I prepared the contents of those files. They are not needed.

Thanks also for the comments above and work done cleaning up this PR. I am in a meeting all week and will likely be able to review/approve on Monday.

macflo8 commented 1 month ago

Thanks for the review and all the suggestions, @glatterf42! I will add a commit that extends the type hints of the material code base. I have adopted your suggestions in the docs and the built html looks good to me now.

I would like to add more tests. However since that requires quite a lot of extra work (see responses to the testing-related suggestions for more details), I would prefer to do that in a follow-up PR. As you say, this PR is already quite big.

Regarding the potential use of GitHub Projects: I think it would be indeed a useful tool, that would improve managing our future developments for MESSAGEix-Materials. But I can just speak for myself as one person that works on MESSAGEix-Materials. We should probably also discuss this with @GamzeUnlu95 and @yiyi1991.

macflo8 commented 1 month ago

Thanks a lot for helping with and reviewing this PR @glatterf42 & @khaeru. I have added a few more commits that address the few minor suggestions that were remaining. I will go ahead and merge now.