Skip to content

Make streams configurable at dataset level#510

Open
Naomi Parsons (NParsonsMO) wants to merge 18 commits into
mainfrom
509-make-streams-configurable-at-dataset-level
Open

Make streams configurable at dataset level#510
Naomi Parsons (NParsonsMO) wants to merge 18 commits into
mainfrom
509-make-streams-configurable-at-dataset-level

Conversation

@NParsonsMO

@NParsonsMO Naomi Parsons (NParsonsMO) commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #509

This comment may be useful while reviewing:
#509 (comment)

PR creation checklist for the developer

  • The <issue_number> above ☝️ has been replaced with the issue number.
  • main has been selected as the base branch.
  • The feature branch name follows the format <issue_number>_<short_description_of_feature>.
  • The text of the PR title exactly matches with the text (not including the issue number) of the issue title.
  • Appropriate reviewers have been added to the PR (once it is ready for review).
  • The PR has been assigned to the developer(s).
  • The same labels as on the issue (except for the good first issue label) have been added to the PR.
  • The Climate Model Evaluation Workflow (CMEW) project has been added to the PR.
  • The appropriate milestone has been added to the PR.

Definition of Done for the developer

  • This PR contains only the changes needed to meet all acceptance criteria.
  • The change in this PR follows the requirements in the wiki: Developer Guide (including copyrights).
  • The GitHub Actions workflow checks pass.
  • The tests run locally and pass (Note: the tests are not run by the GitHub Actions workflow, see wiki: Run the tests locally).
  • Updating the Rose metadata (select one of the following):
    • Rose metadata related to the change has been added or updated.
    • The change does not require Rose metadata to be added or updated.
  • Rendering the Rose metadata (select one of the following):
    • The Rose GUI shows the change as expected.
    • The change in this PR does not affect the Rose GUI.
  • Updating the tests (select one of the following):
    • Tests related to the change have been added or updated.
    • The change does not require tests to be added or updated.
  • Updating the user documentation (i.e. everything in the doc directory, including the Quick Start section; select one of the following):
    • The user documentation related to the change has been updated appropriately.
    • The change in this PR does not require the user documentation to be updated.
  • Rendering the user documentation (wiki: Build the documentation locally provides instructions; select one of the following):
    • The HTML pages show the change as expected.
    • The change in this PR does not affect the HTML pages.
  • Updating the API documentation (e.g. docstrings in Python modules; select one of the following):
    • The API documentation related to the change has been updated appropriately.
    • The change in this PR does not affect the API documentation.

Copyright and IPR:

GitHub handles
I confirm that all code is my own and that my contributions are not subject to copyright or license restrictions. NParsonsMO
I confirm I have not knowingly violated intellectual property rights (IPR) and have taken sensible measures to prevent doing so, including appropriate attribution for usage of Generative AI. I confirm that this work is my own, and I understand that it is my responsibility to ensure I am not violating others’ IPR. This includes taking reasonable steps to ensure that all tools used while creating this contribution did not infringe IPR. NParsonsMO

PR creation checklist for the reviewer

  • The <issue_number> above ☝️ has been replaced with the issue number.
  • main has been selected as the base branch.
  • The feature branch name follows the format <issue_number>_<short_description_of_feature>.
  • The text of the PR title exactly matches with the text (not including the issue number) of the issue title.
  • Appropriate reviewers have been added to the PR (once it is ready for review).
  • The PR has been assigned to the developer(s).
  • The same labels as on the issue (except for the good first issue label) have been added to the PR.
  • The Climate Model Evaluation Workflow (CMEW) project has been added to the PR.
  • The appropriate milestone has been added to the PR.

Definition of Done for the reviewer

  • This PR contains only the changes needed to meet all acceptance criteria.
  • The change in this PR follows the requirements in the wiki: Developer Guide (including copyrights).
  • All developers of this PR have added their names to the Copyright and IPR statements above.
  • The GitHub Actions workflow checks pass.
  • The tests run locally and pass (Note: the tests are not run by the GitHub Actions workflow, see wiki: Run the tests locally).
  • Updating the Rose metadata (select one of the following):
    • Rose metadata related to the change has been added or updated.
    • The change does not require Rose metadata to be added or updated.
  • Rendering the Rose metadata (select one of the following):
    • The Rose GUI shows the change as expected.
    • The change in this PR does not affect the Rose GUI.
  • Updating the tests (select one of the following):
    • Tests related to the change have been added or updated.
    • The change does not require tests to be added or updated.
  • Updating the user documentation (i.e. everything in the doc directory, including the Quick Start section; select one of the following):
    • The user documentation related to the change has been updated appropriately.
    • The change in this PR does not require the user documentation to be updated.
  • Rendering the user documentation (wiki: Build the documentation locally provides instructions; select one of the following):
    • The HTML pages show the change as expected.
    • The change in this PR does not affect the HTML pages.
  • Updating the API documentation (e.g. docstrings in Python modules; select one of the following):
    • The API documentation related to the change has been updated appropriately.
    • The change in this PR does not affect the API documentation.

