This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
install.sh
138 lines (115 loc) · 4.07 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
set -o verbose # echo commands before executing.
# create a folder with benchmark version of RMG-Py and RMG-database:
# go to parent-folder of the RMG-tests repo:
cd ..
# prepare benchmark RMG-Py and RMG-db
export benchmark=$BASE_DIR/code/benchmark
echo "benchmark=$benchmark" >> $GITHUB_ENV
mkdir -p $benchmark
cd $benchmark
# clone benchmark RMG-Py
if [ ! -d "RMG-Py" ]; then
# the directory was not cached, so clone it
git clone https://github.com/ReactionMechanismGenerator/RMG-Py.git
cd RMG-Py
else
# the directory was cached, make sure that it's up to date
cd RMG-Py
git pull --ff-only origin main
fi
conda env create -q -n benchmark -f environment.yml
conda list -n benchmark
export RMG_BENCHMARK=`pwd`
echo "RMG_BENCHMARK=$RMG_BENCHMARK" >> $GITHUB_ENV
cd ..
# clone benchmark RMG-database:
if [ ! -d "RMG-database" ]; then
git clone https://github.com/ReactionMechanismGenerator/RMG-database.git
cd RMG-database
else
cd RMG-database
git pull --ff-only origin main
fi
export RMGDB_BENCHMARK=`pwd`
echo "RMGDB_BENCHMARK=$RMGDB_BENCHMARK" >> $GITHUB_ENV
cd ..
# prepare testing RMG-Py and RMG-db
export testing=$BASE_DIR/code/testing
echo "testing=$testing" >> $GITHUB_ENV
mkdir -p $testing
cd $testing
if [ $RMG_TESTING_BRANCH == "main" ]; then
# set the RMG directory variable
export RMG_TESTING=$RMG_BENCHMARK
echo "RMG_TESTING=$RMG_TESTING" >> $GITHUB_ENV
# copy the conda environment
conda create --name testing --clone benchmark
else
# clone entire RMG-Py
if [ ! -d "RMG-Py" ]; then
git clone -b ${RMG_TESTING_BRANCH} https://github.com/ReactionMechanismGenerator/RMG-Py.git
cd RMG-Py
else
cd RMG-Py
git fetch origin ${RMG_TESTING_BRANCH}
git checkout ${RMG_TESTING_BRANCH}
git reset --hard origin/${RMG_TESTING_BRANCH}
fi
conda env create -q -n testing -f environment.yml
export RMG_TESTING=`pwd`
echo "RMG_TESTING=$RMG_TESTING" >> $GITHUB_ENV
cd ..
fi
if [ $RMGDB_TESTING_BRANCH == "main" ]; then
# set the RMG database directory
export RMGDB_TESTING=$RMGDB_BENCHMARK
echo "RMGDB_TESTING=$RMGDB_TESTING" >> $GITHUB_ENV
else
# clone RMG-database
if [ ! -d "RMG-database" ]; then
git clone -b ${RMGDB_TESTING_BRANCH} https://github.com/ReactionMechanismGenerator/RMG-database.git
cd RMG-database
else
cd RMG-database
git fetch origin ${RMGDB_TESTING_BRANCH}
git checkout ${RMGDB_TESTING_BRANCH}
git reset --hard origin/${RMGDB_TESTING_BRANCH}
fi
export RMGDB_TESTING=`pwd`
echo "RMGDB_TESTING=$RMGDB_TESTING" >> $GITHUB_ENV
cd ..
fi
source "$BASE_DIR/.bash_profile"
conda env list
# Get the conda environments from conda env list
# pick the last column of the row with keyword 'testing' or 'benchmark'
TESTING_CONDA_ENV=$(conda env list | awk '{print $NF}' | grep testing)
BENCHMARK_CONDA_ENV=$(conda env list | awk '{print $NF}' | grep benchmark)
echo "TESTING_CONDA_ENV=$TESTING_CONDA_ENV" >> $GITHUB_ENV
echo "BENCHMARK_CONDA_ENV=$BENCHMARK_CONDA_ENV" >> $GITHUB_ENV
# Install and link Julia dependencies
echo "Installing and linking Julia dependencies"
conda activate $BENCHMARK_CONDA_ENV
export PYTHONPATH=$RMG_BENCHMARK:$PYTHONPATH
export PATH=$RMG_BENCHMARK:$PATH
python -c "import julia; julia.install(); import diffeqpy; diffeqpy.install()"
julia -e 'using Pkg; Pkg.add(PackageSpec(name="ReactionMechanismSimulator",rev="main")); using ReactionMechanismSimulator'
ln -sfn $(which python-jl) $(which python)
conda deactivate
conda activate $TESTING_CONDA_ENV
export PYTHONPATH=$RMG_TESTING:$PYTHONPATH
export PATH=$RMG_TESTING:$PATH
python -c "import julia; julia.install(); import diffeqpy; diffeqpy.install()"
julia -e 'using Pkg; Pkg.add(PackageSpec(name="ReactionMechanismSimulator",rev="main")); using ReactionMechanismSimulator'
ln -sfn $(which python-jl) $(which python)
conda deactivate
# setup MOPAC for both environments
conda activate $BENCHMARK_CONDA_ENV
yes 'Yes' | $BENCHMARK_CONDA_ENV/bin/mopac $MOPACKEY > /dev/null
conda deactivate
conda activate $TESTING_CONDA_ENV
yes 'Yes' | $TESTING_CONDA_ENV/bin/mopac $MOPACKEY > /dev/null
conda deactivate
# go to RMG-tests folder
cd $BASE_DIR