Skip to content
Open
53 changes: 0 additions & 53 deletions Dockerfile

This file was deleted.

66 changes: 66 additions & 0 deletions binder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
FROM rootproject/root-ubuntu16:6.12

# Run the following commands as super user (root):
USER root
WORKDIR /root

SHELL [ "/bin/bash", "-c" ]

# Install required packages for notebooks
RUN apt-get update && \
apt-get upgrade -qq -y && \
apt-get install -qq -y \
python-pip \
wget \
git \
cmake && \
apt-get -y autoclean && \
apt-get -y autoremove && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*

# Use sudo -H pip instead of pip install --user as jupyter will be called later by USER jovyan
RUN sudo -H pip install --upgrade --no-cache-dir pip setuptools wheel && \
sudo -H pip install --no-cache-dir \
jupyter \
metakernel \
zmq

# Install XRootD
ADD binder/install_xrootd.sh install_xrootd.sh
RUN bash install_xrootd.sh && \
rm install_xrootd.sh
ENV PATH /opt/xrootd/bin:${PATH}
ENV LD_LIBRARY_PATH /opt/xrootd/lib

ENV DISPLAY localhost:0.0.0.0
# c.f. https://mybinder.readthedocs.io/en/latest/tutorials/dockerfile.html#preparing-your-dockerfile
ENV NB_USER jovyan
ENV NB_UID 1000
ENV HOME /home/${NB_USER}
WORKDIR /home/${NB_USER}

RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}

# Have Jupyter notebooks launch without command line options
RUN jupyter notebook --generate-config && \
sed -i -e "/allow_root/ a c.NotebookApp.allow_root = True" ~/.jupyter/jupyter_notebook_config.py && \
sed -i -e "/custom_display_url/ a c.NotebookApp.custom_display_url = \'http://localhost:8888\'" ~/.jupyter/jupyter_notebook_config.py && \
sed -i -e "/c.NotebookApp.ip/ a c.NotebookApp.ip = '0.0.0.0'" ~/.jupyter/jupyter_notebook_config.py && \
sed -i -e "/open_browser/ a c.NotebookApp.open_browser = False" ~/.jupyter/jupyter_notebook_config.py
# Prepare the JupyROOT kernel
RUN cp ~/.jupyter/jupyter_notebook_config.py ${HOME} && \
mkdir -p ${HOME}/.local/share/jupyter/kernels && \
cp -r /usr/local/etc/root/notebook/kernels/root ~/.local/share/jupyter/kernels

# Make sure the contents of the repo are in ${HOME}
COPY . ${HOME}
USER root
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_USER}

# Specify the default command to run
CMD ["jupyter", "notebook", "--ip", "0.0.0.0"]
33 changes: 33 additions & 0 deletions binder/install_xrootd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

function setNumProcessors () {
# Set the number of processors used for build
# to be 1 less than are available
if [[ -f "$(which nproc)" ]]; then
NPROC="$(nproc)"
else
NPROC="$(grep -c '^processor' /proc/cpuinfo)"
fi
echo `expr "${NPROC}" - 1`
}

function main() {
cd /tmp

git clone https://github.com/xrootd/xrootd.git /tmp/xroot

mkdir build
cd build

printf "\n# cmake /tmp/xroot -DCMAKE_INSTALL_PREFIX=/opt/xrootd\n"
cmake /tmp/xroot \
-DCMAKE_INSTALL_PREFIX=/opt/xrootd
printf "\n# cmake --build . -- -j${NPROC}\n"
cmake --build . -- -j${NPROC}
printf "\n# make install\n"
make install

rm -rf /tmp/*
}

main "$@" || exit 1
114 changes: 114 additions & 0 deletions notebooks/XRootD_Example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using [XRootD](http://xrootd.org/) to pull large public datasets"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"XRootD's `xrdcp` utility can be used to copy large datasets from remote locations"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Usage: xrdcp [<options>] <src> [<src> [. . .]] <dest>\n",
"\n",
"Options: [--cksum <args>] [--debug <lvl>] [--coerce] [--dynamic-src]\n",
" [--force] [--help] [--infiles <fn>] [--license] [--nopbar]\n",
" [--path] [--posc] [--proxy <host>:<port>] [--recursive]\n",
" [--retry <n>] [--server] [--silent] [--sources <n>] [--streams <n>]\n",
" [--tpc {first|only}] [--verbose] [--version] [--xrate <rate>]\n",
" [--parallel <n>] [--zip <file>]\n",
"<src>: [[x]root://<host>[:<port>]/]<path> | -\n",
"<dest>: [[x]root://<host>[:<port>]/]<path> | -\n",
"\n",
"-C | --cksum <args> verifies the checksum at the destination as provided\n",
" by the source server or locally computed. The args are\n",
" {adler32 | crc32 | md5}[:{<value>|print|source}]\n",
" If the hex value of the checksum is given, it is used.\n",
" Otherwise, the server's checksum is used for remote files\n",
" and computed for local files. Specifying print merely\n",
" prints the checksum but does not verify it.\n",
"-d | --debug <lvl> sets the debug level: 0 off, 1 low, 2 medium, 3 high\n",
"-Z | --dynamic-src file size may change during the copy\n",
"-F | --coerce coerces the copy by ignoring file locking semantics\n",
"-f | --force replaces any existing output file\n",
"-h | --help prints this information\n",
"-H | --license prints license terms and conditions\n",
"-I | --infiles specifies the file that contains a list of input files\n",
"-N | --nopbar does not print the progress bar\n",
"-p | --path automatically create remote destination path\n",
"-P | --posc enables persist on successful close semantics\n",
"-D | --proxy uses the specified SOCKS4 proxy connection\n",
"-r | --recursive recursively copies all source files\n",
"-t | --retry <n> maximum number of times to retry rejected connections\n",
" --server runs in a server environment with added operations\n",
"-s | --silent produces no output other than error messages\n",
"-y | --sources <n> uses up to the number of sources specified in parallel\n",
"-S | --streams <n> copies using the specified number of TCP connections\n",
"-T | --tpc uses third party copy mode between the src and dest.\n",
" Both the src and dest must allow tpc mode. Argument\n",
" 'first' tries tpc and if it fails, does a normal copy;\n",
" while 'only' fails the copy unless tpc succeeds.\n",
"-v | --verbose produces more information about the copy\n",
"-V | --version prints the version number\n",
"-X | --xrate <rate> limits the transfer to the specified rate. You can\n",
" suffix the value with 'k', 'm', or 'g'\n",
" --parallel <n> number of copy jobs to be run simultaneously\n",
"\n",
"-z | --zip <file> treat the source as a ZIP archive containing given file\n",
"Legacy options: [-adler] [-DI<var> <val>] [-DS<var> <val>] [-np]\n",
" [-md5] [-OD<cgi>] [-OS<cgi>] [-version] [-x]\n"
]
}
],
"source": [
"! xrdcp --help"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here, we will pull CMS OpenData containing muon candidates from part of 2012 dataset from Run 1 of the LHC ([DOI:10.7483/OPENDATA.CMS.YLIC.86ZZ](http://opendata.cern.ch/record/6004))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"! xrdcp root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/Run2012B_DoubleMuParked.root ./data/"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ROOT C++",
"language": "c++",
"name": "root"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".C",
"mimetype": " text/x-c++src",
"name": "c++"
}
},
"nbformat": 4,
"nbformat_minor": 2
}