Skip to content

Update dependencies and fix breakages from pyomo 6.10 - #280

Merged
ParticularlyPythonicBS merged 2 commits into
unstablefrom
update_pyomo_and_fix
Mar 24, 2026
Merged

Update dependencies and fix breakages from pyomo 6.10#280
ParticularlyPythonicBS merged 2 commits into
unstablefrom
update_pyomo_and_fix

Conversation

@ParticularlyPythonicBS

@ParticularlyPythonicBSParticularlyPythonicBS commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator
  • Updated dependencies to latest versions
  • Replaced sparse_iterkeys() with sparse_keys() to comply with pyomo 6.10 deprecation
  • Wrapped critical sparse_keys() calls in set() in temoa/components/technology.py to ensure a stable lookups

Summary by CodeRabbit

  • Improvements

    • Increased consistency and stability across capacity, commodity, cost, emissions, time, limits, reserves, and technology processing by unifying internal index handling.
    • Minor reliability and performance improvements that reduce intermittent index-related inconsistencies.
  • Bug Fixes

    • Improved detection and messaging for invalid capacity-factor configurations.
  • Tests

    • Updated legacy full-run test to align with revised internal index handling.

@coderabbitai

coderabbitaiBot commented Mar 17, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)

Walkthrough

Replaced Pyomo's sparse_iterkeys() calls with sparse_keys() across the codebase. Only the enumeration API for sparse parameters/sets changed; tuple unpacking, filters, arithmetic, and control flow in the affected loops remain unchanged.

Changes

Cohort / File(s)Summary
Core internal polling
temoa/_internal/table_data_puller.py
Switched sparse_iterkeys()sparse_keys() in polling loops for construction_input, cost tables, and emissions; iteration API changed but loop logic preserved.
Components — capacity / technology / time / limits / costs / emissions / geography / reserves / commodities
temoa/components/capacity.py, temoa/components/technology.py, temoa/components/time.py, temoa/components/limits.py, temoa/components/costs.py, temoa/components/emissions.py, temoa/components/geography.py, temoa/components/reserves.py, temoa/components/commodities.py
Replaced sparse-key iteration API across many component modules (efficiency, existing_capacity, cost_/emission_, reserve margins, time segments, etc.). Some sites now materialize key sets via set(...sparse_keys()). No other logic or filters were changed.
Model checking & validators
temoa/model_checking/network_model_data.py, temoa/model_checking/pricing_check.py, temoa/model_checking/validators.py
Replaced sparse_iterkeys() with sparse_keys() when enumerating demand, linked techs, costs, efficiencies, and reserve margins; downstream validation logic unchanged.
Tests
tests/test_full_runs.py
Updated test to compute expected efficiency index size from efficiency_param.sparse_keys() instead of sparse_iterkeys().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 60.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title 'Update dependencies and fix breakages from pyomo 6.10' directly describes the main changes: dependency updates and fixing issues caused by Pyomo 6.10 compatibility, which aligns with the primary changes throughout the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update_pyomo_and_fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ParticularlyPythonicBSParticularlyPythonicBS added Maintenance Code quality fixes and deprecation management bugfix labels Mar 17, 2026

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
temoa/components/capacity.py (1)

652-654: ⚠️ Potential issue | 🟡 Minor

Inconsistent API: sparse_iterkeys() not updated to sparse_keys().

This line still uses the deprecated sparse_iterkeys() while all other occurrences in this file and across the PR have been updated to sparse_keys(). This should be updated for consistency with the Pyomo 6.10 migration.

