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 pslot dir from local archive folder on CI case completion #2961

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1c159d8
added a cleanup_experment funciton to ci_utils that cleans local arch…
TerryMcGuinness-NOAA Sep 24, 2024
e7aa3ba
Merge branch 'NOAA-EMC:develop' into ci_clean_loc_arch
TerrenceMcGuinness-NOAA Sep 25, 2024
463655a
moved rm for EXPDIR into cleanup_expermiment function
TerryMcGuinness-NOAA Sep 25, 2024
b511367
Merge branch 'ci_clean_loc_arch' of github.com:TerrenceMcGuinness-NOA…
TerryMcGuinness-NOAA Sep 25, 2024
40c96b2
fixed bracket sytax error in ci_utils and missnamed function call in …
TerryMcGuinness-NOAA Sep 26, 2024
54ce216
fixed SC2155 in bash utils for cleanup
TerryMcGuinness-NOAA Sep 26, 2024
cacde8c
fixed SC2115 for var expation in path for clean experiment util
TerryMcGuinness-NOAA Sep 26, 2024
c8a10a9
needed the OR truch for var assigment via actions in bash
TerryMcGuinness-NOAA Sep 26, 2024
7c93f4b
fixed the evaluation of HOMDIR so that internal strification of env v…
TerryMcGuinness-NOAA Sep 27, 2024
bb92a39
Merge branch 'develop' into ci_clean_loc_arch
TerrenceMcGuinness-NOAA Sep 27, 2024
bfcbba5
still needed archive tagged back onto HOMEDIR
TerryMcGuinness-NOAA Sep 27, 2024
69fc51b
Merge branch 'ci_clean_loc_arch' of github.com:TerrenceMcGuinness-NOA…
TerryMcGuinness-NOAA Sep 27, 2024
49b4489
new linee at aend of ci_utils
TerryMcGuinness-NOAA Sep 27, 2024
b776a59
Merge branch 'NOAA-EMC:develop' into ci_clean_loc_arch
TerrenceMcGuinness-NOAA Oct 23, 2024
d8af194
removed eval in cleanup_experiment and added envsubst at end of pipe …
TerryMcGuinness-NOAA Oct 23, 2024
d54bd8d
updated archival directory to ARCDIR from config.base in cleanup_expe…
TerryMcGuinness-NOAA Oct 24, 2024
85f6369
forgot to clean up EXPDIR replacement in cleanup_experment
TerryMcGuinness-NOAA Oct 24, 2024
6a09b36
forgot to clean up EXPDIR replacement in cleanup_experment still
TerryMcGuinness-NOAA Oct 24, 2024
32b8cd0
Update ci/scripts/utils/ci_utils.sh
TerrenceMcGuinness-NOAA Oct 25, 2024
e01d9d3
added get_config_var util to simplify cleanup_experment
TerryMcGuinness-NOAA Nov 5, 2024
3d5e851
removed debug outputs in cleanup_experiment
TerryMcGuinness-NOAA Nov 5, 2024
162474a
added next step to use get_config_var to remove previous DATAROOT dat…
TerryMcGuinness-NOAA Nov 5, 2024
7da3721
fix conficts and merged develop back in
TerryMcGuinness-NOAA Nov 5, 2024
c6ad4ec
updated Jenkinsfile to use clean experiment and to also clean DATADIR…
TerryMcGuinness-NOAA Nov 5, 2024
bef32e7
updating correct ATARDIR variable in cleaup
TerryMcGuinness-NOAA Nov 5, 2024
02642fc
added true for shell norms
TerryMcGuinness-NOAA Nov 5, 2024
62ec3f6
Update ci/scripts/utils/ci_utils.sh
TerrenceMcGuinness-NOAA Nov 6, 2024
7e5b4fb
Update ci/scripts/utils/ci_utils.sh
TerrenceMcGuinness-NOAA Nov 6, 2024
bf3b80f
Update ci/scripts/utils/get_config_var.py
TerrenceMcGuinness-NOAA Nov 6, 2024
cd4e27b
Update ci/scripts/utils/get_config_var.py
TerrenceMcGuinness-NOAA Nov 6, 2024
5ea8d3d
Update ci/scripts/utils/get_config_var.py
TerrenceMcGuinness-NOAA Nov 6, 2024
99b9322
Update ci/scripts/utils/get_config_var.py
TerrenceMcGuinness-NOAA Nov 6, 2024
f56be33
Update ci/scripts/utils/get_config_var.py
TerrenceMcGuinness-NOAA Nov 6, 2024
9a381b4
fixed name of get_config_var in pipeline (left off the py extention)
TerryMcGuinness-NOAA Nov 6, 2024
788dd8f
DATAROOT is not a config.base value but is construced from STMP in ta…
TerryMcGuinness-NOAA Nov 6, 2024
7d3b8bf
updated Jenkins file with correct RUNDIRS string (had RUNDIR as a bug)
TerryMcGuinness-NOAA Nov 8, 2024
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
4 changes: 4 additions & 0 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ pipeline {
def yaml_case = readYaml file: "${CUSTOM_WORKSPACE}/gfs/ci/cases/pr/${caseName}.yaml.tmp"
def build_system = yaml_case.experiment.system
try {
// Remove any data in that might still be in the DATAROOT directory from previous runs
STMP=sh(script: "${HOMEgfs}/ci/scripts/utils/get_config_var.py STMP ${CUSTOM_WORKSPACE}/RUNTESTS/EXPDIR/${pslot}", returnStdout: true).trim()
sh(script: "rm -Rf ${STMP}/RUNDIRS/${pslot}")
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
22 changes: 21 additions & 1 deletion ci/scripts/utils/ci_utils.sh
DavidHuber-NOAA marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,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 +154,24 @@ function publish_logs() {
fi
echo "${URL}"
}

function cleanup_experiment() {
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

local EXPDIR="$1"
Fixed Show fixed Hide fixed
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 "${STMP}/RUNDIRS/${pslot}"
rm -Rf "${ARCDIR:?}"
rm -Rf "${ATARDIR:?}"
rm -Rf "${COMROOT:?}"
rm -Rf "${EXPDIR}"
}
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

TerrenceMcGuinness-NOAA marked this conversation as resolved.
Show resolved Hide resolved

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]

TerrenceMcGuinness-NOAA marked this conversation as resolved.
Show resolved Hide resolved

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