Skip to content

Template new format new entrants identity cols#124

Merged
EllieKallmier merged 5 commits into
mainfrom
template-new-format-new-entrants-identity-cols
Jun 24, 2026
Merged

Template new format new entrants identity cols#124
EllieKallmier merged 5 commits into
mainfrom
template-new-format-new-entrants-identity-cols

Conversation

@EllieKallmier

Copy link
Copy Markdown
Member

This PR is the first of a few to come in the process of templating new entrants - both generators and storage.

Scope:

  • initial templating for 'identity' columns only for generators_new_entrant and storage_new_entrant
  • wiring into create_ispypsa_inputs_template to feed into connection costs templating
  • minor update to storage_new_entrants schema (removing 'Power Station' column)

Coming up in next PR(s):

  • Writing new-format templated new_entrant tables to templater output
  • Filling out extra columns!

For the moment I've set up both new entrant groups to live in the same file, but this might change/split in future as more detail gets added to each - and as existing/planned technologies get templated too. Happy to take on any suggestions around this kind of structural stuff if there are any :)

@EllieKallmier EllieKallmier added type: feature New feature or request module: templater Covers contents of `templater` module labels Jun 19, 2026
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/ispypsa/templater/create_template.py 93.02% <100.00%> (+0.08%) ⬆️
...spypsa/templater/custom_constraints_from_plexos.py 100.00% <100.00%> (ø)
src/ispypsa/templater/helpers.py 100.00% <100.00%> (ø)
src/ispypsa/templater/new_entrants.py 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nick-gorman nick-gorman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the structure is good, very readable, and a nice size for review. Minor comments only.

Comment thread src/ispypsa/templater/new_entrants.py Outdated
Comment on lines +60 to +61
# Extraction pattern for the resource-quality code embedded between underscores in
# a VRE IASR ID, e.g. "WFX" in "N10_WFX_Hunter Coast".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# Extraction pattern for the resource-quality code embedded between underscores in
# a VRE IASR ID, e.g. "WFX" in "N10_WFX_Hunter Coast".
# Regex extracting the resource-quality code embedded between underscores in a VRE # IASR ID, e.g. "WFX" in "N10_WFX_Hunter Coast". Derived from the code map, it
# expands to "_(WFX|WFL|SAT|...)_" — one capture group over the known codes, # sorted longest-first so a short code can't shadow a longer one it prefixes.

pd.testing.assert_frame_equal(storage, expected_storage)


def test_filter_to_technology_group_raises_unknown_group(csv_str_to_df, caplog):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit picking / totally fine the way it is. But since _filter_to_technology_group is a private function (and you know it will only be fed storage or generators) you could probably not have the raise and assocaited tests.

)


def _set_geo_id(new_entrants: pd.DataFrame) -> pd.DataFrame:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Somewhat duplicates custom_constraints_from_plexos.py:938 _pick_location. We could extract to a helper, but it doesn't concern me too much,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could also guard against future REZ ID being NaN rather than "Not Applicable", but that goes against our lets just assume the templater inputs are fixed principal, on the other hand its a cheap bit of robustness.

Comment thread src/ispypsa/templater/new_entrants.py Outdated
``_STORAGE_TECHNOLOGY_STRINGS`` substring (battery, pumped hydro), matched
case-insensitively; generators are every other row. The two groups partition
the summary, so this single predicate is the only place the generator/storage
boundary is defined.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

custom_constraints_from_plexos.py:935 _is_battery_row ("Batter"); and static_new_generator_properties.py:65 (r"battery|pumped hydro") are also doing this work. Not suggesting we extract helpers (I don't think). But maybe loosen the language in the comment?

@nick-gorman

nick-gorman commented Jun 24, 2026

Copy link
Copy Markdown
Member

Actually, on thing that might have slipped past me in the review (and pervious ones) is adding new format templater tables to this CLI test test_create_ispypsa_inputs_new_table_formats.py::test_create_ispypsa_inputs_new_format, which runs real IASR data through the templater using the CLI and then checks the results are roughly the shape we expect. Not a blocker, and something it might be easier to circle back to when the new templater is being finalised.

@EllieKallmier

Copy link
Copy Markdown
Member Author

Some notes from post-review updates:

  • I did end up pulling out some helpers in places you highlighted, as I do think they made sense and let me cut down a bit particularly in the tests. As part of this I added an equivalent pumped hydro helper to match the _is_battery_row one and a little wrapper to return their union; these are only used in the one spot at the moment but I can foresee a few spots where I think having these extras will come in handy
  • I also though did leave a (possibly unnecessary?) essentially wrapper dude in the new_entrants file pretty much because it was prettier to keep (_set_geo_id) and keeps a nicer readable set of steps in the orchestrators

Re: your comment about the CLI tests - yep good point, and I think I will circle back after I add the next prs with more detail onto this one and actually wire the new_entrants outputs to be templater outputs as well. So I'll do a check + add for everything that I've missed that on so far at that point if ok :)

@EllieKallmier EllieKallmier merged commit 73a0e90 into main Jun 24, 2026
15 checks passed
@EllieKallmier EllieKallmier deleted the template-new-format-new-entrants-identity-cols branch June 24, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: templater Covers contents of `templater` module type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants