forked from yhaddad/CMSDAS-MonoZ-Tutorial-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
149 lines (124 loc) · 5.04 KB
/
bootstrap.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
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env bash
if [[ "$1" == "zsh" ]]; then
cat <<EOF > shell
#!/usr/bin/env zsh
export INSTALL_LOC=/srv/
export ZDOTDIR=\$INSTALL_LOC
EOF
else
cat <<EOF > shell
#!/usr/bin/env bash
export INSTALL_LOC=/srv/
EOF
fi
if [[ "$2" == "lpc" ]]; then
cat <<EOF >> shell
# Needed to setup cluster for LPC
export CONDOR_CONFIG=\$INSTALL_LOC.condor_config
grep -v '^include' /etc/condor/config.d/01_cmslpc_interactive > .condor_config
# Need all our bind addresses
export APPTAINER_BINDPATH=/uscmst1b_scratch,/cvmfs,/cvmfs/grid.cern.ch/etc/grid-security:/etc/grid-security,/eos,/etc/pki/ca-trust,/run/user,/var/run/user,/eos
EOF
else
cat <<EOF >> shell
# Need all our bind addresses
export APPTAINER_BINDPATH=/cvmfs,/cvmfs/grid.cern.ch/etc/grid-security:/etc/grid-security,/eos,/etc/pki/ca-trust,/etc/tnsnames.ora,/run/user,/var/run/user,/eos
EOF
fi
cat <<EOF >> shell
voms-proxy-init -voms cms --valid 192:00 --out \$HOME/x509up_u\$UID
if [[ "\$1" == "" ]]; then
export COFFEA_IMAGE="coffeateam/coffea-dask-almalinux8:2024.11.0-py3.12"
# export COFFEA_IMAGE=/cvmfs/unpacked.cern.ch/registry.hub.docker.com/coffeateam/coffea-dask:latest
else
export COFFEA_IMAGE=\$1
fi
export FULL_IMAGE="/cvmfs/unpacked.cern.ch/registry.hub.docker.com/"\$COFFEA_IMAGE
EOF
if [[ "$1" == "zsh" ]]; then
cat <<EOF >> shell
SINGULARITY_SHELL=\$(which zsh) singularity exec -B \${PWD}:/srv --pwd /srv \${FULL_IMAGE} $(which zsh)
EOF
else
cat <<EOF >> shell
SINGULARITY_SHELL=\$(which bash) singularity exec -B \${PWD}:/srv --pwd /srv \${FULL_IMAGE} $(which bash) --rcfile /srv/.bashrc
EOF
fi
cat <<EOF > .bashrc
LPCJQ_VERSION="0.4.1"
install_env() {
set -e
echo "Installing shallow virtual environment in \$INSTALL_LOC.env..."
python -m venv --without-pip --system-site-packages \$INSTALL_LOC.env
unlink .env/lib64 # HTCondor can't transfer symlink to directory and it appears optional
# work around issues copying CVMFS xattr when copying to tmpdir
export TMPDIR=\$(mktemp -d -p .)
rm -rf \$TMPDIR && unset TMPDIR
# \$INSTALL_LOC.env/bin/python -m pip install --upgrade awkward dask_awkward coffea uproot
cd processing
\$INSTALL_LOC.env/bin/python -m pip install -e .
cd ..
\$INSTALL_LOC.env/bin/python -m pip install -q git+https://github.com/CoffeaTeam/lpcjobqueue.git@v\${LPCJQ_VERSION}
echo "done."
}
install_kernel() {
# work around issues copying CVMFS xattr when copying to tmpdir
export TMPDIR=\$(mktemp -d -p .)
\$INSTALL_LOC.env/bin/python -m ipykernel install --user --name monoz --display-name "monoz" --env PYTHONPATH $PYTHONPATH:$PWD --env PYTHONNOUSERSITE 1
rm -rf \$TMPDIR && unset TMPDIR
}
install_all() {
install_env
install_kernel
}
export JUPYTER_PATH=\$INSTALL_LOC.jupyter
export JUPYTER_RUNTIME_DIR=\$INSTALL_LOC.local/share/jupyter/runtime
export JUPYTER_DATA_DIR=\$INSTALL_LOC.local/share/jupyter
export IPYTHONDIR=\$INSTALL_LOC.ipython
unset GREP_OPTIONS
[[ -d \$INSTALL_LOC.env ]] || install_all
source \$INSTALL_LOC.env/bin/activate
alias pip="python -m pip"
voms-proxy-init -voms cms -vomses /etc/grid-security/vomses/ --valid 192:00 --out \$HOME/x509up_u\$UID
# pip show lpcjobqueue 2>/dev/null | grep -q "Version: \${LPCJQ_VERSION}" || pip install -q git+https://github.com/CoffeaTeam/lpcjobqueue.git@v\${LPCJQ_VERSION}
EOF
cat <<EOF > .zshrc
LPCJQ_VERSION="0.4.1"
install_env() {
set -e
echo "Installing shallow virtual environment in \$INSTALL_LOC.env..."
python -m venv --without-pip --system-site-packages \$INSTALL_LOC.env
unlink .env/lib64 # HTCondor can't transfer symlink to directory and it appears optional
# work around issues copying CVMFS xattr when copying to tmpdir
export TMPDIR=\$(mktemp -d -p .)
rm -rf \$TMPDIR && unset TMPDIR
# \$INSTALL_LOC.env/bin/python -m pip install --upgrade awkward dask_awkward coffea uproot
cd processing
\$INSTALL_LOC.env/bin/python -m pip install -e .
cd ..
\$INSTALL_LOC.env/bin/python -m pip install -q git+https://github.com/CoffeaTeam/lpcjobqueue.git@v\${LPCJQ_VERSION}
echo "done."
}
install_kernel() {
# work around issues copying CVMFS xattr when copying to tmpdir
export TMPDIR=\$(mktemp -d -p .)
\$INSTALL_LOC.env/bin/python -m ipykernel install --user --name monoz --display-name "monoz" --env PYTHONPATH $PYTHONPATH:$PWD --env PYTHONNOUSERSITE 1
rm -rf \$TMPDIR && unset TMPDIR
}
install_all() {
install_env
install_kernel
}
export JUPYTER_PATH=\$INSTALL_LOC.jupyter
export JUPYTER_RUNTIME_DIR=\$INSTALL_LOC.local/share/jupyter/runtime
export JUPYTER_DATA_DIR=\$INSTALL_LOC.local/share/jupyter
export IPYTHONDIR=\$INSTALL_LOC.ipython
unset GREP_OPTIONS
[[ -d \$INSTALL_LOC.env ]] || install_all
source \$INSTALL_LOC.env/bin/activate
alias pip="python -m pip"
voms-proxy-init -voms cms -vomses /etc/grid-security/vomses/ --valid 192:00 --out \$HOME/x509up_u\$UID
# pip show lpcjobqueue 2>/dev/null | grep -q "Version: \${LPCJQ_VERSION}" || pip install -q git+https://github.com/CoffeaTeam/lpcjobqueue.git@v\${LPCJQ_VERSION}
EOF
chmod u+x shell .bashrc .zshrc
echo "Wrote shell .bashrc and .zshrc to current directory. Run ./shell to start the singularity shell"