-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathr-session-complete.sdef
279 lines (227 loc) · 10.7 KB
/
r-session-complete.sdef
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
Bootstrap: docker
From: centos:7
# needed if you want to set up CRAN and BioConductor repos from RSPM (optional)
# set binaryflag to "" in order to stick to source RPMs
%files
../scripts/run.R /
../scripts/bioc.txt /
../scripts/r-packages.txt /
%post -c /bin/bash
# Switch to vault for continued repo availability
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
# Activate EPEL Release and powertools
yum -y install yum-utils epel-release
yum-config-manager --enable powertools
# Set up of developer toolset 11 to use a more recent version of the
# compiler toolchain
yum -y install centos-release-scl
# Switch to vault for continued repo availability
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
yum -y install devtoolset-11
# Install Pro Drivers
yum install -y \
https://cdn.rstudio.com/drivers/7C152C12/installer/rstudio-drivers-{{ PRO_DRIVERS_VERSION }}-1.el7.x86_64.rpm \
&& cp -f /opt/rstudio-drivers/odbcinst.ini.sample /etc/odbcinst.ini
# Install TinyTex
yum install -y wget which perl-Digest-MD5
curl -sL "https://yihui.org/tinytex/install-bin-unix.sh" | sh \
&& /root/.TinyTeX/bin/*/tlmgr install \
bookmark \
caption \
environ \
fancyhdr \
hardwrap \
koma-script \
morefloats \
oberdiek \
pgf \
setspace \
tcolorbox \
textcase \
titlesec \
tufte-latex \
units \
ulem \
xcolor \
&& /root/.TinyTeX/bin/*/tlmgr path remove \
&& mv /root/.TinyTeX/ /opt/TinyTeX \
&& /opt/TinyTeX/bin/*/tlmgr option sys_bin /usr/local/bin \
&& /opt/TinyTeX/bin/*/tlmgr path add
# Install Quarto
curl -o quarto.tar.gz -L https://github.com/quarto-dev/quarto-cli/releases/download/v{{ QUARTO_VERSION }}/quarto-{{ QUARTO_VERSION }}-linux-amd64.tar.gz \
&& mkdir -p /opt/quarto/{{ QUARTO_VERSION }} \
&& tar -xf quarto.tar.gz -C "/opt/quarto/{{ QUARTO_VERSION }}" --strip-components=1 \
&& rm -f quarto.tar.gz \
&& ln -s /opt/quarto/{{ QUARTO_VERSION }}/bin/quarto /usr/local/bin/quarto
# Install Python
for PYTHON_VERSION in {{ PYTHON_VERSION_LIST }}
do
yum install -y https://cdn.rstudio.com/python/centos-7/pkgs/python-${PYTHON_VERSION}-1-1.x86_64.rpm
done
# Configure Python versions to have
# - upgraded pip
# - configure pip to use posit package manager
# - preinstalling packages needed for the integration with other tools (e.g Connect)
# Note: Install will run in parallel to speed up things
cat << EOF > /etc/pip.conf
[global]
timeout = 60
index-url = https://packagemanager.posit.co/pypi/latest/simple
EOF
for PYTHON_VERSION in {{ PYTHON_VERSION_LIST }}
do
/opt/python/${PYTHON_VERSION}/bin/pip install --upgrade \
pip setuptools wheel && \
scl enable devtoolset-11 "/opt/python/${PYTHON_VERSION}/bin/pip install \
ipykernel \
jupyter \
rsconnect_jupyter \
rsconnect_python \
rsp_jupyter \
jupyterlab~=4.2.4 \
pwb_jupyterlab~=1.0" && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-nbextension install --sys-prefix --py rsp_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-nbextension enable --sys-prefix --py rsp_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-nbextension install --sys-prefix --py rsconnect_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-nbextension enable --sys-prefix --py rsconnect_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-serverextension enable --sys-prefix --py rsconnect_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/python -m ipykernel install --name py${PYTHON_VERSION} --display-name "Python ${PYTHON_VERSION}" &
done
wait
# Use default version to point to jupyter and python
if [ ! -z {{ PYTHON_VERSION_DEFAULT }} ]; then
ln -s /opt/python/{{ PYTHON_VERSION_DEFAULT }}/bin/jupyter /usr/local/bin
ln -s /opt/python/{{ PYTHON_VERSION_DEFAULT }}/bin/python /usr/local/bin
ln -s /opt/python/{{ PYTHON_VERSION_DEFAULT }}/bin/python3 /usr/local/bin
fi
# Install PWB session components
mkdir -p /usr/lib/rstudio-server
yum install -y libcurl-devel openssl-devel rrdtool postgresql-libs
curl -O https://s3.amazonaws.com/rstudio-ide-build/session/centos7/x86_64/rsp-session-centos7-{{ PWB_VERSION }}-x86_64.tar.gz
tar xfz rsp-session-centos7-{{ PWB_VERSION }}-x86_64.tar.gz -C /usr/lib/rstudio-server --strip=1
rm -f rsp-session-centos7-{{ PWB_VERSION }}-x86_64.tar.gz
# Install Java JDK (optional)
yum -y install java-1.8.0-openjdk-devel
# Install and configure new set of defined R versions
for R_VERSION in {{R_VERSION_LIST}}
do
yum install -y https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm
# Set up developer toolset 11 for R only (optional)
cat << EOF > /opt/R/${R_VERSION}/lib/R/etc/Renviron.site
# Developer Toolset Root directory
DEVTOOLSROOT=/opt/rh/devtoolset-11/root
# Environment variables needed
PATH=\${DEVTOOLSROOT}/usr/bin:\${PATH}
LD_TMP=\${LD_LIBRARY_PATH}
LD_LIBRARY_PATH=\${DEVTOOLSROOT}/usr/lib64
LD_LIBRARY_PATH=\${DEVTOOLSROOT}/usr/lib:\${LD_LIBRARY_PATH}
LD_LIBRARY_PATH=\${DEVTOOLSROOT}/usr/lib64/dyninst:\${LD_LIBRARY_PATH}
LD_LIBRARY_PATH=\${DEVTOOLSROOT}/usr/lib/dyninst:\${LD_LIBRARY_PATH}
LD_LIBRARY_PATH=\${DEVTOOLSROOT}/usr/lib64:\${LD_LIBRARY_PATH}
LD_LIBRARY_PATH=\${DEVTOOLSROOT}/usr/lib:\${LD_LIBRARY_PATH}:\${LD_TMP}
PKG_CONFIG_PATH=\${DEVTOOLSROOT}/usr/lib64/pkgconfig:\${PKG_CONFIG_PATH}
INFOPATH=\${DEVTOOLSROOT}/usr/share/info:\${INFOPATH}
MANPATH=\${DEVTOOLSROOT}/usr/share/man:\${MANPATH}
X_SCLS=devtoolset-11
PCP_DIR=\${DEVTOOLSROOT}
EOF
# Update R Makevars to use the new compiler features from
# developer toolset 11 (optional)
R_HOME=/opt/R/${R_VERSION}/lib/R
if [ -z ${R_HOME} ]; then echo "R_HOME not set"; exit 1; fi
for std in 14 17 20
do
sed -i "s/^CXX${std} .?*/CXX${std} = g++/ ; \
s/^CXX${std}FLAGS .*/CXX${std}FLAGS = -g -O2 \$(LTO)/ ; \
s/^CXX${std}PICFLAGS .*/CXX${std}PICFLAGS = -fpic/ ; \
s/^CXX${std}STD .*/CXX${std}STD = -std=c++${std}/ " \
$R_HOME/etc/Makeconf
done
# Reconfigure R for Java (optional)
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
/opt/R/${R_VERSION}/bin/R CMD javareconf
echo $JAVA_HOME/lib/server > /etc/ld.so.conf.d/java.conf
# Set up R to use latest CRAN and bioconductor repositories
# from public RSPM (optional)
# Need to make sure R is in PATH so that pak can run R as a subprocess
rm -f /usr/local/bin/{R,Rscript}
ln -s /opt/R/${R_VERSION}/bin/{R,Rscript} /usr/local/bin
/opt/R/${R_VERSION}/bin/Rscript /run.R
rm -f /usr/local/bin/{R,Rscript}
done
rm -f /run.R
# Defining system default version
if [ ! -z {{ R_VERSION_DEFAULT }} ]; then
ln -s /opt/R/{{ R_VERSION_DEFAULT }}/bin/R /usr/local/bin
ln -s /opt/R/{{ R_VERSION_DEFAULT }}/bin/Rscript /usr/local/bin
fi
# Installing frequently needed system dependencies
# (Cf. https://docs.posit.co/connect/admin/r/dependencies/)
yum install -y epel-release
yum install -y cairo-devel openssl-devel make libcurl-devel mariadb-devel \
unixODBC-devel v8-devel java-1.8.0-openjdk-devel libxml2-devel git \
fontconfig-devel freetype-devel libgit2-devel libssh2-devel zlib-devel \
glpk-devel libjpeg-turbo-devel ImageMagick ImageMagick-c++-devel \
cmake cmake3 libpng-devel libtiff-devel mesa-libGLU-devel mesa-libGL-devel \
gdal-devel gdal geos-devel proj-devel proj-epsg sqlite-devel libsodium-devel \
libicu-devel tcl tk tk-devel fribidi-devel harfbuzz-devel udunits2-devel
# SLURM integration (mandatory)
groupadd -g 401 slurm
useradd -u 401 -g 401 slurm
yum -y install munge-devel
# Install SLURM
# Note that the git branches on github do have a slightly different
# naming scheme - firstly the dots are replaced by dashes and
# secondly each SLURM version can have more than one release tag
# Here, we simply append "-1" to use the first git tag of a given
# SLURM version
yum -y install git
dir=`mktemp -d` && \
cd $dir && \
rm -rf slurm && \
export SLURM_VER={{ SLURM_VERSION }} && git clone --depth 1 -b slurm-${SLURM_VER//./-}-1 https://github.com/SchedMD/slurm.git && \
cd slurm && \
./configure --prefix /usr/local/slurm > /var/log/slurm-configure.log && \
echo "Compiling SLURM" && \
make -j 4 > /var/log/slurm-compile.log && \
echo "Installing SLURM" && \
make install > /var/log/slurm-install.log && \
cd / && \
rm -rf $dir && \
ln -s /usr/local/slurm/bin/* /usr/local/bin
# Install zeromq as prereq for clustermq (optional)
yum -y install zeromq
# Install JAGS 4.3.0 as requirement for rjags
# Relies on the presence of openblas-devel from the R install
dir=`mktemp -d`
cd $dir
curl -O -L https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Source/JAGS-4.3.2.tar.gz/download
tar xvfz download
cd JAGS-4.3.2
./configure --with-blas="-lopenblas" && make && make install
cd
rm -rf $dir
# install apptainer
dir=`mktemp -d`
cd $dir
curl -L -O https://github.com/apptainer/apptainer/releases/download/v{{ APPTAINER_VERSION }}/apptainer-{{ APPTAINER_VERSION }}-1.x86_64.rpm
curl -L -O https://github.com/apptainer/apptainer/releases/download/v{{ APPTAINER_VERSION }}/apptainer-suid-{{ APPTAINER_VERSION }}-1.x86_64.rpm
yum install -y /usr/*bin/fuse2fs
yum localinstall -y apptainer-{{ APPTAINER_VERSION }}-1.x86_64.rpm
yum localinstall -y apptainer-suid-{{ APPTAINER_VERSION }}-1.x86_64.rpm
rm -f apptainer*
cd
rm -rf $dir
rm -rf /var/cache/yum/*
#%startscript
# # The below is saving the necessary environment variables so they can eb inherited into
# # subsequent singularity calls
# env | grep -e ^SINGULARITY -e ^SLURM | grep -v NAME | grep -v BIND | sed 's/^/export /' > /tmp/.slurm-$USER-$SLURM_JOBID.env
# $@
%environment
TINI_SUBREAPER=true
export SLURM_CONF=/opt/slurm/etc/slurm.conf