Skip to content

Remove data from linked items when removing data from indexset items #171

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

Open
wants to merge 6 commits into
base: enh/handle-empty-optimization-data-addition
Choose a base branch
from

Conversation

glatterf42
Copy link
Member

message_ix.Scenario.remove_set() expects that when an element from an IndexSet is removed, all corresponding keys from other optimization items (i.e. keys that contain this element from items linked the IndexSet) are also removed (because otherwise, the linked items would contain invalid data). This PR adds the functionality to provide the same behavior.

However, since I'm not a big of silently doing stuff in the background, our version of this comes with a flag to disable it. The default for this is True right now, i.e. to remove related data, but this is mainly because the function will for now mostly be called from message_ix, which needs this default. I'm happy to swap the default to False and have the shim layer request True every time it needs it if you think that's better.

The PR includes some preparatory cleanups and notes.

@glatterf42 glatterf42 added the enhancement New feature or request label Apr 4, 2025
@glatterf42 glatterf42 requested a review from meksor April 4, 2025 09:28
@glatterf42 glatterf42 self-assigned this Apr 4, 2025
Copy link

codecov bot commented Apr 4, 2025

Codecov Report

Attention: Patch coverage is 95.28302% with 5 lines in your changes missing coverage. Please review.

Project coverage is 88.7%. Comparing base (73e7900) to head (1323f3d).

Files with missing lines Patch % Lines
ixmp4/data/api/optimization/equation.py 80.0% 1 Missing ⚠️
ixmp4/data/api/optimization/variable.py 80.0% 1 Missing ⚠️
ixmp4/data/db/optimization/equation/repository.py 94.1% 1 Missing ⚠️
ixmp4/data/db/optimization/indexset/repository.py 97.4% 1 Missing ⚠️
ixmp4/data/db/optimization/variable/repository.py 94.1% 1 Missing ⚠️
Additional details and impacted files
@@                             Coverage Diff                             @@
##           enh/handle-empty-optimization-data-addition    #171   +/-   ##
===========================================================================
  Coverage                                         88.6%   88.7%           
===========================================================================
  Files                                              223     223           
  Lines                                             8210    8284   +74     
===========================================================================
+ Hits                                              7282    7351   +69     
- Misses                                             928     933    +5     
Files with missing lines Coverage Δ
ixmp4/core/optimization/equation.py 93.3% <100.0%> (ø)
ixmp4/core/optimization/indexset.py 91.9% <ø> (ø)
ixmp4/core/optimization/variable.py 93.4% <100.0%> (ø)
ixmp4/data/abstract/optimization/equation.py 97.1% <100.0%> (ø)
ixmp4/data/abstract/optimization/indexset.py 96.5% <ø> (ø)
ixmp4/data/abstract/optimization/variable.py 97.1% <100.0%> (ø)
ixmp4/data/api/optimization/indexset.py 97.8% <100.0%> (ø)
ixmp4/data/db/optimization/base.py 100.0% <100.0%> (ø)
ixmp4/data/db/optimization/equation/model.py 100.0% <ø> (ø)
ixmp4/data/db/optimization/parameter/model.py 97.4% <100.0%> (ø)
... and 11 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@glatterf42 glatterf42 force-pushed the enh/remove-linked-items-when-removing-indexset-items branch 3 times, most recently from 86c4576 to 89dffd1 Compare April 4, 2025 09:57
* ...when removing data from an IndexSet
* ...and set this as default (but allow deactivation via flag)
@glatterf42 glatterf42 force-pushed the enh/remove-linked-items-when-removing-indexset-items branch from 89dffd1 to 1323f3d Compare April 4, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant