Skip to content
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

Migrate message_data.model.transport #207

Merged
merged 1,567 commits into from
Aug 1, 2024
Merged

Migrate message_data.model.transport #207

merged 1,567 commits into from
Aug 1, 2024

Conversation

khaeru
Copy link
Member

@khaeru khaeru commented Jul 29, 2024

This pull request migrates MESSAGEix-Transport and its data/commit history from the private message_data repo.

After #208 is completed, approved, and merged into this branch, CI checks should pass and this PR can be approved and merged.

Preparation

The process roughly uses the migration process from the docs, starting from iiasa/message_data@fff251a4e3c2403f978e99d78e3b64108b357b83 (dev branch). I used the attached replacements.txt

and the following settings in migrate.py:
#: Common args for calls to git-filter-repo in `target_repo`
COMMON = [
    "--force",  # Ignore non-clean history
    # "--debug",  # Show debug information
    "--prune-empty=always",
    # "--prune-degenerate=always",  # COMMENTED
]

…

# -- Configuration ---------------------------------------------------------------------
# Do not edit outside of this section. See the documentation for examples.

S = SOURCE = RepoInfo(
    url="[email protected]:iiasa/message_data.git",
    branch="dev",
)

T = TARGET = RepoInfo(
    url="[email protected]:iiasa/message-ix-models.git",
    branch="main",
)

MOD = "transport"

BATCH = (
    # Use --path-rename to rename several paths and files under them
    dict(
        args=[
            # Module docs
            f"--path-rename={S.base}/model/{MOD}/doc/:doc/{MOD}/",
            # Module data
            f"--path-rename=data/{MOD}/:{T.base}/data/{MOD}/",
            # Module code
            f"--path-rename={S.base}/model/{MOD}/:{T.base}/model/{MOD}/",
            f"--path-rename={S.base}/model/workflow.py:{T.base}/model/workflow.py",
            f"--path-rename={S.base}/projects/engage/workflow.py:{T.base}/project/engage/workflow.py",
            f"--path-rename={S.base}/projects/navigate/__init__.py:{T.base}/project/navigate/__init__.py",
            f"--path-rename={S.base}/projects/transport_futures.py:{T.base}/project/transport_futures.py",
            # Module tests
            f"--path-rename={S.base}/tests/model/{MOD}/cache/:{T.base}/tests/model/{MOD}/",
            f"--path-rename={S.base}/tests/model/{MOD}/:{T.base}/tests/model/{MOD}/",
            # Apply replacements
            "--replace-message=../replacements.txt",
        ],
        message_callback=message_callback,
    ),
    # Use --path to keep only a subset of files and directories
    dict(
        args=[
            "--path=.github/workflows/transport.yaml",
            f"--path=doc/{MOD}/",
            f"--path={T.base}",
        ]
    ),
    # Use --invert-paths to *remove* some specific files
    dict(
        args=[
            "--invert-paths",
            # Proprietary data
            f"--path={T.base}/data/transport/Energyefficiencyindicators_2020-extended.xlsx",
            f"--path={T.base}/data/transport/GEAM_TRP_techinput.xlsx",
            f"--path={T.base}/data/transport/R11/ldv-cost-efficiency.xlsx",
            f"--path={T.base}/data/transport/RoadmapResults_2017.xlsx",
        ],
    ),
)

…plus some other improvements that I will commit separately. This yields rebase-todo.txt. The rebase is performed with git rebase --interactive main, i.e. without --empty=drop. This is to keep the commits that link the history to the many PRs in message_data that developed the code.

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 added enh New features or functionality transport MESSAGEix-Transport variant or transport in the base model labels Jul 29, 2024
@khaeru khaeru self-assigned this Jul 29, 2024
@khaeru khaeru changed the title Migate message_data.model.transport Migrate message_data.model.transport Jul 29, 2024
khaeru added a commit that referenced this pull request Jul 29, 2024
khaeru added 24 commits July 30, 2024 10:22
currently identical to test_demand.test_exo()
needed for corresponding "transport other *" technologies.
khaeru added a commit that referenced this pull request Jul 30, 2024
- Add .testing.preserve_report_callbacks fixture for this and similar cases.
khaeru added a commit that referenced this pull request Jul 30, 2024
khaeru added 3 commits July 31, 2024 12:36
- Mark .transport.base.smooth() as requiring pandas 2.0.
- Mark .transport.build.get_computer() as requiring message_ix 3.8.
- Mark .transport.ldv.capacity_factor() as requiring message_ix 3.6.
- Mark tests using these functions directly or indirectly.
khaeru added a commit that referenced this pull request Jul 31, 2024
khaeru added a commit that referenced this pull request Jul 31, 2024
Manual adjustments for `.model.transport` migration
Copy link

codecov bot commented Jul 31, 2024

Codecov Report

Attention: Patch coverage is 79.53911% with 293 lines in your changes missing coverage. Please review.

Project coverage is 58.8%. Comparing base (4d95695) to head (96c0418).
Report is 1879 commits behind head on main.

Files with missing lines Patch % Lines
message_ix_models/tools/messagev.py 20.4% 97 Missing ⚠️
message_ix_models/model/transport/report.py 48.9% 72 Missing ⚠️
message_ix_models/model/transport/plot.py 74.1% 32 Missing ⚠️
message_ix_models/model/transport/operator.py 79.3% 18 Missing ⚠️
message_ix_models/model/transport/workflow.py 78.9% 16 Missing ⚠️
...sage_ix_models/tests/model/transport/test_build.py 54.2% 16 Missing ⚠️
message_ix_models/model/transport/cli.py 40.0% 12 Missing ⚠️
message_ix_models/model/transport/build.py 91.0% 8 Missing ⚠️
message_ix_models/model/transport/ikarus.py 68.1% 7 Missing ⚠️
message_ix_models/model/transport/structure.py 89.5% 5 Missing ⚠️
... and 6 more
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #207     +/-   ##
=======================================
+ Coverage   52.3%   58.8%   +6.5%     
=======================================
  Files        145     194     +49     
  Lines      11357   15159   +3802     
=======================================
+ Hits        5943    8922   +2979     
- Misses      5414    6237    +823     
Files with missing lines Coverage Δ
message_ix_models/cli.py 93.4% <ø> (ø)
message_ix_models/model/transport/CHN_IND.py 30.3% <100.0%> (ø)
message_ix_models/model/transport/__init__.py 100.0% <ø> (ø)
message_ix_models/model/transport/callback.py 28.5% <ø> (ø)
message_ix_models/model/transport/data.py 94.2% <100.0%> (ø)
message_ix_models/model/transport/demand.py 100.0% <100.0%> (ø)
message_ix_models/model/transport/emission.py 95.2% <100.0%> (ø)
message_ix_models/model/transport/factor.py 90.9% <100.0%> (ø)
message_ix_models/model/transport/freight.py 100.0% <100.0%> (ø)
message_ix_models/model/transport/groups.py 97.0% <100.0%> (ø)
... and 41 more

... and 3 files with indirect coverage changes

@khaeru khaeru requested a review from glatterf42 July 31, 2024 12:25
@khaeru
Copy link
Member Author

khaeru commented Jul 31, 2024

The test coverage of the added code is about 80%; compare with .material and .water here at about 10% each.

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.

Overall, this PR looks great to me :)
I've noted some changes I would like to see, most of which are fine in follow-up PRs, though. The one thing I would like to request is that we should really avoid importing from message_data with code in here.
Once that is done and no tests break because of it, I'll approve :)

.github/workflows/transport.yaml Show resolved Hide resolved
doc/transport/input.rst Show resolved Hide resolved
doc/transport/input.rst Show resolved Hide resolved
message_ix_models/data/transport/technology.yaml Outdated Show resolved Hide resolved
message_ix_models/model/transport/CHN_IND.py Show resolved Hide resolved
message_ix_models/model/transport/roadmap.py Show resolved Hide resolved
message_ix_models/model/workflow.py Show resolved Hide resolved
message_ix_models/tests/model/transport/__init__.py Outdated Show resolved Hide resolved
@khaeru khaeru requested a review from glatterf42 August 1, 2024 09:07
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 for addressing my comments so quickly. With several follow-up issues opened and the intention to address them somewhat soon, I'm fine with approving this.

@khaeru
Copy link
Member Author

khaeru commented Aug 1, 2024

Thanks for the review!

@khaeru khaeru merged commit 2fcae67 into main Aug 1, 2024
26 checks passed
@khaeru khaeru deleted the migrate/transport branch August 1, 2024 09:28
@khaeru khaeru restored the migrate/transport branch August 1, 2024 09:28
@glatterf42 glatterf42 deleted the migrate/transport branch August 1, 2024 09:45
khaeru added a commit that referenced this pull request Aug 2, 2024
- Ensure new modules from #207 are packaged.
- Exclude .github etc. from distributions (parallel to
  iiasa/message_ix).
khaeru added a commit that referenced this pull request Aug 2, 2024
- Ensure new modules from #207 are packaged.
- Exclude .github etc. from distributions (parallel to
  iiasa/message_ix).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enh New features or functionality transport MESSAGEix-Transport variant or transport in the base model
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants