Skip to content

Commit 7b8f36f

Browse files
Merge branch 'develop' into feature/gocart_variable_fh
2 parents 2aca055 + 1872499 commit 7b8f36f

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

ci/Jenkinsfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ pipeline {
222222
def build_system = yaml_case.experiment.system
223223
try {
224224
sh(script: "${HOMEgfs}/ci/scripts/run-check_ci.sh ${CUSTOM_WORKSPACE} ${pslot} ${build_system}")
225+
sh(script: "${HOMEgfs}/ci/scripts/utils/ci_utils_wrapper.sh cleanup_experiment ${CUSTOM_WORKSPACE}/RUNTESTS/EXPDIR/${pslot}")
225226
} catch (Exception error_experment) {
226227
sh(script: "${HOMEgfs}/ci/scripts/utils/ci_utils_wrapper.sh cancel_batch_jobs ${pslot}")
227228
ws(CUSTOM_WORKSPACE) {

ci/scripts/check_ci.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ for pr in ${pr_list}; do
168168
fi
169169
if [[ "${rocoto_state}" == "DONE" ]]; then
170170
#Remove Experment cases that completed successfully
171-
rm -Rf "${pslot_dir}"
172-
rm -Rf "${pr_dir}/RUNTESTS/COMROOT/${pslot}"
171+
"${HOMEgfs}/ci/scripts/utils/ci_utils_wrapper.sh" cleanup_experiment "${pslot_dir}"
173172
rm -f "${output_ci_single}"
174173
# echo "\`\`\`" > "${output_ci_single}"
175174
DATE=$(date +'%D %r')

ci/scripts/utils/ci_utils.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ function create_experiment () {
122122
source "${HOMEgfs}/ci/platforms/config.${MACHINE_ID}"
123123
source "${HOMEgfs}/workflow/gw_setup.sh"
124124

125-
# Remove RUNDIRS dir incase this is a retry
125+
# Remove RUNDIRS dir incase this is a retry (STMP now in host file)
126+
STMP=$("${HOMEgfs}/ci/scripts/utils/parse_yaml.py" -y "${HOMEgfs}/workflow/hosts/${MACHINE_ID}.yaml" -k STMP -s)
127+
echo "Removing ${STMP}/RUNDIRS/${pslot} directory incase this is a retry"
126128
rm -Rf "${STMP}/RUNDIRS/${pslot}"
127129

128130
"${HOMEgfs}/${system}/workflow/create_experiment.py" --overwrite --yaml "${yaml_config}"
@@ -137,7 +139,6 @@ function publish_logs() {
137139
local PR_header="$1"
138140
local dir_path="$2"
139141
local file="$3"
140-
141142
local full_paths=""
142143
while IFS= read -r line; do
143144
full_path="${dir_path}/${line}"
@@ -155,3 +156,24 @@ function publish_logs() {
155156
fi
156157
echo "${URL}"
157158
}
159+
160+
function cleanup_experiment() {
161+
162+
local EXPDIR="$1"
163+
local pslot
164+
local ARCDIR
165+
local ATARDIR
166+
local COMROOT
167+
168+
EXPDIR="$1"
169+
pslot=$(basename "${EXPDIR}")
170+
171+
# Use the Python utility to get the required variables
172+
read -r ARCDIR ATARDIR STMP COMROOT < <("${HOMEgfs}/ci/scripts/utils/get_config_var.py" ARCDIR ATARDIR STMP COMROOT "${EXPDIR}") || true
173+
174+
rm -Rf "${ARCDIR:?}"
175+
rm -Rf "${ATARDIR:?}"
176+
rm -Rf "${COMROOT}/${pslot:?}"
177+
rm -Rf "${EXPDIR}/${pslot:?}"
178+
rm -Rf "${STMP}/RUNDIRS/${pslot:?}"
179+
}

ci/scripts/utils/get_config_var.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import argparse
5+
from wxflow import Configuration
6+
7+
8+
def get_config_vars(var_names, config_path):
9+
"""
10+
GET_CONFIG_VARS Get configuration variables from a config file or directory.
11+
Parameters:
12+
var_names (list of str): The names of the configuration variables to retrieve.
13+
config_path (str): The path to the configuration file or directory.
14+
Returns:
15+
list of str: The values of the specified configuration variables.
16+
"""
17+
if os.path.isfile(config_path):
18+
config_dir = os.path.dirname(config_path)
19+
config_file = os.path.basename(config_path)
20+
elif os.path.isdir(config_path):
21+
config_dir = config_path
22+
config_file = 'config.base'
23+
config = Configuration(config_dir)
24+
config_data = config.parse_config(config_file)
25+
return [config_data[var_name] for var_name in var_names]
26+
27+
28+
if __name__ == "__main__":
29+
"""
30+
Main entry point for the script.
31+
Parses command-line arguments and retrieves the specified configuration variables.
32+
"""
33+
parser = argparse.ArgumentParser(description="Get configuration variables from a config file or directory.")
34+
parser.add_argument("var_names", nargs='+', help="The names of the configuration variables to retrieve.")
35+
parser.add_argument("config_path", help="The path to the configuration file or directory.")
36+
37+
args = parser.parse_args()
38+
39+
var_names = args.var_names
40+
config_path = args.config_path
41+
42+
values = get_config_vars(var_names, config_path)
43+
print(" ".join(values))

0 commit comments

Comments
 (0)