Proposed fix
- for r, _e, t, v in model.emission_end_of_life.sparse_iterkeys():+ for r, _e, t, v in model.emission_end_of_life.sparse_keys():
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@temoa/components/capacity.py` around lines 652 - 654, The loop uses the
deprecated iterator method model.emission_end_of_life.sparse_iterkeys(); replace
this call with the updated API model.emission_end_of_life.sparse_keys() in the
for loop that checks (r, t, v) in model.retirement_periods and updates
model.used_techs.add(t) so the code consistently uses Pyomo 6.10's sparse_keys()
method.
temoa/components/technology.py (1)

448-456: ⚠️ Potential issue | 🟡 Minor

Inconsistent API: sparse_iterkeys() not updated to sparse_keys().

This line still uses the deprecated sparse_iterkeys() while all other occurrences in this file and across the PR have been updated to sparse_keys(). This should be updated for consistency with the Pyomo 6.10 migration.

Proposed fix
- for r, t, v in model.existing_capacity.sparse_iterkeys():+ for r, t, v in model.existing_capacity.sparse_keys():
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@temoa/components/technology.py` around lines 448 - 456, The loop uses the
deprecated model.existing_capacity.sparse_iterkeys() API; update it to
model.existing_capacity.sparse_keys() in the loop that unpacks (r, t, v) and
computes cap using value(model.existing_capacity[r, t, v]) so behavior is
unchanged. Locate the for-loop referencing sparse_iterkeys() in the technology
component (around the block that logs non-positive existing capacity) and
replace sparse_iterkeys() with sparse_keys() while keeping the unpacking and
subsequent logic (variables r, t, v, cap, logger.warning, continue) intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@temoa/components/technology.py`:
- Around line 63-64: There are duplicate loops iterating
model.existing_capacity.sparse_keys() and setting
model.is_survival_curve_process[r, t, v] = False twice; remove the redundant
loop so each (r, t, v) is initialized only once (keep a single loop that
iterates model.existing_capacity.sparse_keys() and assigns
model.is_survival_curve_process[r, t, v] = False). Apply the same removal for
the other duplicated occurrences noted (the similar duplicate around the indices
handling), ensuring only one initialization loop exists for
model.is_survival_curve_process per key source.
---
Outside diff comments:
In `@temoa/components/capacity.py`:
- Around line 652-654: The loop uses the deprecated iterator method
model.emission_end_of_life.sparse_iterkeys(); replace this call with the updated
API model.emission_end_of_life.sparse_keys() in the for loop that checks (r, t,
v) in model.retirement_periods and updates model.used_techs.add(t) so the code
consistently uses Pyomo 6.10's sparse_keys() method.
In `@temoa/components/technology.py`:
- Around line 448-456: The loop uses the deprecated
model.existing_capacity.sparse_iterkeys() API; update it to
model.existing_capacity.sparse_keys() in the loop that unpacks (r, t, v) and
computes cap using value(model.existing_capacity[r, t, v]) so behavior is
unchanged. Locate the for-loop referencing sparse_iterkeys() in the technology
component (around the block that logs non-positive existing capacity) and
replace sparse_iterkeys() with sparse_keys() while keeping the unpacking and
subsequent logic (variables r, t, v, cap, logger.warning, continue) intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cdbcb44b-f44d-4d8f-b92a-2da475908247

📥 Commits

Reviewing files that changed from the base of the PR and between 5baa092 and 1383bd3.

⛔ Files ignored due to path filters (2)
  • stubs/pyomo/core/base/param.pyi is excluded by !stubs/**
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • temoa/_internal/table_data_puller.py
  • temoa/components/capacity.py
  • temoa/components/commodities.py
  • temoa/components/costs.py
  • temoa/components/emissions.py
  • temoa/components/geography.py
  • temoa/components/limits.py
  • temoa/components/reserves.py
  • temoa/components/technology.py
  • temoa/components/time.py
  • temoa/model_checking/network_model_data.py
  • temoa/model_checking/pricing_check.py
  • temoa/model_checking/validators.py
  • tests/test_full_runs.py

Comment threadtemoa/components/technology.py
@ParticularlyPythonicBS
ParticularlyPythonicBSforce-pushed the update_pyomo_and_fix branch 6 times, most recently from 38fa269 to 60ee22dCompareMarch 23, 2026 14:45
@ParticularlyPythonicBS
ParticularlyPythonicBS merged commit 11be18a into unstableMar 24, 2026
12 checks passed
@ParticularlyPythonicBS
ParticularlyPythonicBS deleted the update_pyomo_and_fix branch March 24, 2026 14:04
@coderabbitaicoderabbitaiBot mentioned this pull request Mar 25, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfixMaintenanceCode quality fixes and deprecation management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@ParticularlyPythonicBS