Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Commit 94eddec

Browse files
committed
New local testing workflow
1 parent 9652c29 commit 94eddec

File tree

6 files changed

+376
-0
lines changed

6 files changed

+376
-0
lines changed

local/install_local.sh

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/bin/bash
2+
3+
# Exit immediately on failure
4+
set -e
5+
6+
###################
7+
# BENCHMARK SETUP #
8+
###################
9+
10+
# Prepare temporary directory for benchmark RMG-Py and RMG-db
11+
benchmark=$DATA_DIR/code/benchmark/$(date +%Y-%m-%d:%H:%M:%S)
12+
rm -rf $benchmark
13+
mkdir -p $benchmark
14+
cd $benchmark
15+
16+
# Prepare benchmark RMG-Py
17+
git clone -q https://github.com/ReactionMechanismGenerator/RMG-Py.git
18+
cd RMG-Py
19+
git checkout $RMGPY_BENCHMARK_BRANCH
20+
export benchmark_py_sha=$(git rev-parse HEAD)
21+
cd ..
22+
23+
# Prepare benchmark RMG-database:
24+
git clone -q https://github.com/ReactionMechanismGenerator/RMG-database.git
25+
cd RMG-database
26+
git checkout $RMGDB_BENCHMARK_BRANCH
27+
export benchmark_db_sha=$(git rev-parse HEAD)
28+
29+
# Rename benchmark code folder
30+
cd $DATA_DIR/code/benchmark
31+
32+
export benchmark_tag=py${benchmark_py_sha:0:12}_db${benchmark_db_sha:0:12}
33+
34+
if [ ! -d "${benchmark_tag}" ]; then
35+
mv $benchmark $benchmark_tag
36+
else
37+
rm -rf $benchmark
38+
fi
39+
40+
export benchmark=$DATA_DIR/code/benchmark/$benchmark_tag
41+
42+
# Prepare benchmark environment if requested
43+
if [ "$CLEAN_ENV" == true ]; then
44+
cd $benchmark/RMG-Py
45+
export benchmark_env="benchmark_env"
46+
conda remove --name $benchmark_env --all -y
47+
conda env create -n $benchmark_env -f environment_${CURRENT_OS}.yml
48+
else
49+
export benchmark_env="rmg_env"
50+
fi
51+
52+
# Compile benchmark RMG-Py:
53+
cd $benchmark/RMG-Py
54+
source activate $benchmark_env
55+
make
56+
source deactivate
57+
58+
export RMG_BENCHMARK=$benchmark/RMG-Py
59+
export RMGDB_BENCHMARK=$benchmark/RMG-database
60+
61+
#################
62+
# TESTING SETUP #
63+
#################
64+
65+
# Prepare temporary directory for testing RMG-Py and RMG-db
66+
testing=$DATA_DIR/code/testing/$(date +%Y-%m-%d:%H:%M:%S)
67+
rm -rf $testing
68+
mkdir -p $testing
69+
cd $testing
70+
71+
# Prepare testing RMG-Py:
72+
git clone -q https://github.com/ReactionMechanismGenerator/RMG-Py.git
73+
cd RMG-Py
74+
git checkout ${RMGPY_TESTING_BRANCH}
75+
export testing_py_sha=$(git rev-parse HEAD)
76+
cd ..
77+
78+
# Prepare testing RMG-database
79+
git clone -q https://github.com/ReactionMechanismGenerator/RMG-database.git
80+
cd RMG-database
81+
git checkout ${RMGDB_TESTING_BRANCH}
82+
export testing_db_sha=$(git rev-parse HEAD)
83+
84+
# Rename testing code folder
85+
cd $DATA_DIR/code/testing
86+
87+
export testing_tag=py${testing_py_sha:0:12}_db${testing_db_sha:0:12}
88+
89+
if [ ! -d "${testing_tag}" ]; then
90+
mv $testing $testing_tag
91+
else
92+
rm -rf $testing
93+
fi
94+
export testing=$DATA_DIR/code/testing/$testing_tag
95+
96+
# Prepare testing environment if requested
97+
if [ "$SEPARATE_ENV" == true]; then
98+
cd $testing/RMG-Py
99+
export testing_env="testing_env"
100+
conda remove --name $testing_env --all -y
101+
conda env create -n $testing_env -f environment_${CURRENT_OS}.yml
102+
else
103+
export testing_env=$benchmark_env
104+
fi
105+
106+
# Compile RMG-Py:
107+
cd $testing/RMG-Py
108+
source activate $testing_env
109+
make
110+
source deactivate
111+
112+
export RMG_TESTING=$testing/RMG-Py
113+
export RMGDB_TESTING=$testing/RMG-database
114+
115+
# Go to RMG-tests folder:
116+
cd $DATA_DIR
117+

