forked from NOAA-EMC/global-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove RUNDIRS before running CI cases to cover re-run events (NOAA-E…
…MC#3076) This Pr removes **pslot** dir (with hash) from local archive folder on CI case completion and also adds `cleanup_experiment` function in the BASH utilities to clean up after a CI case runs. This change consolidates cleanup actions and adds functionality to clean the local archive folders. Key changes: - Fixes bug for cleaning up the `RUNDIRS` directory before new experiments are run in the case the pipeline is being ran for a second time - Updated `$HOMEgfs/ci/scripts/check_ci.sh` to use the new `cleanup_experiment` function under the BASH CI system. - Added `cleanup_experiment `function in `$HOMEgfs/ci/scripts/utils/ci_utils.sh` to handle various cleanups including: - COMROOT/EXPDIR per case - ARCDIR and ATADIR directories for archive - STMP/RUNDIRS/${PSLOT} - Added get config var from EXPDIR utility [get_config_var.py](https://github.com/NOAA-EMC/global-workflow/pull/2961/files#diff-b780733ae1d45917730364e09a6c510e79d4cc8cffad6d9020c7961c53b987bc) for getting config values in BASH Resolves NOAA-EMC#2954 Resolves NOAA-EMC#3066
- Loading branch information
1 parent
e6df3b3
commit 1872499
Showing
4 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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,43 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import argparse | ||
from wxflow import Configuration | ||
|
||
|
||
def get_config_vars(var_names, config_path): | ||
""" | ||
GET_CONFIG_VARS Get configuration variables from a config file or directory. | ||
Parameters: | ||
var_names (list of str): The names of the configuration variables to retrieve. | ||
config_path (str): The path to the configuration file or directory. | ||
Returns: | ||
list of str: The values of the specified configuration variables. | ||
""" | ||
if os.path.isfile(config_path): | ||
config_dir = os.path.dirname(config_path) | ||
config_file = os.path.basename(config_path) | ||
elif os.path.isdir(config_path): | ||
config_dir = config_path | ||
config_file = 'config.base' | ||
config = Configuration(config_dir) | ||
config_data = config.parse_config(config_file) | ||
return [config_data[var_name] for var_name in var_names] | ||
|
||
|
||
if __name__ == "__main__": | ||
""" | ||
Main entry point for the script. | ||
Parses command-line arguments and retrieves the specified configuration variables. | ||
""" | ||
parser = argparse.ArgumentParser(description="Get configuration variables from a config file or directory.") | ||
parser.add_argument("var_names", nargs='+', help="The names of the configuration variables to retrieve.") | ||
parser.add_argument("config_path", help="The path to the configuration file or directory.") | ||
|
||
args = parser.parse_args() | ||
|
||
var_names = args.var_names | ||
config_path = args.config_path | ||
|
||
values = get_config_vars(var_names, config_path) | ||
print(" ".join(values)) |