iiasa / message-ix-models

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

Clean up Materials migration branch #189

Closed macflo8 closed 4 months ago

macflo8 commented 5 months ago

This separate branch includes commits to tidy and make MESSAGEix-Materials run on message-ix-models.

How to review

  1. Check the removed files and changed code pieces
  2. Build-Solve-Report MESSAGEix-Materials

PR checklist

~- [ ] Continuous integration checks all ✅~ Not possible due to missing tests

khaeru commented 5 months ago

@macflo8, this and #188 look good, thank you!

One thing I notice is that the commit messages do not conform to our code style (see the first bullet).

For this -tidy branch with a few commits, it is easy to git rebase -i and use the r/reword command to adjust.

glatterf42 commented 4 months ago

@macflo8, I've migrated the required functions now and cleaned up several imports. However, there's still work left to be done: the code quality check (as you analyzed) should be the first, but you also have a doc.rst file in message_ix_models/model/material. These files should generally live under doc/, in this case probably doc/material (since we also have doc/water. This file in particular is calling automodule for several message_data.model.material functions. These should all be migrated now, so please adapt to the new locations.

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 11.36108% with 1576 lines in your changes missing coverage. Please review.

Project coverage is 52.2%. Comparing base (9d9fa6c) to head (cc2e59f).

Files Patch % Lines
...x_models/util/compat/message_data/calibrate_vre.py 5.5% 340 Missing :warning:
.../compat/message_data/change_technology_lifetime.py 2.5% 268 Missing :warning:
...ge_data/manual_updates_ENGAGE_SSP2_v417_to_v418.py 8.0% 195 Missing :warning:
...l/compat/message_data/calibrate_UE_gr_to_demand.py 9.6% 94 Missing :warning:
message_ix_models/model/material/data_aluminum.py 12.7% 89 Missing :warning:
message_ix_models/model/material/data_steel.py 8.9% 81 Missing :warning:
message_ix_models/model/material/data_methanol.py 0.0% 76 Missing :warning:
...pat/message_data/calibrate_UE_share_constraints.py 10.8% 74 Missing :warning:
...sage_ix_models/model/material/data_power_sector.py 5.4% 70 Missing :warning:
...at/message_data/check_scenario_fix_and_inv_cost.py 6.2% 60 Missing :warning:
... and 12 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## migrate-materials_2024-W17 #189 +/- ## ============================================================ - Coverage 54.8% 52.2% -2.7% ============================================================ Files 128 141 +13 Lines 10011 11342 +1331 ============================================================ + Hits 5491 5921 +430 - Misses 4520 5421 +901 ``` | [Files](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?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/cli.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?src=pr&el=tree&filepath=message_ix_models%2Fcli.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvY2xpLnB5) | `93.4% <ø> (ø)` | | | [message\_ix\_models/model/material/build.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fmaterial%2Fbuild.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvbWF0ZXJpYWwvYnVpbGQucHk=) | `17.1% <100.0%> (+17.1%)` | :arrow_up: | | [...age\_ix\_models/util/compat/message\_data/\_\_init\_\_.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?src=pr&el=tree&filepath=message_ix_models%2Futil%2Fcompat%2Fmessage_data%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvdXRpbC9jb21wYXQvbWVzc2FnZV9kYXRhL19faW5pdF9fLnB5) | `100.0% <100.0%> (ø)` | | | [...s/util/compat/message\_data/get\_historical\_years.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?src=pr&el=tree&filepath=message_ix_models%2Futil%2Fcompat%2Fmessage_data%2Fget_historical_years.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvdXRpbC9jb21wYXQvbWVzc2FnZV9kYXRhL2dldF9oaXN0b3JpY2FsX3llYXJzLnB5) | `20.0% <ø> (ø)` | | | [...ge\_ix\_models/util/compat/message\_data/get\_nodes.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?src=pr&el=tree&filepath=message_ix_models%2Futil%2Fcompat%2Fmessage_data%2Fget_nodes.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvdXRpbC9jb21wYXQvbWVzc2FnZV9kYXRhL2dldF9ub2Rlcy5weQ==) | `100.0% <ø> (ø)` | | | [...util/compat/message\_data/get\_optimization\_years.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?src=pr&el=tree&filepath=message_ix_models%2Futil%2Fcompat%2Fmessage_data%2Fget_optimization_years.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvdXRpbC9jb21wYXQvbWVzc2FnZV9kYXRhL2dldF9vcHRpbWl6YXRpb25feWVhcnMucHk=) | `28.5% <ø> (ø)` | | | [message\_ix\_models/model/material/data\_generic.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?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) | `15.1% <57.1%> (+15.1%)` | :arrow_up: | | [message\_ix\_models/model/material/data\_cement.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?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=) | `10.9% <55.5%> (+10.9%)` | :arrow_up: | | [message\_ix\_models/model/material/data\_buildings.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fmaterial%2Fdata_buildings.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvbWF0ZXJpYWwvZGF0YV9idWlsZGluZ3MucHk=) | `0.0% <0.0%> (ø)` | | | [...l/material/material\_demand/material\_demand\_calc.py](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?src=pr&el=tree&filepath=message_ix_models%2Fmodel%2Fmaterial%2Fmaterial_demand%2Fmaterial_demand_calc.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa#diff-bWVzc2FnZV9peF9tb2RlbHMvbW9kZWwvbWF0ZXJpYWwvbWF0ZXJpYWxfZGVtYW5kL21hdGVyaWFsX2RlbWFuZF9jYWxjLnB5) | `18.8% <45.4%> (ø)` | | | ... and [18 more](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iiasa) | | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/iiasa/message-ix-models/pull/189/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 4 months ago

Thanks, @glatterf42 for taking care of that 🙏🏻 I will have a look at the materials docs.

macflo8 commented 4 months ago

The materials doc file is now moved and the code quality checks are passing. Do you agree to merge this PR @khaeru @glatterf42 ?

khaeru commented 4 months ago

Looking at step (9) in our migration guide:

  1. Merge the clean-up branch from (7) into (6), and then (6) into main.

… I see the following things:

Once we address these items, then we can make a simultaneous approval of both PRs, and then perform step (9).

macflo8 commented 4 months ago

Thanks @khaeru!

khaeru commented 4 months ago
  • I was not sure about the "Update doc/whatsnew". Should we update this?

Please have a look at these past commits to the file, particularly this one and this one. Something similar and short should be fine.

Please add the commit to this branch; then it will automatically be included for #188 as well.

glatterf42 commented 4 months ago

Thanks, this is looking good now. Please open a new issue to mention and track that the materials team will provide tests at a later date (ideally within a few weeks or months).

@khaeru, would we want to exclude the new files from coverage (to keep the test coverage apparently high) or are we fine with the reduction in coverage (as we were for the nexus module)?

Either way, I think we can then approve this PR and merging this branch to the first migration branch hopefully resolves the code quality issues there, too.

khaeru commented 4 months ago

@khaeru, would we want to exclude the new files from coverage (to keep the test coverage apparently high) or are we fine with the reduction in coverage (as we were for the nexus module)?

I think we ought to be honest, so better to accept the reduction.

macflo8 commented 4 months ago

The tracking issue for tests and other pending items is now linked in the PR checklist. I will merge the PR once you approve @glatterf42 @khaeru.