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 👍
There was a problem hiding this comment.
Please remove these lines following the change you made at #349 (comment) 😊
There was a problem hiding this comment.
This review comment has still not been addressed.
There was a problem hiding this comment.
Sorry, I posted it under other comment.
| [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 👍
|
|
||
| def load_request_defaults(): | ||
| cfg = configparser.ConfigParser() | ||
| cfg.read(str(_get_request_defaults_path())) |
There was a problem hiding this comment.
| cfg.read(str(_get_request_defaults_path())) | |
| cfg.read(os.environ.get("REQUEST_DEFAULTS_PATH")) |
There was a problem hiding this comment.
The above SHA is unrelated to the suggested change above.
| def _get_request_defaults_path() -> Path: | ||
| """ | ||
| Return path to request defaults file. | ||
| Prefer REQUEST_DEFAULTS_PATH from the environment (set by Cylc), | ||
| but fall back to the repository-relative path for standalone pytest runs. | ||
| """ | ||
| env_path = os.environ.get("REQUEST_DEFAULTS_PATH") | ||
| if env_path: | ||
| return Path(env_path) | ||
| return Path(__file__).resolve().parents[1] / "etc" / "request_defaults.cfg" | ||
|
|
||
|
|
There was a problem hiding this comment.
This function is now not needed:
| def _get_request_defaults_path() -> Path: | |
| """ | |
| Return path to request defaults file. | |
| Prefer REQUEST_DEFAULTS_PATH from the environment (set by Cylc), | |
| but fall back to the repository-relative path for standalone pytest runs. | |
| """ | |
| env_path = os.environ.get("REQUEST_DEFAULTS_PATH") | |
| if env_path: | |
| return Path(env_path) | |
| return Path(__file__).resolve().parents[1] / "etc" / "request_defaults.cfg" |
There was a problem hiding this comment.
This function is made for pytest. To run successful standalone pytest we need content of cfg file.
So, in case of pytest, I will use:
Path(__file__).resolve().parents[1] / "etc" / "request_defaults.cfg"
and load the file.
There was a problem hiding this comment.
The change I suggested at #349 (comment) removes the last reference to _get_request_defaults_path in CMEW, meaning this function can be removed.
There was a problem hiding this comment.
removed the function but then I had to update the tests.

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?