-
Notifications
You must be signed in to change notification settings - Fork 3
Remove environment variables from create_request_file.py
#529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Naomi Parsons (NParsonsMO)
merged 21 commits into
main
from
523-remove-environment-variables-from-create_request_filepy
Aug 28, 2026
Merged
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2bafc3a
Reconfiguring create_request_file
NParsonsMO df511a9
Missed environmental var
NParsonsMO 83d64df
changed test
NParsonsMO cbe4efc
Missed feeding through argument
NParsonsMO 8e3b30e
Merge branch 'main' into 523-remove-environment-variables-from-create…
NParsonsMO 9af7871
Merge branch 'main' into 523-remove-environment-variables-from-create…
NParsonsMO 7d36736
Missed at merge
NParsonsMO a141994
Missed at merge
NParsonsMO 264d77f
Merge branch 'main' into 523-remove-environment-variables-from-create…
NParsonsMO f9fc36e
removing argument
NParsonsMO 8e38656
Using conftest.py
NParsonsMO d18aaeb
Listing from a variables file rather than all streams
NParsonsMO 551d01b
Missed removal
NParsonsMO 46fd783
Missed removal
NParsonsMO 77b0459
Merge branch 'main' into 523-remove-environment-variables-from-create…
NParsonsMO 07e0ea5
Merge branch 'main' into 523-remove-environment-variables-from-create…
NParsonsMO 01fc928
Copyright
NParsonsMO c288751
Apply suggestions from code review
NParsonsMO ab42ddc
Suggestion plus closing bracket
NParsonsMO 0e20e17
Merge branch 'main' into 523-remove-environment-variables-from-create…
NParsonsMO 6fd7280
Merge branch 'main' into 523-remove-environment-variables-from-create…
NParsonsMO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # (C) Crown Copyright 2026, Met Office. | ||
| # The LICENSE.md file contains full licensing details. | ||
| import argparse | ||
| from create_request_file import create_request_file | ||
|
|
||
|
|
||
| def parse_args_for_create_request_file(arguments): | ||
| """ | ||
| Return the names and values of the command line arguments for | ||
| :func:`main_for_create_request_file`. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| arguments : :obj:`list` of :obj:`str` | ||
| The command line arguments to be parsed. | ||
|
|
||
| Returns | ||
| ------- | ||
| :class:`argparse.Namespace` | ||
| The names and values of the command line arguments. | ||
| """ | ||
| parser = argparse.ArgumentParser( | ||
| description="Create a request to standardise model data with CDDS.", | ||
| formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||
| ) | ||
| parser.add_argument( | ||
| "--dataset", | ||
| help="The model run to be extracted from MASS and processed.", | ||
| ) | ||
| parser.add_argument( | ||
| "--output_filepath", | ||
| help=( | ||
| "The full path to the file where the " | ||
| "variables from the ESMValTool recipe will be written." | ||
|
NParsonsMO marked this conversation as resolved.
Outdated
|
||
| ), | ||
| ) | ||
| parser.add_argument( | ||
| "--defaults_path", | ||
| help=( | ||
| "The full path to the file where the " | ||
| "default values for a CDDS request are written." | ||
| ), | ||
| ) | ||
| parser.add_argument( | ||
| "--mip_table_dir", | ||
| help="The MIP table to use from CDDS.", | ||
|
NParsonsMO marked this conversation as resolved.
Outdated
|
||
| ) | ||
| parser.add_argument( | ||
| "--model_runs_yml_fp", | ||
| help=( | ||
| "The full path to the YAML file " | ||
| "containing details of the model runs." | ||
| ), | ||
| ) | ||
| parser.add_argument( | ||
| "--root_proc_dir", | ||
| help=( | ||
| "The full path to the directory where CDDS " | ||
| "should store data for the processing workflow." | ||
| ), | ||
| ) | ||
| parser.add_argument( | ||
| "--root_data_dir", | ||
| help=( | ||
| "The full path to the directory where CDDS " | ||
| "should store raw and standardised data." | ||
| ), | ||
| ) | ||
| parser.add_argument( | ||
| "--variables_file", | ||
| help=( | ||
| "The full path to the file where the " | ||
| "variables to be retrieved by CDDS are written." | ||
| ), | ||
| ) | ||
| parser.add_argument( | ||
| "--raw_data_dir_mode", | ||
| help=("Whether to save or reuse raw CDDS data files."), | ||
| ) | ||
| return parser.parse_args(arguments) | ||
|
|
||
|
|
||
| def main_for_create_request_file(arguments=None): | ||
| """ | ||
| Generate and write the request file for the current task environment. | ||
|
NParsonsMO marked this conversation as resolved.
Outdated
|
||
|
|
||
| Parameters | ||
| ---------- | ||
| arguments : :obj:`list` of :obj:`str` | ||
| The command line arguments to be parsed. | ||
| """ | ||
| # Parse the arguments. | ||
| args = parse_args_for_create_request_file(arguments) | ||
|
|
||
| # Run the code. | ||
| print(f"dataset: {args.dataset}"), | ||
| print(f"output_filepath: {args.output_filepath}"), | ||
| print(f"defaults_path: {args.defaults_path}"), | ||
| print(f"mip_table_dir: {args.mip_table_dir}"), | ||
| print(f"model_runs_yml_fp: {args.model_runs_yml_fp}"), | ||
| print(f"root_proc_dir: {args.root_proc_dir}"), | ||
| print(f"root_data_dir: {args.root_data_dir}"), | ||
| print(f"variables_file: {args.variables_file}"), | ||
| print(f"raw_data_dir_mode: {args.raw_data_dir_mode}"), | ||
| create_request_file( | ||
| args.dataset, | ||
| args.output_filepath, | ||
| args.defaults_path, | ||
| args.mip_table_dir, | ||
| args.model_runs_yml_fp, | ||
| args.root_proc_dir, | ||
| args.root_data_dir, | ||
| args.variables_file, | ||
| args.raw_data_dir_mode, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
CMEW/app/configure_standardise/bin/configure_standardise_conftest.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/usr/bin/env python | ||
| # (C) Crown Copyright 2026, Met Office. | ||
| # The LICENSE.md file contains full licensing details. | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def mock_data_dir(): | ||
| return Path(__file__).parent.parent.parent / "unittest" / "mock_data" | ||
|
|
||
|
|
||
| def model_runs_yml_fp(): | ||
| return mock_data_dir() / "model_runs.yml" | ||
|
|
||
|
|
||
| def kgo_dir(): | ||
| return Path(__file__).parent.parent.parent / "unittest" / "kgo" | ||
|
|
||
|
|
||
| def request_u_cw673_cfg_fp(): | ||
| return kgo_dir() / "request_u-cw673.cfg" | ||
|
|
||
|
|
||
| def etc_dir(): | ||
| return Path(__file__).parent.parent / "etc" | ||
|
|
||
|
|
||
| def request_defaults_yml_fp(): | ||
| return etc_dir() / "request_defaults.yml" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #!/usr/bin/env python | ||
| # (C) Crown Copyright 2026, Met Office. | ||
| # The LICENSE.md file contains full licensing details. | ||
| from command_line import main_for_create_request_file | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main_for_create_request_file() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.