Skip to content
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

Remove RUNDIRS before running CI cases to cover re-run events #3076

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ pipeline {
def build_system = yaml_case.experiment.system
try {
sh(script: "${HOMEgfs}/ci/scripts/run-check_ci.sh ${CUSTOM_WORKSPACE} ${pslot} ${build_system}")
sh(script: "${HOMEgfs}/ci/scripts/utils/ci_utils_wrapper.sh cleanup_experiment ${CUSTOM_WORKSPACE}/RUNTESTS/EXPDIR/${pslot}")
} catch (Exception error_experment) {
sh(script: "${HOMEgfs}/ci/scripts/utils/ci_utils_wrapper.sh cancel_batch_jobs ${pslot}")
ws(CUSTOM_WORKSPACE) {
Expand Down
3 changes: 1 addition & 2 deletions ci/scripts/check_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ for pr in ${pr_list}; do
fi
if [[ "${rocoto_state}" == "DONE" ]]; then
#Remove Experment cases that completed successfully
rm -Rf "${pslot_dir}"
rm -Rf "${pr_dir}/RUNTESTS/COMROOT/${pslot}"
"${HOMEgfs}/ci/scripts/utils/ci_utils_wrapper.sh" cleanup_experiment "${pslot_dir}"
rm -f "${output_ci_single}"
# echo "\`\`\`" > "${output_ci_single}"
DATE=$(date +'%D %r')
Expand Down
26 changes: 24 additions & 2 deletions ci/scripts/utils/ci_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ function create_experiment () {
source "${HOMEgfs}/ci/platforms/config.${MACHINE_ID}"
source "${HOMEgfs}/workflow/gw_setup.sh"

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

"${HOMEgfs}/${system}/workflow/create_experiment.py" --overwrite --yaml "${yaml_config}"
Expand All @@ -137,7 +139,6 @@ function publish_logs() {
local PR_header="$1"
local dir_path="$2"
local file="$3"

local full_paths=""
while IFS= read -r line; do
full_path="${dir_path}/${line}"
Expand All @@ -155,3 +156,24 @@ function publish_logs() {
fi
echo "${URL}"
}

function cleanup_experiment() {

local EXPDIR="$1"
local pslot
local ARCDIR
local ATARDIR
local COMROOT

EXPDIR="$1"
pslot=$(basename "${EXPDIR}")

# Use the Python utility to get the required variables
read -r ARCDIR ATARDIR STMP COMROOT < <("${HOMEgfs}/ci/scripts/utils/get_config_var.py" ARCDIR ATARDIR STMP COMROOT "${EXPDIR}") || true

rm -Rf "${ARCDIR:?}"
rm -Rf "${ATARDIR:?}"
rm -Rf "${COMROOT}/${pslot:?}"
rm -Rf "${EXPDIR}/${pslot:?}"
rm -Rf "${STMP}/RUNDIRS/${pslot:?}"
}
43 changes: 43 additions & 0 deletions ci/scripts/utils/get_config_var.py
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))
Loading