Skip to content

Update dependencies and fix breakages from pyomo 6.10#280

Open
ParticularlyPythonicBS wants to merge 3 commits intounstablefrom
update_pyomo_and_fix
Open

Update dependencies and fix breakages from pyomo 6.10#280
ParticularlyPythonicBS wants to merge 3 commits intounstablefrom
update_pyomo_and_fix

Conversation

@ParticularlyPythonicBS
Copy link
Member

@ParticularlyPythonicBS ParticularlyPythonicBS commented Mar 17, 2026

  • 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

Release Notes

  • Bug Fixes

    • Enhanced error detection for invalid capacity factor configurations with improved error messaging.
  • Improvements

    • Optimized internal model data structure handling across capacity, commodity, cost, and emissions components.
    • Refined model validation logic for improved data consistency checks.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b3bc4539-fa2f-4cac-b623-397a0cb5f28d

📥 Commits

Reviewing files that changed from the base of the PR and between 7f7ff86 and 5baa092.

⛔ 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

Walkthrough

This PR systematically replaces all usages of the sparse_iterkeys() API method with sparse_keys() across the codebase. Changes are primarily API method replacements with minimal functional modifications, except for enhancements to error handling and logic in a few components.

Changes

Cohort / File(s) Summary
Components – API Migration (Sparse Keys)
temoa/components/emissions.py, temoa/components/geography.py, temoa/components/reserves.py, temoa/components/time.py
Replaced sparse_iterkeys() with sparse_keys() for key iteration across sparse structures. No control flow or logic changes.
Components – API Migration + Enhanced Validation
temoa/components/capacity.py
Replaced sparse_iterkeys() with sparse_keys() across capacity-related loops. Additionally strengthened error handling in capacity_factor_process by logging and raising ValueError on invalid (r, p, t, v) combinations instead of silently continuing.
Components – API Migration + Logic Expansion
temoa/components/commodities.py
Replaced sparse_iterkeys() with sparse_keys() in commodity and demand iterations. Extended tech_demand population logic to include technologies where output commodity is in model.commodity_demand.
Components – API Migration (Costs & Emissions Indices)
temoa/components/costs.py, temoa/components/limits.py
Replaced sparse_iterkeys() with sparse_keys() across cost, emission, and constraint index builders. Adjusted filtering logic conditions to work with new key accessor method.
Components – API Migration + Set Materialization
temoa/components/technology.py
Replaced sparse_iterkeys() with sparse_keys(), but now wraps results in set() before iteration. This materializes keys and alters evaluation order compared to direct iteration.
Internal Modules – API Migration
temoa/_internal/table_data_puller.py
Replaced sparse_iterkeys() with sparse_keys() across poll_flow_results, poll_cost_results, and poll_emissions functions. Iteration semantics preserved.
Model Checking – API Migration
temoa/model_checking/network_model_data.py, temoa/model_checking/validators.py
Replaced sparse_iterkeys() with sparse_keys() for model.demand, model.linked_techs, and reserve margin iterations.
Model Checking – API Migration + Tuple Unpacking Adjustments
temoa/model_checking/pricing_check.py
Replaced sparse_iterkeys() with sparse_keys() and adjusted tuple unpacking to match new key shapes. Updated efficiency_rtv and cost-related dictionary constructions to align with sparse_keys() return format.
Tests – API Migration
tests/test_full_runs.py
Replaced sparse_iterkeys() with sparse_keys() in efficiency parameter size computation for test assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

bugfix, Maintenance

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.97% 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 name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main objective of the PR: updating dependencies and fixing compatibility issues from Pyomo 6.10 by replacing deprecated sparse_iterkeys() with sparse_keys().

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update_pyomo_and_fix
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can get early access to new features in CodeRabbit.

Enable the early_access setting to enable early access features such as new models, tools, and more.

@ParticularlyPythonicBS ParticularlyPythonicBS added Maintenance Code quality fixes and deprecation management bugfix labels Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Maintenance Code quality fixes and deprecation management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant