Minimise duplication of the CDDS default request items#349
Minimise duplication of the CDDS default request items#349
Conversation
NParsonsMO
left a comment
There was a problem hiding this comment.
The unit test for configure_standardise/bin/test_create_request_file.py::test_create_request fails.
I also think that the defaults file is not supposed to contain user-configurable variables.
| mode=mkdir | ||
|
|
||
| [file:$CYLC_WORKFLOW_SHARE_DIR/etc/request_defaults.cfg] | ||
| source=${CYLC_WORKFLOW_RUN_DIR}/app/configure_standardise/etc/request_defaults.cfg |
There was a problem hiding this comment.
I hoped on seeing this that it might be a way round the unit test failures that I encountered in PR #324, but unfortunately it isn't, and it has a very similar error itself.
When I run pytest myself, all the tests pass fine. But when I do cylc vip -O metoffice -O unittest, I get a file not found error for the file above, ending as below:
cfg_path = base_dir / "etc" / "request_defaults.cfg"
if not cfg_path.exists():
> raise FileNotFoundError(f"Defaults file not found: {cfg_path}")
E FileNotFoundError: Defaults file not found: [MY_DIR]/CMEW/run3/share/etc/request_defaults.cfg
configure_standardise/bin/create_request_file.py:25: FileNotFoundError
However here, the unit test also does not pass with the command cylc vip -O metoffice -O test (as opposed to unittest) either.
| # Running inside Cylc | ||
| base_dir = Path(os.environ["CYLC_WORKFLOW_SHARE_DIR"]) | ||
| else: | ||
| # Running under pytest / unittest / local execution |
There was a problem hiding this comment.
This doesn't seem to catch everything, see comment on rose-app.conf
| @@ -0,0 +1,44 @@ | |||
| # (C) Crown Copyright 2022-2026, Met Office. | |||
There was a problem hiding this comment.
It's only 2026, not 2022-2026.
The year of first publication of the specific file:
https://github.com/MetOffice/CMEW/wiki/Detailed-Working-Practices#coding-requirements
There was a problem hiding this comment.
This hasn't been addressed
NParsonsMO
left a comment
There was a problem hiding this comment.
One unit test is failing.
Two prior review comments have not been responded to.
| @@ -0,0 +1,44 @@ | |||
| # (C) Crown Copyright 2022-2026, Met Office. | |||
There was a problem hiding this comment.
This hasn't been addressed
Fix the unittest: ca8d9a0 |
alistairsellar
left a comment
There was a problem hiding this comment.
Thanks @zmaalick!
| [file:$CYLC_WORKFLOW_SHARE_DIR/etc/request_defaults.cfg] | ||
| source=${CYLC_WORKFLOW_RUN_DIR}/app/configure_standardise/etc/request_defaults.cfg |
There was a problem hiding this comment.
Would it be possible to explain why making a copy of request_defaults.cfg is needed here? Is it not possible to access the contents directly from the original file? 🤔
There was a problem hiding this comment.
Cylc runs workflows from a run directory, not the source tree. Copying request_defaults.cfg into share/etc makes the run self-contained, reproducible, and immune to source changes. Reading the original file directly would break provenance and reproducibility.
There was a problem hiding this comment.
The location where the request_defaults.cfg file is being copied from ($CYLC_WORKFLOW_SHARE_DIR) is already located in the run directory, so there's no need to copy the file.
There was a problem hiding this comment.
It should be possible to remove these lines following the proposed changes in my comment above 👍
| REQUEST_DEFAULTS_PATH = ( | ||
| Path(__file__).resolve().parents[1] / "etc" / "request_defaults.cfg" | ||
| ) |
There was a problem hiding this comment.
Thinking a bit more about this, and given much of the Python code in CMEW accesses information via environment variables defined in the Cylc workflow, would it be possible to define REQUEST_DEFAULTS_PATH in the root environment in the flow.cylc file, then use that below?
I acknowledge this goes against my previous comment, but I forgot we are already doing this in other places in CMEW 😞
I know there are multiple issues open to review environment variables, and I'm going to open another one to consider environment variables within Python scripts.
| [file:$CYLC_WORKFLOW_SHARE_DIR/etc/request_defaults.cfg] | ||
| source=${CYLC_WORKFLOW_RUN_DIR}/app/configure_standardise/etc/request_defaults.cfg |
There was a problem hiding this comment.
It should be possible to remove these lines following the proposed changes in my comment above 👍

Closes #209 .
PR creation checklist for the developer
<issue_number>above ☝️ been replaced with the issue number?mainbeen selected as the base branch?<issue_number>_<short_description_of_feature>?good first issuelabel) been added to the PR?Climate Model Evaluation Workflow (CMEW)project been added to the PR?Definition of Done for the developer
docdirectory) related to the change been updated appropriately, including the Quick Start section?PR creation checklist for the reviewer
<issue_number>above ☝️ been replaced with the issue number?mainbeen selected as the base branch?<issue_number>_<short_description_of_feature>?good first issuelabel) been added to the PR?Climate Model Evaluation Workflow (CMEW)project been added to the PR?Definition of Done for the reviewer
docdirectory) related to the change been updated appropriately, including the Quick Start section?