Skip to content

Commit cd7b284

Browse files
authored
Merge pull request #285 from xylar/add_compass_metapackage
Add compass metapackage
2 parents 750a482 + dcb3ed7 commit cd7b284

File tree

4 files changed

+230
-0
lines changed

4 files changed

+230
-0
lines changed

compass/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE

compass/build_and_upload.bash

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
conda build -c conda-forge -c e3sm .
4+
5+
#anaconda upload -u e3sm ${HOME}/miniconda3/conda-bld/noarch/compass*.tar.gz

compass/create_new_env.bash

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
#!/bin/bash
2+
3+
check_env () {
4+
for module in "geometric_features" "mpas_tools" "jigsawpy"
5+
do
6+
if python -c "import ${module}"; then
7+
echo " ${module} passed"
8+
else
9+
echo " ${module} failed"
10+
exit 1
11+
fi
12+
done
13+
14+
for exec in "gpmetis" "ffmpeg"
15+
do
16+
if ${exec} --help; then
17+
echo " ${exec} passed"
18+
else
19+
echo " ${exec} failed"
20+
exit 1
21+
fi
22+
done
23+
}
24+
25+
26+
# Modify the following to choose which e3sm-unified version(s) the python version(s) are installed and whether to make
27+
# an environment with x-windows support under cdat (cdatx) and/or without (nox). Typically, both environments should
28+
# be created.
29+
versions=(0.1.0)
30+
pythons=(3.7)
31+
32+
default_python=3.7
33+
34+
# Any subsequent commands which fail will cause the shell script to exit
35+
# immediately
36+
set -e
37+
38+
world_read="True"
39+
40+
# The rest of the script should not need to be modified
41+
if [[ $HOSTNAME = "cori"* ]] || [[ $HOSTNAME = "dtn"* ]]; then
42+
base_path="/global/cfs/cdirs/acme/software/anaconda_envs/base"
43+
activ_path="/global/cfs/cdirs/acme/software/anaconda_envs"
44+
group="acme"
45+
elif [[ $HOSTNAME = "acme1"* ]] || [[ $HOSTNAME = "aims4"* ]]; then
46+
base_path="/usr/local/e3sm_unified/envs/base"
47+
activ_path="/usr/local/e3sm_unified/envs"
48+
group="climate"
49+
elif [[ $HOSTNAME = "blueslogin"* ]]; then
50+
base_path="/lcrc/soft/climate/e3sm-unified/base"
51+
activ_path="/lcrc/soft/climate/e3sm-unified"
52+
group="climate"
53+
elif [[ $HOSTNAME = "rhea"* ]]; then
54+
base_path="/ccs/proj/cli900/sw/rhea/e3sm-unified/base"
55+
activ_path="/ccs/proj/cli900/sw/rhea/e3sm-unified"
56+
group="cli900"
57+
elif [[ $HOSTNAME = "cooley"* ]]; then
58+
base_path="/lus/theta-fs0/projects/ccsm/acme/tools/e3sm-unified/base"
59+
activ_path="/lus/theta-fs0/projects/ccsm/acme/tools/e3sm-unified"
60+
group="ccsm"
61+
elif [[ $HOSTNAME = "compy"* ]]; then
62+
base_path="/compyfs/software/e3sm-unified/base"
63+
activ_path="/compyfs/software/e3sm-unified"
64+
group="users"
65+
elif [[ $HOSTNAME = "gr-fe"* ]] || [[ $HOSTNAME = "wf-fe"* ]]; then
66+
base_path="/usr/projects/climate/SHARED_CLIMATE/anaconda_envs/base"
67+
activ_path="/usr/projects/climate/SHARED_CLIMATE/anaconda_envs"
68+
group="climate"
69+
elif [[ $HOSTNAME = "burnham"* ]]; then
70+
base_path="/home/xylar/Desktop/test_e3sm_unified/base"
71+
activ_path="/home/xylar/Desktop/test_e3sm_unified"
72+
group="xylar"
73+
else
74+
echo "Unknown host name $HOSTNAME. Add env_path and group for this machine to the script."
75+
exit 1
76+
fi
77+
78+
if [ ! -d $base_path ]; then
79+
miniconda=Miniconda3-latest-Linux-x86_64.sh
80+
wget https://repo.continuum.io/miniconda/$miniconda
81+
/bin/bash $miniconda -b -p $base_path
82+
rm $miniconda
83+
fi
84+
85+
# activate the new environment
86+
source ${base_path}/etc/profile.d/conda.sh
87+
conda activate
88+
89+
conda config --add channels conda-forge
90+
conda config --set channel_priority strict
91+
conda update -y --all
92+
93+
for version in "${versions[@]}"
94+
do
95+
for python in "${pythons[@]}"
96+
do
97+
channels="--override-channels -c conda-forge -c defaults -c e3sm"
98+
packages="python=$python compass=${version}"
99+
100+
if [[ "$python" == "$default_python" ]]; then
101+
suffix=""
102+
else
103+
suffix="_py${python}"
104+
fi
105+
106+
env_name=compass_${version}${suffix}
107+
if [ ! -d "$base_path/envs/$env_name" ]; then
108+
echo creating "$env_name"
109+
conda create -n "$env_name" -y $channels $packages
110+
conda activate "$env_name"
111+
conda deactivate
112+
else
113+
echo "$env_name" already exists
114+
fi
115+
116+
conda activate "$env_name"
117+
check_env
118+
conda deactivate
119+
120+
mkdir -p "$activ_path"
121+
122+
# make activation scripts
123+
script=""
124+
script="${script}"$'\n'"if [ -x \"\$(command -v module)\" ] ; then"
125+
script="${script}"$'\n'" module unload python"
126+
script="${script}"$'\n'"fi"
127+
script="${script}"$'\n'"source ${base_path}/etc/profile.d/conda.sh"
128+
script="${script}"$'\n'"conda activate $env_name"
129+
file_name=$activ_path/load_latest_compass${suffix}.sh
130+
rm -f "$file_name"
131+
echo "${script}" > "$file_name"
132+
done
133+
done
134+
135+
# delete the tarballs and any unused packages
136+
conda clean -y -p -t
137+
138+
# continue if errors happen from here on
139+
set +e
140+
141+
echo "changing permissions on activation scripts"
142+
chown -R "$USER":$group $activ_path/load_latest_compass*
143+
if [ $world_read == "True" ]; then
144+
chmod -R go+r $activ_path/load_latest_compass*
145+
chmod -R go-w $activ_path/load_latest_compass*
146+
else
147+
chmod -R g+r $activ_path/load_latest_compass*
148+
chmod -R g-w $activ_path/load_latest_compass*
149+
chmod -R o-rwx $activ_path/load_latest_compass*
150+
fi
151+
152+
echo "changing permissions on environments"
153+
cd $base_path
154+
echo " changing owner"
155+
chown -R "$USER:$group" .
156+
if [ $world_read == "True" ]; then
157+
echo " adding group/world read"
158+
chmod -R go+rX .
159+
echo " removing group/world write"
160+
chmod -R go-w .
161+
else
162+
echo " adding group read"
163+
chmod -R g+rX .
164+
echo " removing group write"
165+
chmod -R g-w .
166+
echo " removing world read/write"
167+
chmod -R o-rwx .
168+
fi
169+
echo " done."
170+

