mirror of
https://github.com/JHUAPL/kaiju.git
synced 2026-01-09 15:17:56 -05:00
Overhauled reproducibiity check.
This commit is contained in:
@@ -20,21 +20,26 @@ echo 'The currently loaded modules are:'
|
||||
module list
|
||||
|
||||
echo 'Loading python environment.'
|
||||
export CONDARC="{{ condarc }}"
|
||||
export CONDA_ENVS_PATH="{{ conda_envs_path }}"
|
||||
mage_miniconda3="{{ mage_test_root }}/miniconda3"
|
||||
mage_conda="${mage_miniconda3}/bin/conda"
|
||||
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
|
||||
if [ $? -eq 0 ]; then
|
||||
eval "$__conda_setup"
|
||||
else
|
||||
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
|
||||
. "$mage_miniconda3/etc/profile.d/conda.sh"
|
||||
mage_test_root=$HOME
|
||||
if [ -d "${mage_test_root}/miniconda3" ]; then
|
||||
echo 'Loading local miniconda3'
|
||||
mage_miniconda3="${mage_test_root}/miniconda3"
|
||||
mage_conda="${mage_miniconda3}/bin/conda"
|
||||
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
|
||||
if [ $? -eq 0 ]; then
|
||||
eval "$__conda_setup"
|
||||
else
|
||||
export PATH="$mage_miniconda3/bin:$PATH"
|
||||
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
|
||||
. "$mage_miniconda3/etc/profile.d/conda.sh"
|
||||
else
|
||||
export PATH="$mage_miniconda3/bin:$PATH"
|
||||
fi
|
||||
fi
|
||||
unset __conda_setup
|
||||
else
|
||||
echo 'Loading conda module'
|
||||
module load conda
|
||||
fi
|
||||
unset __conda_setup
|
||||
conda activate {{ conda_environment }}
|
||||
echo "The current conda environment is ${CONDA_PREFIX}."
|
||||
|
||||
@@ -42,18 +47,14 @@ echo 'Setting up MAGE environment.'
|
||||
source {{ kaijuhome }}/scripts/setupEnvironment.sh
|
||||
echo "The kaiju software is located at ${KAIJUHOME}."
|
||||
|
||||
echo 'Setting up kaipy environment.'
|
||||
source {{ kaipy_private_root }}/kaipy/scripts/setupEnvironment.sh
|
||||
echo "The kaipy software is located at ${KAIPYHOME}."
|
||||
|
||||
echo 'Setting environment variables.'
|
||||
export TMPDIR={{ tmpdir }}
|
||||
export SLACK_BOT_TOKEN={{ slack_bot_token }}
|
||||
export OMP_NUM_THREADS=128
|
||||
export MPI_TYPE_DEPTH=32
|
||||
export KMP_STACKSIZE=128M
|
||||
export MAGE_TEST_ROOT="{{ mage_test_root }}"
|
||||
export MAGE_TEST_SET_ROOT={{ mage_test_set_root }}
|
||||
export KAIJU_TEST_ROOT="{{ kaiju_test_root }}"
|
||||
export KAIJU_TEST_SET_ROOT={{ kaiju_test_set_root }}
|
||||
export BRANCH_OR_COMMIT={{ branch_or_commit }}
|
||||
|
||||
echo 'The active environment variables are:'
|
||||
|
||||
@@ -9,7 +9,6 @@ Authors
|
||||
-------
|
||||
Jeff Garretson
|
||||
Eric Winter
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@@ -40,6 +39,17 @@ DEFAULT_MODULE_SET_FILE = os.path.join(
|
||||
KAIJUHOME, "testingScripts", "mage_build_test_modules", "intel_mpich.lst"
|
||||
)
|
||||
|
||||
# Default values for command-line arguments when none are supplied (such as
|
||||
# when this code is called by external code).
|
||||
args_default = {
|
||||
"debug": False,
|
||||
"loud": False,
|
||||
"slack_on_fail": False,
|
||||
"test": False,
|
||||
"verbose": False,
|
||||
"module_set_file": DEFAULT_MODULE_SET_FILE,
|
||||
}
|
||||
|
||||
# Root of directory tree for this set of tests.
|
||||
KAIJU_TEST_SET_ROOT = os.environ["KAIJU_TEST_SET_ROOT"]
|
||||
|
||||
@@ -53,11 +63,6 @@ REPRODUCIBILITY_CHECK_DIRECTORY_PREFIX = "reproducibility_check_"
|
||||
# Path to directory containing the test scripts
|
||||
TEST_SCRIPTS_DIRECTORY = os.path.join(KAIJUHOME, "testingScripts")
|
||||
|
||||
# List of weekly dash test files to copy
|
||||
WEEKLY_DASH_TEST_FILES = [
|
||||
"weeklyDashGo.xml",
|
||||
]
|
||||
|
||||
# Path to jinja2 template file for PBS script for build job.
|
||||
BUILD_MAGE_PBS_TEMPLATE_FILE = os.path.join(
|
||||
TEST_SCRIPTS_DIRECTORY, "build_mage-template.pbs"
|
||||
@@ -75,6 +80,11 @@ RUN_MAGE_PBS_TEMPLATE_FILE = os.path.join(
|
||||
RUN1_MAGE_PBS_SCRIPT = "run1_mage.pbs"
|
||||
RUN2_MAGE_PBS_SCRIPT = "run2_mage.pbs"
|
||||
|
||||
# List of weekly dash test files to copy
|
||||
WEEKLY_DASH_TEST_FILES = [
|
||||
"weeklyDashGo.xml",
|
||||
]
|
||||
|
||||
# Path to jinja2 template file for PBS script for comparison.
|
||||
MAGE_REPRODUCIBILITY_CHECK_PBS_TEMPLATE_FILE = os.path.join(
|
||||
TEST_SCRIPTS_DIRECTORY, "mage_reproducibility_check-template.pbs"
|
||||
@@ -84,6 +94,35 @@ MAGE_REPRODUCIBILITY_CHECK_PBS_TEMPLATE_FILE = os.path.join(
|
||||
MAGE_REPRODUCIBILITY_CHECK_PBS_SCRIPT = "mage_reproducibility_check.pbs"
|
||||
|
||||
|
||||
def create_command_line_parser():
|
||||
"""Create the command-line argument parser.
|
||||
|
||||
Create the parser for command-line arguments.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
None
|
||||
|
||||
Returns
|
||||
-------
|
||||
parser : argparse.ArgumentParser
|
||||
Command-line argument parser for this script.
|
||||
|
||||
Raises
|
||||
------
|
||||
None
|
||||
"""
|
||||
parser = common.create_command_line_parser(DESCRIPTION)
|
||||
parser.add_argument(
|
||||
"--module_set_file", "-f", default=DEFAULT_MODULE_SET_FILE,
|
||||
help=(
|
||||
"Path to text file containing set of modules to build with "
|
||||
"(default: %(default)s)"
|
||||
)
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
def mage_reproducibility_check(args: dict):
|
||||
"""Perform a MAGE reproducibility check.
|
||||
|
||||
@@ -123,13 +162,14 @@ def mage_reproducibility_check(args: dict):
|
||||
subprocess.CalledProcessError
|
||||
If an exception occurs in subprocess.run()
|
||||
"""
|
||||
# Local convenience variables.
|
||||
debug = args.get("debug", False)
|
||||
loud = args.get("loud", False)
|
||||
slack_on_fail = args.get("slack_on_fail", False)
|
||||
test = args.get("test", False)
|
||||
verbose = args.get("verbose", False)
|
||||
module_set_file = args.get("module_set_file", DEFAULT_MODULE_SET_FILE)
|
||||
# Set missing arguments to defaults.
|
||||
args = args_default | args
|
||||
debug = args["debug"]
|
||||
loud = args["loud"]
|
||||
slack_on_fail = args["slack_on_fail"]
|
||||
test = args["test"]
|
||||
verbose = args["verbose"]
|
||||
module_set_file = args["module_set_file"]
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
@@ -146,7 +186,6 @@ def mage_reproducibility_check(args: dict):
|
||||
module_names, cmake_environment, cmake_options = (
|
||||
common.read_build_module_list_file(module_set_file)
|
||||
)
|
||||
print(f"module_names = {module_names}")
|
||||
|
||||
# Extract the name of the list.
|
||||
module_set_name = os.path.split(module_set_file)[-1].rstrip(".lst")
|
||||
@@ -197,8 +236,7 @@ def mage_reproducibility_check(args: dict):
|
||||
|
||||
# Submit the job.
|
||||
cmd = f"qsub {BUILD_MAGE_PBS_SCRIPT}"
|
||||
cproc = subprocess.run(cmd, shell=True, check=True, text=True,
|
||||
capture_output=True)
|
||||
cproc = subprocess.run(cmd, shell=True, text=True, capture_output=True)
|
||||
jobid_build = cproc.stdout.split(".")[0]
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
@@ -240,14 +278,12 @@ def mage_reproducibility_check(args: dict):
|
||||
pbs_options["walltime"] = "08:00:00"
|
||||
pbs_options["modules"] = module_names
|
||||
pbs_options["conda_environment"] = os.environ["CONDA_ENVIRONMENT"]
|
||||
pbs_options["kaiju_test_root"] = os.environ["KAIJU_TEST_ROOT"]
|
||||
pbs_options["kaiju_test_set_root"] = os.environ["KAIJU_TEST_SET_ROOT"]
|
||||
pbs_options["kaijuhome"] = KAIJUHOME
|
||||
pbs_options["tmpdir"] = os.environ["TMPDIR"]
|
||||
pbs_options["slack_bot_token"] = os.environ["SLACK_BOT_TOKEN"]
|
||||
pbs_options["kaiju_test_root"] = os.environ["KAIJU_TEST_ROOT"]
|
||||
pbs_options["kaiju_test_set_root"] = os.environ["KAIJU_TEST_SET_ROOT"]
|
||||
pbs_options["branch_or_commit"] = os.environ["BRANCH_OR_COMMIT"]
|
||||
pbs_options["cmake_cmd"] = cmake_cmd
|
||||
pbs_options["make_cmd"] = make_cmd
|
||||
pbs_options["genLFM_cmd"] = genLFM_cmd
|
||||
pbs_options["cda2wind_cmd"] = cda2wind_cmd
|
||||
pbs_options["mpiexec_cmd"] = mpiexec_cmd
|
||||
@@ -320,11 +356,11 @@ def mage_reproducibility_check(args: dict):
|
||||
pbs_options["walltime"] = "02:00:00"
|
||||
pbs_options["modules"] = module_names
|
||||
pbs_options["conda_environment"] = os.environ["CONDA_ENVIRONMENT"]
|
||||
pbs_options["kaiju_test_root"] = os.environ["KAIJU_TEST_ROOT"]
|
||||
pbs_options["kaiju_test_set_root"] = os.environ["KAIJU_TEST_SET_ROOT"]
|
||||
pbs_options["kaijuhome"] = KAIJUHOME
|
||||
pbs_options["tmpdir"] = os.environ["TMPDIR"]
|
||||
pbs_options["slack_bot_token"] = os.environ["SLACK_BOT_TOKEN"]
|
||||
pbs_options["kaiju_test_root"] = os.environ["KAIJU_TEST_ROOT"]
|
||||
pbs_options["kaiju_test_set_root"] = os.environ["KAIJU_TEST_SET_ROOT"]
|
||||
pbs_options["branch_or_commit"] = os.environ["BRANCH_OR_COMMIT"]
|
||||
pbs_options["xml1"] = os.path.join(build_directory, "run1",
|
||||
"weeklyDashGo.xml")
|
||||
@@ -389,31 +425,44 @@ def mage_reproducibility_check(args: dict):
|
||||
if debug:
|
||||
print(f"Ending {sys.argv[0]} at {datetime.datetime.now()}")
|
||||
|
||||
# Return nominal status.
|
||||
return 0
|
||||
|
||||
|
||||
def main():
|
||||
"""Driver for command-line version of code."""
|
||||
# Set up the command-line parser.
|
||||
parser = common.create_command_line_parser(DESCRIPTION)
|
||||
"""Main program code for the command-line version of this file.
|
||||
|
||||
# # Add additional arguments specific to this script.
|
||||
# parser.add_argument(
|
||||
# "--module_set_file", "-f", default=DEFAULT_MODULE_SET_FILE,
|
||||
# help=(
|
||||
# "Path to text file containing set of modules to build with "
|
||||
# "(default: %(default)s)"
|
||||
# )
|
||||
# )
|
||||
This is the main program code for the command-line version of this file.
|
||||
It processes command-line options, then calls the primary code.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
None
|
||||
|
||||
Returns
|
||||
-------
|
||||
None
|
||||
|
||||
Raises
|
||||
------
|
||||
None
|
||||
"""
|
||||
# Set up the command-line parser.
|
||||
parser = create_command_line_parser()
|
||||
|
||||
# Parse the command-line arguments.
|
||||
args = parser.parse_args()
|
||||
if args.debug:
|
||||
print(f"args = {args}")
|
||||
|
||||
# Convert the arguments from Namespace to dict.
|
||||
args = vars(args)
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
# Pass the command-line arguments to the main function as a dict.
|
||||
mage_reproducibility_check(args)
|
||||
# Call the main program logic. Note that the Namespace object (args)
|
||||
# returned from the option parser is converted to a dict using vars().
|
||||
mage_reproducibility_check(vars(args))
|
||||
|
||||
# Exit normally.
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -20,21 +20,26 @@ echo 'The currently loaded modules are:'
|
||||
module list
|
||||
|
||||
echo 'Loading python environment.'
|
||||
export CONDARC="{{ condarc }}"
|
||||
export CONDA_ENVS_PATH="{{ conda_envs_path }}"
|
||||
mage_miniconda3="{{ mage_test_root }}/miniconda3"
|
||||
mage_conda="${mage_miniconda3}/bin/conda"
|
||||
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
|
||||
if [ $? -eq 0 ]; then
|
||||
eval "$__conda_setup"
|
||||
else
|
||||
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
|
||||
. "$mage_miniconda3/etc/profile.d/conda.sh"
|
||||
mage_test_root=$HOME
|
||||
if [ -d "${mage_test_root}/miniconda3" ]; then
|
||||
echo 'Loading local miniconda3'
|
||||
mage_miniconda3="${mage_test_root}/miniconda3"
|
||||
mage_conda="${mage_miniconda3}/bin/conda"
|
||||
__conda_setup="$($mage_conda 'shell.bash' 'hook' 2> /dev/null)"
|
||||
if [ $? -eq 0 ]; then
|
||||
eval "$__conda_setup"
|
||||
else
|
||||
export PATH="$mage_miniconda3/bin:$PATH"
|
||||
if [ -f "$mage_miniconda3/etc/profile.d/conda.sh" ]; then
|
||||
. "$mage_miniconda3/etc/profile.d/conda.sh"
|
||||
else
|
||||
export PATH="$mage_miniconda3/bin:$PATH"
|
||||
fi
|
||||
fi
|
||||
unset __conda_setup
|
||||
else
|
||||
echo 'Loading conda module'
|
||||
module load conda
|
||||
fi
|
||||
unset __conda_setup
|
||||
conda activate {{ conda_environment }}
|
||||
echo "The current conda environment is ${CONDA_PREFIX}."
|
||||
|
||||
@@ -42,18 +47,14 @@ echo 'Setting up MAGE environment.'
|
||||
source {{ kaijuhome }}/scripts/setupEnvironment.sh
|
||||
echo "The kaiju software is located at ${KAIJUHOME}."
|
||||
|
||||
echo 'Setting up kaipy environment.'
|
||||
source {{ kaipy_private_root }}/kaipy/scripts/setupEnvironment.sh
|
||||
echo "The kaipy software is located at ${KAIPYHOME}."
|
||||
|
||||
echo 'Setting environment variables.'
|
||||
export TMPDIR={{ tmpdir }}
|
||||
export SLACK_BOT_TOKEN={{ slack_bot_token }}
|
||||
export OMP_NUM_THREADS=128
|
||||
export MPI_TYPE_DEPTH=32
|
||||
export KMP_STACKSIZE=128M
|
||||
export MAGE_TEST_ROOT="{{ mage_test_root }}"
|
||||
export MAGE_TEST_SET_ROOT={{ mage_test_set_root }}
|
||||
export KAIJU_TEST_ROOT={{ kaiju_test_root }}
|
||||
export KAIJU_TEST_SET_ROOT={{ kaiju_test_set_root }}
|
||||
export BRANCH_OR_COMMIT={{ branch_or_commit }}
|
||||
|
||||
echo 'The active environment variables are:'
|
||||
|
||||
Reference in New Issue
Block a user