Fix v4 migrator: route annual techs' split rows to the annual split tables#351
Fix v4 migrator: route annual techs' split rows to the annual split tables#351SutubraResearch wants to merge 2 commits into
Conversation
The v3->v4 migrator routed TechInputSplit and TechOutputSplit rows to the seasonal v4 tables (limit_tech_input_split / limit_tech_output_split) unconditionally. Temoa's seasonal split constraints only apply to non-annual techs, so every annual tech's split constraint silently disappeared from migrated models: the rows exist in the DB but no constraint is built from them. Fix: partition split rows by the tech's Technology.annual flag (with a tech_annual table fallback for older v3 databases) and route annual techs' rows to limit_tech_input_split_annual / limit_tech_output_split_annual. The seasonal and annual targets are column-identical, so the existing row transformation applies to both. Found migrating the Open Energy Outlook 9-region US database: 13,313 of 15,369 TechInputSplit rows belonged to annual techs (transport fuel blends, industrial fuel mixes) and were dropped from the model, letting e.g. Fischer-Tropsch synfuel run without its mandated hydrogen input. Adds regression coverage: both mock datasets now carry a seasonal-tech and an annual-tech split row, asserting placement after migration. The new v3-schema assertions fail without this fix.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe migration detects annual technologies from current or legacy metadata, routes legacy split-table rows to seasonal or annual v4 tables, and verifies both routing paths with expanded migration fixtures and tests. ChangesSplit-table migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant LegacyDB
participant Migration
participant V4Tables
LegacyDB->>Migration: Read annual technology flags
Migration->>LegacyDB: Read split-table rows
Migration->>V4Tables: Insert seasonal rows
Migration->>V4Tables: Insert annual rows
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…al fallback, neither)
Problem
master_migration.pyroutesTechInputSplit/TechOutputSplitrows to the seasonal v4 tables (limit_tech_input_split/limit_tech_output_split) unconditionally, ignoringTechnology.annual. The seasonal split constraints only apply to non-annual techs, so every annual tech's split constraint silently disappears from migrated models — the rows are present in the DB, but no constraint is built from them, and nothing warns.Impact (real-world case)
Migrating the Open Energy Outlook 9-region US database, 13,313 of 15,369
TechInputSplitrows belong to annual techs (transport fuel blends, industrial fuel-mix shares) and were all dropped from the model. Visible symptom: Fischer-Tropsch synfuel ran without its mandated hydrogen input, making captured CO₂ a free fuel source and distorting the whole electricity mix (a ~370 GW phantom coal-CCS build at $0 carbon). Re-routing the rows restored v3-equivalent behavior.Fix
In
_migrate_operator_tables, partition split rows by the tech'sannualflag (readingTechnology.annual, with atech_annualtable fallback for older v3 databases) and route annual techs' rows tolimit_tech_input_split_annual/limit_tech_output_split_annual. The seasonal and annual targets are column-identical, so the existing operator-insertion transform applies unchanged.v3.1-schema databases (explicit
LimitTech*Split[Annual]tables) are unaffected — they already migrate by name.Tests
Both migration mock datasets now carry one seasonal-tech and one annual-tech split row (input and output), with placement assertions after migration. The new v3-schema assertions fail without this fix and pass with it; the v3.1 path passes before and after (placement-preservation coverage).
Summary by CodeRabbit
Bug Fixes
Tests