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

BASH wrapper to create_experiment.py and removed its redundant 2nd argument #1789

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/globalworkflow-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
cd ${{ env.TEST_DIR }}/HOMEgfs
source workflow/gw_setup.sh
source ci/platforms/orion.sh
./ci/scripts/create_experiment.py --yaml ci/cases/${{ matrix.case }}.yaml --dir ${{ env.HOMEgfs_PR }}
./ci/scripts/create_experiment.py --yaml ci/cases/${{ matrix.case }}.yaml

run-experiments:
needs: create-experiments
Expand Down
2 changes: 0 additions & 2 deletions ci/scripts/create_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ def input_args():
formatter_class=ArgumentDefaultsHelpFormatter)

parser.add_argument('--yaml', help='full path to yaml file describing the experiment configuration', type=str, required=True)
parser.add_argument('--dir', help='full path to global-workflow build', type=str, required=True)

return parser.parse_args()


if __name__ == '__main__':

user_inputs = input_args()
HOMEgfs = Path.absolute(Path(user_inputs.dir))
testconf = YAMLFile(path=user_inputs.yaml)
experiment_dir = Path.absolute(Path.joinpath(Path(testconf.arguments.expdir), Path(testconf.arguments.pslot)))

Expand Down
68 changes: 68 additions & 0 deletions ci/scripts/create_experiment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
set -eux

#########################################################################
#
# Script description: BASH script for creating an experiment
# by only taking a single YAML file
########################################################################

usage() {
set +x
echo
echo "Usage: $0 -y case/yaml_conf_file.yaml"
echo
echo " -c global workflow configuration yaml defining an experiment (\$HOMEgfs/ci/cases)"
echo " -d full path to directory to place COMROT with EXPDIR for createing experiments"
echo " -h display this message and quit"
echo
exit 1
}

while getopts "c:d:h" opt; do
case ${opt} in
c)
YAML_CASE=${OPTARG}
;;
d)
RUNTESTS=${OPTARG}
;;
h|\?|:)
usage
;;
*)
echo "Unrecognized option"
usage
;;
esac
done

HOMEgfs="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." >/dev/null 2>&1 && pwd )"
scriptname=$(basename "${BASH_SOURCE[0]}")
echo "Begin ${scriptname} at $(date -u)" || true
export PS4='+ $(basename ${BASH_SOURCE})[${LINENO}]'

#########################################################################
# Set up runtime environment varibles for accounts on supproted machines
#########################################################################

source "${HOMEgfs}/ush/detect_machine.sh"
case ${MACHINE_ID} in
hera | orion)
source "${HOMEgfs}/ci/platforms/${MACHINE_ID}.sh"
;;
*)
echo "Unsupported platform. Exiting with error."
exit 1
;;
esac

filename=$(basename -- "${YAML_CASE}")
export pslot="${filename%.*}"
export RUNTESTS=${RUNTESTS:-"${PWD}"}
# TODO env HOMEgfs being set will cause runtime error
# with HOMEgfs being blank in Rocoto XLM file
export HOMEgfs_PR="${HOMEgfs}"
unset HOMEgfs;

"${HOMEgfs_PR}/ci/scripts/create_experiment.py" --yaml "${YAML_CASE}"
2 changes: 1 addition & 1 deletion ci/scripts/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ for pr in ${pr_list}; do
pslot="${case}_${pr_sha}"
export pslot
set +e
"${HOMEgfs_PR}/ci/scripts/create_experiment.py" --yaml "${HOMEgfs_PR}/ci/cases/${case}.yaml" --dir "${HOMEgfs_PR}"
"${HOMEgfs_PR}/ci/scripts/create_experiment.py" --yaml "${HOMEgfs_PR}/ci/cases/${case}.yaml"
ci_status=$?
set -e
if [[ ${ci_status} -eq 0 ]]; then
Expand Down