Skip to content

Manual adjustments for .engage.workflow migration #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 16, 2025

Conversation

khaeru
Copy link
Member

@khaeru khaeru commented May 14, 2025

This branch makes additional adjustments to the branch for #350 after the semi-automated migration process.

These include:

  • Adjust imports and data paths
  • Add type hints.
  • Format docstrings according to the code style.
  • Use ScenarioInfo instead of get_nodes(), get_optimization_years().
  • New tests for the added .tools submodules.

How to review

PR checklist

  • Continuous integration checks all ✅
  • Add or expand tests; coverage checks both ✅
  • Add, expand, or update documentation.
  • Update doc/whatsnew.

@khaeru khaeru self-assigned this May 14, 2025
@khaeru khaeru added the enh New features or functionality label May 14, 2025
@khaeru khaeru force-pushed the migrate/engage-tools-cleanup branch from e370556 to e20d9fd Compare May 15, 2025 06:43
Copy link

codecov bot commented May 15, 2025

Codecov Report

Attention: Patch coverage is 89.80583% with 21 lines in your changes missing coverage. Please review.

Please upload report for BASE (migrate/engage-tools@630d110). Learn more about missing BASE report.

Files with missing lines Patch % Lines
message_ix_models/project/navigate/workflow.py 50.0% 7 Missing ⚠️
message_ix_models/model/buildings/__init__.py 62.5% 6 Missing ⚠️
...essage_ix_models/tools/add_AFOLU_CO2_accounting.py 75.0% 2 Missing ⚠️
message_ix_models/tools/add_emission_trajectory.py 66.6% 2 Missing ⚠️
message_ix_models/model/buildings/cli.py 0.0% 1 Missing ⚠️
message_ix_models/project/navigate/cli.py 0.0% 1 Missing ⚠️
message_ix_models/project/navigate/report.py 80.0% 1 Missing ⚠️
message_ix_models/tools/remove_emission_bounds.py 90.0% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##             migrate/engage-tools    #351   +/-   ##
======================================================
  Coverage                        ?   71.1%           
======================================================
  Files                           ?     243           
  Lines                           ?   19460           
  Branches                        ?       0           
======================================================
  Hits                            ?   13851           
  Misses                          ?    5609           
  Partials                        ?       0           
Files with missing lines Coverage Δ
message_ix_models/model/buildings/build.py 44.7% <100.0%> (ø)
message_ix_models/model/buildings/rc_afofi.py 18.8% <100.0%> (ø)
message_ix_models/model/buildings/report.py 48.9% <100.0%> (ø)
message_ix_models/model/buildings/sturm.py 21.6% <100.0%> (ø)
message_ix_models/project/navigate/__init__.py 88.6% <100.0%> (ø)
message_ix_models/project/navigate/wp2/util.py 98.0% <100.0%> (ø)
message_ix_models/testing/__init__.py 80.1% <ø> (ø)
message_ix_models/tests/model/test_buildings.py 92.1% <100.0%> (ø)
..._ix_models/tests/project/navigate/test_wp2_util.py 100.0% <100.0%> (ø)
message_ix_models/tests/project/test_navigate.py 60.7% <100.0%> (ø)
... and 15 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@khaeru khaeru force-pushed the migrate/engage-tools-cleanup branch 5 times, most recently from ae577d6 to 5b6958e Compare May 16, 2025 07:17
khaeru added 2 commits May 16, 2025 09:24
- Format docstrings according to code style, wrap at 88 characters.
- Correct misspellings.
- Add type hints.
- Use Scenario.transact() where possible.
- Use f-strings.
- Use ScenarioInfo.Y instead of get_optimization_years().
- Use ScenarioInfo.N instead of get_nodes().
- Remove if __name__ == "__main__" blocks.
@khaeru khaeru force-pushed the migrate/engage-tools-cleanup branch from 5b6958e to 85bc5a3 Compare May 16, 2025 07:26
khaeru added 8 commits May 16, 2025 09:50
- Adjust imports.
- Type hint test functions.
- Use parametrized generics from default collections.
- Import from collections.abc instead of typing.
- Copied from: https://github.com/iiasa/navigate-workflow
  - file definitions/scenario/scenarios.yaml
  - commit abb23814b7de3618ec4287ec014ddfce3e07c030 (2023-04-21)
- Adjust code that reads this file to use the new location.
@khaeru khaeru force-pushed the migrate/engage-tools-cleanup branch from 85bc5a3 to 3156c69 Compare May 16, 2025 07:51
- Use path_fallback in .navigate.wp2.utils.
- Change load_private_data → load_package_data in
  .buildings.build.load_config().
@khaeru khaeru force-pushed the migrate/engage-tools-cleanup branch from 3156c69 to 0054ac1 Compare May 16, 2025 08:06
@khaeru khaeru changed the base branch from main to migrate/engage-tools May 16, 2025 08:43
@khaeru khaeru force-pushed the migrate/engage-tools-cleanup branch from 0054ac1 to 108a3b0 Compare May 16, 2025 08:44
@khaeru khaeru marked this pull request as ready for review May 16, 2025 08:46
@khaeru khaeru requested a review from glatterf42 as a code owner May 16, 2025 08:46
@khaeru khaeru requested a review from yiyi1991 May 16, 2025 08:46
Copy link
Member

@glatterf42 glatterf42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me :)


from message_ix import Scenario

from message_ix_models import Context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like all the new type hints :)
I'm just wondering: what's the benefit of importing these only if TYPE_CHECKING? Does this save actual runtime for the tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it has any performance effect.

I usually follow the heuristic "things used only for type checking in a module are imported in a TYPE_CHECKING block". The corollary is that the top-level imports contain only things actually referenced/called in the module.

This habit has helped me a number of times to avoid issues with circular imports.

Comment on lines +87 to +90
This documentation and the related code was migrated from :mod:`message_data` ``dev``
branch as of commit 8213e6c (2025-05-08) in :pull:`350`.
It does not reflect further changes made on the :mod:`message_data` ``main`` branch,
other related branches, or in forks or other repositories.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is clear to me, but I might not be the best to judge this since I already understood this concept when I migrated the legacy reporting version.

@khaeru khaeru merged commit 5367ff4 into migrate/engage-tools May 16, 2025
24 checks passed
@khaeru khaeru deleted the migrate/engage-tools-cleanup branch May 16, 2025 09:55
@khaeru khaeru added this to the 2025-06 milestone May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enh New features or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants