diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f5ef2ca..0000000 --- a/Dockerfile +++ /dev/null @@ -1,53 +0,0 @@ - -FROM andrewosh/binder-base - -MAINTAINER Enric Tejedor Saavedra - -USER root - -# Install ROOT prerequisites -RUN apt-get update -RUN apt-get install -y \ - libx11-6 \ - libxext6 \ - libxft2 \ - libxpm4 - -# Install ROOT additional libraries -RUN apt-get install -y \ - r-base \ - r-base-dev - -# Install R packages -RUN R -e "install.packages(c('Rcpp','RInside'), repos = \"http://cran.case.edu\")" - -# Download and install ROOT master -WORKDIR /opt -RUN wget http://root.cern.ch/notebooks/rootbinderdata/root.tar.gz -RUN tar xzf root.tar.gz -RUN rm root.tar.gz - -# Download and install Fastjet -RUN wget http://root.cern.ch/notebooks/rootbinderdata/fastjet.tar.gz -RUN tar xzf fastjet.tar.gz -RUN rm fastjet.tar.gz - -USER main - -# Set ROOT environment -ENV ROOTSYS "/opt/root" -ENV PATH "$ROOTSYS/bin:$ROOTSYS/bin/bin:$PATH" -ENV LD_LIBRARY_PATH "$ROOTSYS/lib:$LD_LIBRARY_PATH" -ENV PYTHONPATH "$ROOTSYS/lib:PYTHONPATH" - -# Set ROOT environment for Fastjet -ENV LD_LIBRARY_PATH "/opt/fastjet/lib:$LD_LIBRARY_PATH" -ENV ROOT_INCLUDE_PATH "/opt/fastjet/include" - -# Customise the ROOTbook -RUN pip install --upgrade pip -RUN pip install metakernel -RUN mkdir -p $HOME/.ipython/kernels -RUN cp -r $ROOTSYS/etc/notebook/kernels/root $HOME/.ipython/kernels -RUN mkdir -p $HOME/.ipython/profile_default/static -RUN cp -r $ROOTSYS/etc/notebook/custom $HOME/.ipython/profile_default/static diff --git a/binder/Dockerfile b/binder/Dockerfile new file mode 100644 index 0000000..dc4a53f --- /dev/null +++ b/binder/Dockerfile @@ -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"] diff --git a/binder/install_xrootd.sh b/binder/install_xrootd.sh new file mode 100644 index 0000000..9d0bc5a --- /dev/null +++ b/binder/install_xrootd.sh @@ -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 diff --git a/notebooks/XRootD_Example.ipynb b/notebooks/XRootD_Example.ipynb new file mode 100644 index 0000000..3cfdbaf --- /dev/null +++ b/notebooks/XRootD_Example.ipynb @@ -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 [] [ [. . .]] \n", + "\n", + "Options: [--cksum ] [--debug ] [--coerce] [--dynamic-src]\n", + " [--force] [--help] [--infiles ] [--license] [--nopbar]\n", + " [--path] [--posc] [--proxy :] [--recursive]\n", + " [--retry ] [--server] [--silent] [--sources ] [--streams ]\n", + " [--tpc {first|only}] [--verbose] [--version] [--xrate ]\n", + " [--parallel ] [--zip ]\n", + ": [[x]root://[:]/] | -\n", + ": [[x]root://[:]/] | -\n", + "\n", + "-C | --cksum verifies the checksum at the destination as provided\n", + " by the source server or locally computed. The args are\n", + " {adler32 | crc32 | md5}[:{|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 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 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 uses up to the number of sources specified in parallel\n", + "-S | --streams 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 limits the transfer to the specified rate. You can\n", + " suffix the value with 'k', 'm', or 'g'\n", + " --parallel number of copy jobs to be run simultaneously\n", + "\n", + "-z | --zip treat the source as a ZIP archive containing given file\n", + "Legacy options: [-adler] [-DI ] [-DS ] [-np]\n", + " [-md5] [-OD] [-OS] [-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 +}