local/run.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
3+
# Set RMG-tests base directory
4+
export BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
5+
echo "Local tests base dir: "$BASE_DIR
6+
7+
# Set data directory
8+
export DATA_DIR=$BASE_DIR/data_dir
9+
10+
# Figure out OS
11+
if [[ $MACHTYPE == *"apple"* ]]; then
12+
export CURRENT_OS="mac"
13+
elif [[ $MACHTYPE == *"linux"* ]]; then
14+
export CURRENT_OS="linux"
15+
else
16+
echo "$MACHTYPE not supported. Exiting..."
17+
exit 0
18+
fi
19+
echo "Current OS: "$CURRENT_OS
20+
21+
# Print input settings
22+
echo "Benchmark Branches:"
23+
echo " RMG-Py: "$RMGPY_BENCHMARK_BRANCH
24+
echo " RMG-database: "$RMGDB_BENCHMARK_BRANCH
25+
echo "Testing Branches:"
26+
echo " RMG-Py: "$RMGPY_TESTING_BRANCH
27+
echo " RMG-database: "$RMGDB_TESTING_BRANCH
28+
echo "Testing Jobs: "$JOBS
29+
echo "Data Directory: "$DATA_DIR
30+
31+
. $BASE_DIR/color_define.sh
32+
. $BASE_DIR/local/install_local.sh
33+
. $BASE_DIR/version_summary.sh
34+
35+
echo "INSTALLATION COMPLETE"
36+
37+
cd $BASE_DIR/local
38+
39+
# Run RMG test jobs
40+
if [ $JOBS == "all" ]; then
41+
for i in eg1 eg3 eg5 eg6 eg7 NC solvent_hexane MCH
42+
do
43+
if [ $PARALLEL == "true" ]; then
44+
export SBATCH_JOB_NAME=run_$i
45+
sbatch $BASE_DIR/local/submit_job.sl $i no
46+
else
47+
. $BASE_DIR/local/run_job.sh $i no
48+
fi
49+
done
50+
else
51+
if [ $PARALLEL == "true" ]; then
52+
export SBATCH_JOB_NAME=run_$i
53+
sbatch $BASE_DIR/local/submit_job.sl $JOBS no
54+
else
55+
. $BASE_DIR/local/run_job.sh $JOBS no
56+
fi
57+
fi
58+
59+
# Run thermo validation jobs
60+
if [ $THERMOVAL == "true" ]; then
61+
for i in hc_cyclics hco_cyclics rmg_internal_cyclics
62+
do
63+
. $BASE_DIR/local/thermo_val.sh $i
64+
done
65+
fi
66+

