Skip to content

Handle adding empty optimization data #169

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 2 commits into
base: enh/make-equation-indexsets-optional
Choose a base branch
from

Conversation

glatterf42
Copy link
Member

In message_ix, we may iterate over all variables etc of one Scenario (backed by a Run) to add them to another Scenario (backed by another Run), which may include adding empty data ({} or pd.DataFrame()) to them. This should be working already as only the combination of existing and new data are validated.
However, this led to an error for indexsets because adding an empty list violates one of the UniqueConstraints for their underlying tables. So I was adjusting that already and figured the remaining items would also benefit from tests covering this case.
On top of which, I figure we don't need to bother the DB or validate data when adding empty data. This PR avoids that, which should make the code more performant.

NOTE: I'm also using this branch right now for some temporary debug commits.

@glatterf42 glatterf42 added the enhancement New feature or request label Mar 27, 2025
@glatterf42 glatterf42 requested a review from meksor March 27, 2025 12:18
@glatterf42 glatterf42 self-assigned this Mar 27, 2025
@glatterf42 glatterf42 force-pushed the enh/handle-empty-optimization-data-addition branch from d0642ce to 28d870e Compare March 27, 2025 12:20
Copy link

codecov bot commented Mar 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.7%. Comparing base (f907393) to head (71d71ec).

Additional details and impacted files
@@                         Coverage Diff                          @@
##           enh/make-equation-indexsets-optional    #169   +/-   ##
====================================================================
  Coverage                                  88.6%   88.7%           
====================================================================
  Files                                       223     223           
  Lines                                      8200    8219   +19     
====================================================================
+ Hits                                       7272    7291   +19     
  Misses                                      928     928           
Files with missing lines Coverage Δ
ixmp4/data/db/optimization/equation/repository.py 98.8% <100.0%> (+<0.1%) ⬆️
ixmp4/data/db/optimization/indexset/repository.py 98.5% <100.0%> (+<0.1%) ⬆️
ixmp4/data/db/optimization/parameter/repository.py 97.0% <100.0%> (+0.2%) ⬆️
ixmp4/data/db/optimization/table/repository.py 98.7% <100.0%> (+<0.1%) ⬆️
ixmp4/data/db/optimization/utils.py 100.0% <100.0%> (ø)
ixmp4/data/db/optimization/variable/repository.py 98.9% <100.0%> (+<0.1%) ⬆️
🚀 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/handle-empty-optimization-data-addition branch 5 times, most recently from 71d71ec to 73e7900 Compare April 2, 2025 09:27
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