Skip to content

Commit 72d5cb8

Browse files
committed
Added venv creation script based on Jeff Mast's GMD install script.
1 parent e7a01d8 commit 72d5cb8

File tree

4 files changed

+228
-0
lines changed

4 files changed

+228
-0
lines changed

install-ampl/ampl-venv.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
cd $DIR
5+
6+
# --- begin: must be sourced guard ---
7+
(return 0 2>/dev/null) || {
8+
echo "b This script must be sourced, not executed."
9+
echo " Use: source ${BASH_SOURCE[0]} or . ${BASH_SOURCE[0]}"
10+
exit 1
11+
}
12+
# --- end: must be sourced guard ---
13+
14+
PY_VER=3.10
15+
PY_VER_STR="${PY_VER//./}"
16+
17+
# load system python module
18+
echo module load python/$PY_VER
19+
module load python/$PY_VER || return 1
20+
21+
# activate the venv
22+
VENV=$(realpath venvs/ampl-py${PY_VER_STR}-venv/bin/activate) || return 1
23+
echo "Activating ampl-py${PY_VER_STR}-venv @ $VENV"
24+
source venvs/ampl-py${PY_VER_STR}-venv/bin/activate || return 1
25+
26+
27+

install-ampl/create_venv.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
cd $DIR
5+
6+
VENV_ID=ampl
7+
SYNC_PACKAGES=0
8+
9+
PATH=~/.local/bin:$PATH
10+
UV_CMD=$(which uv)
11+
12+
if [ "$UV_CMD" = "" ]; then
13+
curl -LsSf https://astral.sh/uv/install.sh | sh
14+
fi
15+
16+
OPTIONS=(
17+
"python/3.10" "Python 3.10 " off
18+
"python/3.11" "Python 3.11 [deepchem support questionable]" off
19+
)
20+
21+
# Show checklist and capture selected values
22+
CHOICES=$(dialog --clear --title "Select Options" \
23+
--checklist "Use SPACE to select/unselect, ENTER to confirm:" 20 60 10 \
24+
"${OPTIONS[@]}" \
25+
3>&1 1>&2 2>&3)
26+
27+
dialog --clear \
28+
--title "Sync Packages" \
29+
--yesno "Do you want to sync packages in the venvs?" 8 60
30+
31+
response=$?
32+
33+
if [[ $response -eq 0 ]]; then
34+
SYNC_PACKAGES=1
35+
else
36+
SYNC_PACKAGES=0
37+
fi
38+
39+
clear # remove dialog UI
40+
41+
# CHOICES is a quoted space-separated list of values, e.g. "build" "limits"
42+
# Remove quotes and loop
43+
for choice in $CHOICES; do
44+
# Remove surrounding quotes
45+
val="${choice%\"}"
46+
val="${val#\"}"
47+
module_name=$val
48+
python_version="${val#*/}"
49+
python_version_str="${python_version//./}"
50+
venv_name="${VENV_ID}-py${python_version_str}-venv"
51+
module load $module_name
52+
if [ ! -e $(pwd)/venvs/$venv_name ]; then
53+
uv venv --python $(which python3) $(pwd)/venvs/$venv_name
54+
fi
55+
if [ $SYNC_PACKAGES -eq 1 ]; then
56+
./uv-sync.sh $python_version
57+
fi
58+
done
59+