compass/meta.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{% set name = "compass" %}
2+
{% set version = "0.1.0" %}
3+
4+
package:
5+
name: {{ name|lower }}
6+
version: {{ version }}
7+
8+
build:
9+
noarch: python
10+
number: 0
11+
12+
requirements:
13+
host:
14+
- python
15+
run:
16+
- python
17+
- geometric_features 0.1.6
18+
- mpas_tools 0.0.8
19+
- jigsaw 0.9.12
20+
- jigsawpy 0.2.1
21+
- metis
22+
- pyflann
23+
- scikit-image
24+
- cartopy
25+
- cartopy_offlinedata
26+
- pyamg
27+
- ffmpeg
28+
29+
test:
30+
imports:
31+
- geometric_features
32+
- mpas_tools
33+
- jigsawpy
34+
commands:
35+
- gpmetis --help
36+
- ffmpeg -help
37+
38+
about:
39+
home: https://github.com/MPAS-Dev/MPAS-Model/tree/ocean/develop/testing_and_setup/compass
40+
license: BSD 3-Clause
41+
license_family: BSD
42+
license_file: LICENSE
43+
summary: 'A metapackage for creating test cases in the Model for Prediction Across Scales'
44+
description: |
45+
A metapackage of all the tools needed by COMPASS (Configuration Of Model
46+
for Prediction Across Scales Setups), a framework for setting up and running
47+
ocean and land-ice test cases in the Model for Prediction Across Scales
48+
(MPAS) framework.
49+
doc_url: https://github.com/MPAS-Dev/MPAS-Model/blob/ocean/develop/testing_and_setup/compass/README_ocean.md
50+
dev_url: https://github.com/MPAS-Dev/MPAS-Model/tree/ocean/develop/testing_and_setup/compass
51+
52+
extra:
53+
recipe-maintainers:
54+
- xylar

0 commit comments

Comments
 (0)