Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Install rucio_jupyterlab extension #117

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ gpgcheck=0' > /etc/yum.repos.d/carepo.repo && \
# Install VOMS
RUN yum install -y voms-clients-java voms-clients-cpp fetch-crl globus-gsi-sysconfig

# Install gfal2 required by Rucio
RUN yum install -y gfal2-all gfal2-python

ADD etc/vomses /etc/vomses
ADD etc/grid-security/vomsdir /etc/grid-security/vomsdir

Expand Down Expand Up @@ -208,7 +211,8 @@ RUN pip install --no-deps --no-cache-dir \
swanoauthrenew==1.0.1 PyJWT \
swanshare==1.1.1 \
swanheader==1.0.0 \
swanportallocator==1.0.1
swanportallocator==1.0.1 \
rucio-jupyterlab==0.9.8
# swandask must be installed after its dependency dask-labextension to disable the server extension automatically
RUN pip install --no-deps --no-cache-dir swandask==0.0.3

Expand Down Expand Up @@ -246,7 +250,20 @@ RUN jupyter nbextension install --py --system hdfsbrowser && \
ln -s /usr/local/lib/python3.9/site-packages/swandask /usr/local/lib/swan/extensions/ && \
# FIXME workaround for templates. For some reason, and only in our image, Jupyter is looking for templates inside templates
cp -r /usr/local/lib/python3.9/site-packages/swancontents/templates{,2} && \
mv /usr/local/lib/python3.9/site-packages/swancontents/templates{2,/templates}
mv /usr/local/lib/python3.9/site-packages/swancontents/templates{2,/templates} && \
jupyter serverextension enable --py rucio_jupyterlab --sys-prefix

# Add Rucio CA Certificate
RUN mkdir /certs \
&& touch /opt/rucio/rucio_ca.pem \
&& curl -fsSL 'https://cafiles.cern.ch/cafiles/certificates/CERN%20Root%20Certification%20Authority%202.crt' | openssl x509 -inform DER -out /tmp/cernrootca2.crt \
&& curl -fsSL 'https://cafiles.cern.ch/cafiles/certificates/CERN%20Grid%20Certification%20Authority(1).crt' -o /tmp/cerngridca.crt \
&& curl -fsSL 'https://cafiles.cern.ch/cafiles/certificates/CERN%20Certification%20Authority.crt' -o /tmp/cernca.crt \
&& cat /tmp/cernrootca2.crt >> /opt/rucio/rucio_ca.pem \
&& cat /tmp/cerngridca.crt >> /opt/rucio/rucio_ca.pem \
&& cat /tmp/cernca.crt >> /opt/rucio/rucio_ca.pem \
&& rm /tmp/*.crt \
&& update-ca-certificates

# Configure Dask
ENV DASK_DIR /srv/dask
Expand All @@ -273,6 +290,7 @@ ADD userconfig.sh /srv/singleuser/userconfig.sh
ADD create_dask_certs.sh /srv/singleuser/create_dask_certs.sh
ADD configure_kernels_and_terminal.py /srv/singleuser/configure_kernels_and_terminal.py
ADD executables/start_ipykernel.py /usr/local/bin/start_ipykernel.py
ADD configure_rucio_extension.py /srv/singleuser/configure_rucio_extension.py
RUN chmod 705 /usr/local/bin/start_ipykernel.py

WORKDIR /root
Expand Down
58 changes: 58 additions & 0 deletions configure_rucio_extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Derived from https://github.com/rucio/jupyterlab-extension/blob/master/docker/configure.py

import os
import json

def write_jupyterlab_config():
file_path = '/etc/jupyter/jupyter_notebook_config.json'
if not os.path.isfile(file_path):
os.makedirs('/etc/jupyter/', exist_ok=True)
else:
config_file = open(file_path, 'r')
config_payload = config_file.read()
config_file.close()

try:
config_json = json.loads(config_payload)
except:
config_json = {}

instance_config = {
"name": os.getenv('RUCIO_NAME', "default"),
"display_name": os.getenv('RUCIO_DISPLAY_NAME', "Default Instance"),
"rucio_base_url": os.getenv('RUCIO_BASE_URL'),
"rucio_auth_url": os.getenv('RUCIO_AUTH_URL'),
"rucio_webui_url": os.getenv('RUCIO_WEBUI_URL'),
"rucio_ca_cert": os.getenv('RUCIO_CA_CERT'),
"site_name": os.getenv('RUCIO_SITE_NAME'),
"vo": os.getenv('RUCIO_VO'),
"voms_enabled": os.getenv('RUCIO_VOMS_ENABLED', '0') == '1',
"voms_vomses_path": os.getenv('RUCIO_VOMS_VOMSES_PATH'),
"voms_certdir_path": os.getenv('RUCIO_VOMS_CERTDIR_PATH'),
"voms_vomsdir_path": os.getenv('RUCIO_VOMS_VOMSDIR_PATH'),
"destination_rse": os.getenv('RUCIO_DESTINATION_RSE'),
"rse_mount_path": os.getenv('RUCIO_RSE_MOUNT_PATH'),
"replication_rule_lifetime_days": int(os.getenv('RUCIO_REPLICATION_RULE_LIFETIME_DAYS')) if os.getenv('RUCIO_REPLICATION_RULE_LIFETIME_DAYS') else None,
"path_begins_at": int(os.getenv('RUCIO_PATH_BEGINS_AT', '0')),
"mode": os.getenv('RUCIO_MODE', 'replica'),
"wildcard_enabled": os.getenv('RUCIO_WILDCARD_ENABLED', '0') == '1',
"oidc_auth": os.getenv('RUCIO_OIDC_AUTH'),
"oidc_env_name": os.getenv('RUCIO_OIDC_ENV_NAME'),
"oidc_file_name": os.getenv('RUCIO_OIDC_FILE_NAME'),
}

instance_config = {k: v for k,
v in instance_config.items() if v is not None}
config_json['RucioConfig'] = {
'instances': [instance_config],
"default_instance": os.getenv('RUCIO_DEFAULT_INSTANCE'),
"default_auth_type": os.getenv('RUCIO_DEFAULT_AUTH_TYPE'),
}

config_file = open(file_path, 'w')
config_file.write(json.dumps(config_json, indent=2))
config_file.close()

if __name__ == '__main__':
write_jupyterlab_config()

3 changes: 3 additions & 0 deletions systemuser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ else
}" > /etc/jupyter/labconfig/page_config.json
fi

# Rucio configuration
python /srv/singleuser/configure_rucio_extension.py

# HTCondor at CERN integration
if [[ $CERN_HTCONDOR ]]
then
Expand Down