local/run_job.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
3+
job=$1
4+
scoop_test=$2
5+
6+
set -e
7+
8+
if [ -z ${RMG_BENCHMARK+x} ]; then
9+
echo "RMG variable is unset. Exiting..."
10+
exit 0
11+
fi
12+
13+
export ORIGIN_PYTHONPATH=$PYTHONPATH
14+
echo "Running Job: $1"
15+
16+
#############
17+
# BENCHMARK #
18+
#############
19+
20+
# Make folder for models generated by the benchmark version of RMG-Py/RMG-database:
21+
export benchmark_tests=$DATA_DIR/tests/benchmark/$benchmark_tag
22+
mkdir -p $benchmark_tests/rmg_jobs/$job
23+
rm -rf $benchmark_tests/rmg_jobs/$job/*
24+
cp $BASE_DIR/examples/rmg/$job/input.py $benchmark_tests/rmg_jobs/$job/input.py
25+
26+
source activate ${benchmark_env}
27+
28+
echo "Benchmark Version of RMG: "$RMG_BENCHMARK
29+
export PYTHONPATH=$RMG_BENCHMARK:$ORIGIN_PYTHONPATH
30+
31+
python $RMG_BENCHMARK/rmg.py $benchmark_tests/rmg_jobs/$job/input.py > /dev/null
32+
33+
source deactivate
34+
export PYTHONPATH=$ORIGIN_PYTHONPATH
35+
36+
###########
37+
# TESTING #
38+
###########
39+
40+
# Make folder for models generated by the test version of RMG-Py and RMG-database:
41+
export testing_tests=$DATA_DIR/tests/testing/$testing_tag
42+
mkdir -p $testing_tests/rmg_jobs/$job
43+
rm -rf $testing_tests/rmg_jobs/$job/*
44+
cp $BASE_DIR/examples/rmg/$job/input.py $testing_tests/rmg_jobs/$job/input.py
45+
46+
source activate ${testing_env}
47+
48+
echo "Test Version of RMG: "$RMG_TESTING
49+
export PYTHONPATH=$RMG_TESTING:$ORIGIN_PYTHONPATH
50+
51+
python $RMG_TESTING/rmg.py $testing_tests/rmg_jobs/$job/input.py > /dev/null
52+
53+
export PYTHONPATH=$ORIGIN_PYTHONPATH
54+
source deactivate
55+
56+
###########
57+
# COMPARE #
58+
###########
59+
60+
export check_tests=$DATA_DIR/tests/check/$testing_tag
61+
mkdir -p $check_tests/rmg_jobs/$job
62+
rm -rf $check_tests/rmg_jobs/$job/*
63+
cd $check_tests/rmg_jobs/$job
64+
65+
source activate ${benchmark_env}
66+
export PYTHONPATH=$RMG_BENCHMARK:$ORIGIN_PYTHONPATH
67+
68+
bash $BASE_DIR/check.sh $job $benchmark_tests/rmg_jobs/$job $testing_tests/rmg_jobs/$job
69+
70+
export PYTHONPATH=$ORIGIN_PYTHONPATH
71+
source deactivate
72+
73+
if [ $scoop_test == "yes" ]; then
74+
# Make folder for models generated by the test version of RMG-Py and RMG-database, with scoop enabled:
75+
mkdir -p $testing_tests/rmg_jobs/$job/scoop
76+
rm -rf $testing_tests/rmg_jobs/$job/scoop/*
77+
cp $BASE_DIR/examples/rmg/$job/input.py $testing_tests/rmg_jobs/$job/scoop/input.py
78+
echo "Version of RMG running with SCOOP: $RMG"
79+
source activate ${testing_env}
80+
export PYTHONPATH=$RMG_TESTING:$ORIGIN_PYTHONPATH
81+
82+
python -m scoop -n 1 $RMG_TESTING/rmg.py $testing_tests/rmg_jobs/$job/scoop/input.py > /dev/null
83+
84+
export PYTHONPATH=$ORIGIN_PYTHONPATH
85+
source deactivate
86+
87+
# compare both generated models
88+
mkdir -p $check_tests/rmg_jobs/$job/scoop
89+
cd $check_tests/rmg_jobs/$job/scoop
90+
source activate ${benchmark_env}
91+
export PYTHONPATH=$RMG_BENCHMARK:$ORIGIN_PYTHONPATH
92+
93+
bash $BASE_DIR/check.sh $job $benchmark_tests/rmg_jobs/$job $testing_tests/rmg_jobs/$job/scoop
94+
95+
export PYTHONPATH=$ORIGIN_PYTHONPATH
96+
source deactivate
97+
fi
98+
99+
echo "$job: TEST JOB COMPLETE"
100+

local/submit.sl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
#SBATCH -p debug
3+
#SBATCH -J RMG-test
4+
#SBATCH -n 1
5+
#SBATCH --nodelist=node03
6+
#SBATCH --output=main_log.out
7+
8+
# Usage: sbatch submit.sl
9+
10+
# Specify testing branches here
11+
RMGPY_TESTING_BRANCH="test_branch"
12+
RMGDB_TESTING_BRANCH="master"
13+
14+
# Specify benchmark branches here
15+
# These should generally be left as master
16+
RMGPY_BENCHMARK_BRANCH="master"
17+
RMGDB_BENCHMARK_BRANCH="master"
18+
19+
# Specify jobs to run
20+
# Current jobs available: eg1, eg3, eg5, eg6, eg7, NC, solvent_hexane, MCH, methane
21+
JOBS="all"
22+
23+
# Specify whether to run thermo validation
24+
THERMOVAL=true
25+
26+
# Specify whether or not to recreate the Anaconda environment
27+
# This is generally not necessary, and can be left as false
28+
CLEAN_ENV=false
29+
30+
# Specify whether or not the testing and benchmark jobs should use separate environments
31+
# This is generally not necessary, and can be left as false
32+
SEPARATE_ENV=false
33+
34+
# Specify whether to run jobs in parallel or serial
35+
PARALLEL=true
36+
37+
# Start the job
38+
. ./run.sh
39+

local/submit_job.sl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
#SBATCH -p debug
3+
#SBATCH -n 1
4+
5+
JOB=$1
6+
SCOOP=$2
7+
8+
. $BASE_DIR/local/run_job.sh $JOB $SCOOP

local/thermo_val.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
job=$1
3+
4+
export ORIGIN_PYTHONPATH=$PYTHONPATH
5+
6+
#############
7+
# BENCHMARK #
8+
#############
9+
10+
# Make folder for models generated by the benchmark version of RMG-Py/RMG-database:
11+
export benchmark_tests=$DATA_DIR/tests/benchmark/$benchmark_tag
12+
mkdir -p $benchmark_tests/thermo_val_jobs/$job
13+
14+
cp $BASE_DIR/examples/thermo_val/$job/dataset.txt $benchmark_tests/thermo_val_jobs/$job/dataset.txt
15+
16+
echo "Benchmark Version of RMG: "$RMG_BENCHMARK
17+
echo "Running thermo validation on benchmark version..."
18+
19+
source activate ${benchmark_env}
20+
export PYTHONPATH=$RMG_BENCHMARK:$ORIGIN_PYTHONPATH
21+
22+
python $BASE_DIR/thermo_val/evaluate.py -d $benchmark_tests/thermo_val_jobs/$job/dataset.txt -pb $RMGPY_BENCHMARK_BRANCH -dbb $RMGDB_BENCHMARK_BRANCH -psha ${benchmark_py_sha} -dbsha ${benchmark_db_sha}
23+
24+
source deactivate
25+
export PYTHONPATH=$ORIGIN_PYTHONPATH
26+
27+
###########
28+
# TESTING #
29+
###########
30+
31+
# Make folder for models generated by the test version of RMG-Py and RMG-database:
32+
export testing_tests=$DATA_DIR/tests/testing/$testing_tag
33+
mkdir -p $testing_tests/thermo_val_jobs/$job
34+
35+
cp $BASE_DIR/examples/thermo_val/$job/dataset.txt $testing_tests/thermo_val_jobs/$job/dataset.txt
36+
37+
echo "Testing Version of RMG: "$RMG_TESTING
38+
echo "Running thermo validation on testing version..."
39+
40+
source activate ${testing_env}
41+
export PYTHONPATH=$RMG_TESTING:$ORIGIN_PYTHONPATH
42+
43+
python $BASE_DIR/thermo_val/evaluate.py -d $testing_tests/thermo_val_jobs/$job/dataset.txt -pb $RMGPY_TESTING_BRANCH -dbb $RMGDB_TESTING_BRANCH -psha ${testing_py_sha} -dbsha ${testing_db_sha}
44+
45+
source deactivate
46+
export PYTHONPATH=$ORIGIN_PYTHONPATH

0 commit comments

Comments
 (0)