install-ampl/pyproject.toml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
2+
[project]
3+
name = "ampl"
4+
version = "1.0"
5+
6+
# NOTE:
7+
# * deepchem only works with python <= 3.10 (and possibly 3.11)
8+
# - seems to install in python 3.11 but website says suports only
9+
# python <= 3.10
10+
# - does not work with python 3.12+ due to tensorflow-addons dependency
11+
# which is no longer supported and only has support up to python 3.11
12+
# * ampl only works with python 3.9, 3.10, 3.11 (due to deepchem)
13+
# - encoders / decoders need python 3.9
14+
# - everthing else works with python 3.9 and 3.10 (and possibly 3.11)
15+
# * this will install on python 3.12 but won't have deepchem
16+
requires-python = ">=3.9,<3.13"
17+
18+
# Dependencies for all Python versions
19+
dependencies = [
20+
"setuptools",
21+
"pip",
22+
23+
# core dependencies
24+
"torch_cluster",
25+
"torch_scatter",
26+
"torch_sparse",
27+
"torch_spline_conv",
28+
"torch-geometric",
29+
30+
# deepchem 2.8.0 deps [NOTE: may not work on python >= 3.11]
31+
"deepchem[torch,tensorflow]==2.8.0; python_version >= '3.10' and python_version < '3.12'",
32+
33+
# deepchem[tensorflow] deps
34+
"tensorflow-cpu==2.14.0; python_version >= '3.10' and python_version < '3.12'",
35+
36+
# atomsci-ampl deps [need to be added to atomsci-ampl]
37+
"molvs",
38+
"xgboost",
39+
"umap-learn",
40+
"imbalanced-learn",
41+
"ipykernel",
42+
"ipython",
43+
"pytest",
44+
"seaborn",
45+
"matplotcheck",
46+
47+
# code repos
48+
"atomsci-ampl; python_version >= '3.10' and python_version < '3.12'",
49+
"atomsci-clients",
50+
51+
# rdkit
52+
"rdkit>=2024.3.5; python_version >= '3.10'",
53+
54+
"numpy<2",
55+
56+
# python specific versions [dgl / pyg dependent]
57+
"dgl==2.1.0; python_version >= '3.10'",
58+
59+
"pyg_lib==0.3.1; python_version >= '3.10' and python_version < '3.12'",
60+
"pyg_lib==0.4.0; python_version >= '3.12'",
61+
62+
"torch==2.1.2+cpu; python_version >= '3.10' and python_version < '3.12'",
63+
"torch==2.3.1+cpu; python_version >= '3.12'"
64+
]
65+
66+
67+
[tool.uv]
68+
allow-insecure-host = [
69+
"download.pytorch.org",
70+
"data.dgl.ai",
71+
"data.pyg.org"
72+
]
73+
74+
[[tool.uv.index]]
75+
name = "pytorch"
76+
url = "https://download.pytorch.org/whl/cpu/torch_stable.html"
77+
format = "flat"
78+
79+
[[tool.uv.index]]
80+
name = "dgl"
81+
url = "https://data.dgl.ai/wheels/repo.html"
82+
format = "flat"
83+
84+
[[tool.uv.index]]
85+
# NOTE: pyg libraries for torch >= 2.2 seem to have GLIBC incompatibilities on LC
86+
name = "pyg_lib_py312"
87+
url = "https://data.pyg.org/whl/torch-2.3.1+cpu.html"
88+
format = "flat"
89+
90+
[[tool.uv.index]]
91+
name = "pyg_lib_py310"
92+
url = "https://data.pyg.org/whl/torch-2.1.2+cpu.html"
93+
format = "flat"
94+
95+
[tool.uv.sources]
96+
# code repos
97+
atomsci-ampl = [
98+
{ git = "https://github.com/ATOMScience-org/AMPL.git", rev = "py310", marker = "python_version >= '3.10'"}
99+
]
100+
atomsci-clients = { git = "ssh://git@czgitlab.llnl.gov:7999/atom/clients.git", rev = "master" }
101+
102+
# dgl
103+
dgl = { index = "dgl" }
104+
105+
# torch
106+
torch = { index = "pytorch" }
107+
pyg_lib = [
108+
{ index = "pyg_lib_py310", marker = "python_version >= '3.10' and python_version < '3.12'" },
109+
{ index = "pyg_lib_py312", marker = "python_version >= '3.12'" },
110+
]
111+
torch_cluster = [
112+
{ index = "pyg_lib_py310", marker = "python_version >= '3.10' and python_version < '3.12'" },
113+
{ index = "pyg_lib_py312", marker = "python_version >= '3.12'" },
114+
]
115+
torch_scatter = [
116+
{ index = "pyg_lib_py310", marker = "python_version >= '3.10' and python_version < '3.12'" },
117+
{ index = "pyg_lib_py312", marker = "python_version >= '3.12'" },
118+
]
119+
torch_sparse = [
120+
{ index = "pyg_lib_py310", marker = "python_version >= '3.10' and python_version < '3.12'" },
121+
{ index = "pyg_lib_py312", marker = "python_version >= '3.12'" },
122+
]
123+
torch_spline_conv = [
124+
{ index = "pyg_lib_py310", marker = "python_version >= '3.10' and python_version < '3.12'" },
125+
{ index = "pyg_lib_py312", marker = "python_version >= '3.12'" },
126+
]
127+

install-ampl/uv-sync.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2+
cd $DIR
3+
4+
PATH=~/.local/bin:$PATH
5+
UV_CMD=$(which uv)
6+
7+
if [ "$UV_CMD" = "" ]; then
8+
curl -LsSf https://astral.sh/uv/install.sh | sh
9+
fi
10+
11+
. ampl-venv.sh || exit 1
12+
13+
# NOTE add --refresh to get latest version of repos
14+
uv sync --active
15+

0 commit comments

Comments
 (0)