Important

  • Remember to re-check the Definition of Done after making changes in response to a review.
  • The developer merges the PR.
  • Remember to use the format #<pull_request_number>: <pull_request_title> when writing the merge commit message for the pull request, so the pull request number is immediately visible on GitHub, regardless of the length of the pull request title.

@NParsonsMO Naomi Parsons (NParsonsMO) added standardise Anything related to CDDS configure Anything related to configuration labels Jun 25, 2026
@NParsonsMO Naomi Parsons (NParsonsMO) linked an issue Jun 25, 2026 that may be closed by this pull request
@NParsonsMO Naomi Parsons (NParsonsMO) changed the title 509 make streams configurable at dataset level Make streams configurable at dataset level Jun 25, 2026
Comment on lines +56 to +67
# Check whether a custom stream map is set to be used
dataset = os.environ["CYLC_TASK_PARAM_dataset"].strip()
with open(f"{os.environ['DATASETS_LIST_DIR']}/model_runs.yml") as f:
content = yaml.safe_load(f)
dataset_dict = content[dataset]
logger.debug("Dataset information:\n%s", dataset_dict)

# Get path to stream mappings
streams_config = os.environ["STREAM_CONFIG_PATH"]
if dataset_dict["use_custom_data_streams"] == "true":
streams_config = dataset_dict["path_to_custom_streams_config"]
else:
streams_config = os.environ["STREAM_CONFIG_PATH"]

@NParsonsMO Naomi Parsons (NParsonsMO) Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This adds exactly the same code in two different files.

Find a better way.

@NParsonsMO Naomi Parsons (NParsonsMO) Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We should discuss which runs count as "standard" for writing the streams to this file.

I've written the MJO variables' streams as they are in the not for CMIP model run (u-cw...), as I assume this better represents future uses, but this means we have to provide the custom path for the u-az... and u-bv... runs (in order to run the MJO recipe, not for radiation budget). Eventually I'm guessing users will pull these kinds from CHAMP, as actual CMIP runs.


# Read the model run information from the model_runs.yml file
model_runs_yaml = Path(os.environ["DATASETS_LIST_DIR"]) / "model_runs.yml"
model_runs_yaml = os.environ["MODEL_RUNS_CONFIG"]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I found this referenced in a few places.

@NParsonsMO Naomi Parsons (NParsonsMO) Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Currently this is just a single function that's imported by the two files in this directory so that I didn't write the code twice (and tested it only once), so it doesn't have main().

As it applies only to these two highly related files, I put it here rather than in CMEW/lib/python (it's also much easier to unit test from here).

- Amon/tas
- Emon/rls
- Emon/rss
- Amon/hfls

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The spacing worked before, but I think this way is standard.

yaml.dump(dataset_dict, f)


def format_as_bools(filepath):

@NParsonsMO Naomi Parsons (NParsonsMO) Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Using Rose to set the type to either of "boolean" or "python_boolean" resulted in a quoted string ('true' or 'True'), so this is just to make querying the file easier later (and it makes the file neater to look at, and to reproduce a different way in future if we moved away from the whole namelist thing).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Tests before were using the actual file, so they started failing. They should have used a mock to begin with.

Comment thread CMEW/flow.cylc
DATASETS_LIST_DIR = "${CYLC_WORKFLOW_SHARE_DIR}/dataset_lists"
DATASETS_LIST_DIR = ${CYLC_WORKFLOW_SHARE_DIR}/dataset_lists
# This particular file controls behaviours throughout the workflow
MODEL_RUNS_CONFIG = ${DATASETS_LIST_DIR}/model_runs.yml

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the path I found referenced a few times so I thought it belonged here.

Comment thread CMEW/rose-suite.conf Outdated
experiment_id="historical"
label_for_plots="UKESM1.0 N96ORCA1"
model_id="UKESM1-0-LL"
path_to_custom_streams_config="$HOME/my_own_streams.yml"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If I know what these "custom" streams are for some styles of model run, should we have that stored somewhere in CMEW?

@NParsonsMO
Naomi Parsons (NParsonsMO) marked this pull request as ready for review June 26, 2026 11:41
Comment thread CMEW/meta/rose-meta.conf
description=The calendar used by the run.
help=Only 'gregorian' and '360_day' are currently supported.
sort-key=6
sort-key=16

@NParsonsMO Naomi Parsons (NParsonsMO) Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The sorting seems to work more like the sub-unitary digits of a decimal than an integer of unspecified number of digits.

@ehogan

Copy link
Copy Markdown
Member

Naomi Parsons (@NParsonsMO), would it be possible to get a walkthrough of this PR at the surgery on Monday, please? I'm struggling to understand the quantity of changes.

My immediate reaction is: how did we end up with so much Python code in CMEW? We might want to evaluate whether any of it can be added back into Rose and / or Cylc, and also consider pulling out all the Python code into a Python package (which can then be properly tested; #228). This would make it easier to replace / share Python code in the future.

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

Labels

configure Anything related to configuration standardise Anything related to CDDS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make streams configurable at dataset level

2 participants