Skip to content

fix: make CBA workflow correctly run single runs and collection (multi climate year) runs#625

Open
measrainsey wants to merge 10 commits intomasterfrom
fix/single-cba-run
Open

fix: make CBA workflow correctly run single runs and collection (multi climate year) runs#625
measrainsey wants to merge 10 commits intomasterfrom
fix/single-cba-run

Conversation

@measrainsey
Copy link
Copy Markdown
Member

@measrainsey measrainsey commented Apr 13, 2026

Closes:

Changes proposed in this Pull Request

PR to fix the CBA workflow so that it works consistently for both single runs and collection runs

Tasks

Workflow

  • rules/cba.smk: the workflow now distinguishes between different kinds of runs, via a function called cba_projects_run()
    • simple runs (e.g., NT)
    • collection scenarios (runs with cba.scenarios) (e.g., NT-cyears)
    • source runs that may point to another scenario via cba.sb_scenario (e.g., NT-cy2009)

With these changes:

  • single-run CBA execution works as a proper target
  • collection runs still build the nested runs and ensemble outputs
  • ensemble-only steps are no longer forced onto normal runs

I tested by running the command snakemake -call cba --configfile config/config.tyndp.yaml.

If just the NT is run, then the results create only the NT folder, with solved SB networks and CBA results.
Screenshot 2026-04-14 at 12 16 24 PM

If NT-cyears is run, there are two possibilities:

  • if the intermediate files such as resources/<run>/cba/networks/simple_*.nc already exist (in the desired temporal resolution and such), then the NT results won't include the solved SB networks
  • if the intermediate files don't exist, it will trigger the solved SB networks, as the solved SB networks are needed

This is the file directory of a situation where the intermediate files didn't exist, so the NT SB solved networks were also recreated in the results. Also note that the collection rule, NT-cyears, only has the ensemble results.

Screenshot 2026-04-14 at 2 58 14 PM

Conversely, if I run the NT-cy1998 scenario, which references cba.sb_scenario: NT, if the NT-cy1998 resources folder already has the required intermediate resources file(s), then the workflow won't run and solve the SB networks for the NT again.

Screenshot 2026-04-14 at 3 02 25 PM

Open issues

Notes

Checklist

  • I tested my contribution locally and it works as intended.
  • Code and workflow changes are sufficiently documented.
  • [ ] Changed dependencies are added to pixi.toml (using pixi add <dependency-name>).
  • [ ] Changes in configuration options are added in config/config.default.yaml.
  • [ ] Changes in configuration options are documented in doc/configtables/*.csv.
  • [ ] Changes in configuration options are added in config/test/*.yaml.
  • The multiple weather/climate years test is passing locally (using pixi run -e open-tyndp tyndp-cyears-test).
  • [ ] Open-TYNDP SPDX license header added to all touched files.
  • [ ] For new data sources or versions, these instructions have been followed.
  • [ ] New rules are documented in the appropriate doc/*.rst files.
  • A release note doc/release_notes.rst is added.
  • [ ] Major features are documented with up-to-date information in README and doc/index.rst.
  • [ ] Module docstrings added to new Python scripts.

@measrainsey measrainsey self-assigned this Apr 13, 2026
@measrainsey measrainsey added bug Something isn't working CBA Cost Benefit Analysis labels Apr 13, 2026
@measrainsey measrainsey marked this pull request as ready for review April 14, 2026 13:08
@lisazeyen lisazeyen self-requested a review April 14, 2026 15:40
 Conflicts:
	doc/release_notes.rst
Copy link
Copy Markdown
Collaborator

@lisazeyen lisazeyen left a comment

Choose a reason for hiding this comment

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

Great @measrainsey ! Also just some minor comments here on reformulating the release notes and summarizing one part of the cba.smk into a function.

Comment thread rules/cba.smk Outdated
Comment on lines +601 to +605
run = w.get("run", config_provider("run", "name")(w))
if isinstance(run, list):
run = run[0] if run else ""
if not run:
return []
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This pattern is used quite often, should we modularize into a function?

Comment thread doc/release_notes.rst Outdated
@measrainsey measrainsey requested a review from lisazeyen April 21, 2026 06:29
@measrainsey
Copy link
Copy Markdown
Member Author

Thanks @lisazeyen for your review! I implemented your suggestion to the PR description, and I refactored the commonly used code into a function - feel free take another look at let me know if you have any other suggestions! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CBA Cost Benefit Analysis

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow CBA workflow to run with single runs (NT) instead of just collection runs (weather years)

2 participants