Skip to content

Update add_AFOLU_CO2_accounting() per message_data:ssp_dev #354

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

khaeru
Copy link
Member

@khaeru khaeru commented May 19, 2025

Per this thread (Slack, private), the version of add_AFOLU_CO2_accounting() on the message_data dev branch, migrated here in #350, no longer works with current scenarios like ixmp://ixmp-dev/SSP_SSP1_v5.0/baseline_DEFAULT_step_13. This manifests as breakage in the .model.transport workflow, with exceptions like:

ComputationError: computing 'SSP5 policy with tax' using:

<Task 'SSP5 policy with tax' <Step tax_emission()>(...)>

Use Computer.describe(...) to trace the computation.

Computation traceback:
  File "/home/runner/actions-runner/_work/message_data/message_data/.venv/lib/python3.13/site-packages/message_ix_models/workflow.py", line 125, in __call__
    result = self.action(context, s, **self.kwargs)
  File "/home/runner/actions-runner/_work/message_data/message_data/.venv/lib/python3.13/site-packages/message_ix_models/model/transport/workflow.py", line 161, in tax_emission
    scenario = engage_workflow.step_0(context, scenario)
  File "/home/runner/actions-runner/_work/message_data/message_data/.venv/lib/python3.13/site-packages/message_data/projects/engage/workflow.py", line 188, in step_0
    add_AFOLU_CO2_accounting(scenario, **kw)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/home/runner/actions-runner/_work/message_data/message_data/.venv/lib/python3.13/site-packages/message_data/tools/utilities/add_AFOLU_CO2_accounting.py", line 65, in add_AFOLU_CO2_accounting
    raise ValueError("'land_output' not available for commodity 'LU_CO2'")
ValueError: 'land_output' not available for commodity 'LU_CO2'

This PR updates the version here to match the version on message_data ssp_dev branch, thus partly addresses #275.

Some immediate observations about changes to the code:

  • The previous version of the function modified and parameters relation_activity, input. The new version of the code does not.
  • The function previously constructed data to be added by reference to the scenario structure. Now the added data is derived from existing scenario contents.
  • The function previously passed the constraint_value parameter to add_CO2_emission_constraint(). Now this parameter is totally unused.
  • The glb parameter is renamed to glb_reg, but is now ignored.
  • The test added in Manual adjustments for .engage.workflow migration #351 fails.
  • Thus the docstring of the function, which has not been updated and references "relations" in the summary and body, appears to be out of date and no longer an accurate description.

The PR also tries to address these changes.

How to review

TBA

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 19, 2025
@khaeru khaeru added bug Something isn't working p:SSP-2024 2024 SSP updates and ScenarioMIP labels May 19, 2025
Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.0%. Comparing base (4bc1cfa) to head (e2a3817).
Report is 3 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #354   +/-   ##
=====================================
  Coverage   72.0%   72.0%           
=====================================
  Files        243     243           
  Lines      19451   19457    +6     
=====================================
+ Hits       14011   14021   +10     
+ Misses      5440    5436    -4     
Files with missing lines Coverage Δ
message_ix_models/tests/test_tools.py 78.1% <100.0%> (+4.4%) ⬆️
...essage_ix_models/tools/add_AFOLU_CO2_accounting.py 95.6% <100.0%> (+7.8%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@khaeru khaeru added this to the 2025-07 milestone May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p:SSP-2024 2024 SSP updates and ScenarioMIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant