From 42171e7b380f700bbbccafcc53dd05a5ed22cc82 Mon Sep 17 00:00:00 2001 From: "Patrick L.S. Connor" <connorpa@mail.desy.de> Date: Thu, 4 Jul 2024 14:11:54 +0200 Subject: [PATCH] updating instructions to install with CMake on Alma9 (partly addresses gitlab-profile#19) [skip ci] --- README.md | 56 ++++++++++++++++++++++++++++++++++++------- install.sh | 65 +++++++++++++++++++++++++------------------------- setup | 6 ++--- setup.sh.in | 1 + tunfold.xml.in | 13 ---------- 5 files changed, 84 insertions(+), 57 deletions(-) delete mode 100644 tunfold.xml.in diff --git a/README.md b/README.md index dc44490..116ab46 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The `Campaigns` subgroup contains actual repos corresponding to different analys In the following, we provide two alternative methods to install the framework. -### Method #1: From scratch with the default installer +### Method \#1: From scratch with the default installer In general, it is recommended that you install the software on a fast disk to ensure fast compilation (e.g. AFS), but that you process the heavy n-tuples on a dedicated area (e.g. NFS at DESY, EOS at CERN). Keeping the software neat and clean is important for reproducibility. @@ -25,21 +25,21 @@ git clone https://gitlab.cern.ch/cms-analysis/general/DasAnalysisSystem/gitlab-p cd DasAnalysisSystem source ./setup ``` -It is currently working at CERN (CH), at DESY (DE), at IIHE (BE), and for GitLab CI. Feel free to make a merge request to include your favourite facility. +The `setup` is necessary at CERN (CH), at DESY (DE), at IIHE (BE), and for GitLab CI, but may not be necessary on all platforms (e.g. your private laptop). 2. Run the installation: ``` ./install.sh ``` -*Remark*: if a CMSSW release has already been sourced, it will use that one instead of installing a new one. -3. Then change to the directory of the CMSSW release (by default, it is created in the local directory) and compile as follows: +3. After a few minutes, you get back to the prompt. You only have to set up the newly compiled environment: ``` -cmsenv -scram b -j$(nproc) +source tools/setup.sh ``` -4. After a few minutes, you get back to the prompt. You have to rerun `cmsenv` to actually see the commands in the shell. Then you're all set. -### Method #2: By hand, step by step +### Method \#2: By hand, step by step +*Work in progress* + +<!--- In the following, we explain the installation of the framework step by step. A few packages external to CMSSW are necessary (e.g. TUnfold), which you will need to tell CMSSW how to find them with `scram setup`. First source your CMSSW release and close to a directory where you want to install the external packages. @@ -73,10 +73,11 @@ cd $CMSSW_BASE/src/JMEAnalysis/JetToolbox patch -p1 $OLDPWD/jetToolbox_120X.patch ``` 5. Clone the `Tables` wherever you like and the `Core` in CMSSW, and compile as usual with `scram b -j`. +--> ## Setting up the environment -First source the minimal environment for CMSSW with `source ./setup`, then just source the CMSSW release as usual with `cmsenv`. +First source the minimal environment with `source ./setup`, then `source ./tools/setup.sh`. To run CRAB jobs, you will also need to set up a valid [grid certificate](https://twiki.cern.ch/twiki/bin/view/CMSPublic/WorkBookStartingGrid#ObtainingCert). If you already have done so, this will enable it: ``` @@ -85,6 +86,43 @@ voms-proxy-init --rfc --voms cms -valid 192:00 To make [RUCIO](https://twiki.cern.ch/twiki/bin/viewauth/CMS/Rucio) requests, the `setup` file tried to guess your RUCIO username from your local username (unless was already set up). This is not guaranteed to work and you may have to define your RUCIO username ahead for sourcing the DAS environment. +### Contributing + +If you modify part of the source code of a module (e.g. `Core`), you can recompile it as follows: +``` +cd $DAS_BASE +cmake --build Core.build --target install +``` +(This is analog to `cd $CMSSW_BASE; scram b`.) +It is good practice to check that your changes do not harm the rest of the code. For this, tests can be run as follows: +``` +cd $DAS_BASE/Core.build +ctest . +``` +(analog to `cd $CMSSW_BASE; scram b runtests`.) + +For `cmake` and `ctest`, one can always specify `-j8` to compile with 8 cores (for instance), or more generally `-j$(nproc)` to compile with the number of cores on the present machine. + +Despite multitasking, the whole process of compiling and testing may take a few minutes. In case you would like to compile and/or test a subset of the code, do the following (where `JEC` is here just taken as an example): +``` +cd $DAS_BASE/Core.build/JEC +make install +``` +(analog to `cd $CMSSW_BASE/src/Core/JEC; scram b`.) + +Whenever developing, it is perfectly fine to only compile subsets of the code to speed up the whole process. Instead, whenever running over large samples, it is advised to commit and to rerun the whole `Core` to ensure compatibility and reproducibility of the resulsts. + +### Updating a module + +If you want to update source code of a module (e.g. `Core`), assuming no local changes, you can proceed as follows: +``` +cd $DAS_BASE/Core +git pull +cmake -B $DAS_BASE/build +cmake --build $DAS_BASE/build --target install +``` +In case of local changes, you should first commit them, or use `git stash` to pause the changes temporarily (after the update, it will be sufficient to run `git stash pop` to recover your changes). + ### Good practices Fight against the increase of entropy by diff --git a/install.sh b/install.sh index efc82cb..9959d52 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash set -e @@ -28,37 +28,38 @@ if [ ! -z "$(git config url.ssh://git@gitlab.cern.ch:7999/.insteadOf)" ]; then ssh-add fi -# Get a CMSSW if we don't have one -if [ -z $CMSSW_BASE ]; then - version=CMSSW_12_4_0 - [ ! -d $version ] && scram p $version - cd $version - eval `scramv1 runtime -sh` - unset version -fi - -# Set up libgit2 -cd $CMSSW_BASE -scram setup $BASE_DIR/libgit2.xml +set -x # Download and build supporting tools -cd $BASE_DIR -cmake3 -B .build -cmake3 --build .build --target install -j$(nproc) - -# Get Core -cd $CMSSW_BASE/src -[ ! -d Core ] && git clone https://gitlab.cern.ch/cms-analysis/general/DasAnalysisSystem/Core.git - -# And JetToolbox -[ ! -d JMEAnalysis/JetToolbox ] && ( - git clone https://github.com/cms-jet/JetToolbox.git JMEAnalysis/JetToolbox -b jetToolbox_120X - cd JMEAnalysis/JetToolbox - patch -p1 <$BASE_DIR/jetToolbox_120X.patch -) +cmake3 -B build +cmake3 --build build --target install -j$(nproc) -# Set up scram tools in CMSSW -- must be done after fetching Core -cd $CMSSW_BASE -for xml in $BASE_DIR/tools/etc/*.xml; do - scram setup $xml -done +## Get a CMSSW if we don't have one +#if [ -z $CMSSW_BASE ]; then +# version=CMSSW_12_4_0 +# [ ! -d $version ] && scram p $version +# cd $version +# eval `scramv1 runtime -sh` +# unset version +#fi +# +## Set up libgit2 +#cd $CMSSW_BASE +#scram setup $BASE_DIR/libgit2.xml +# +## Get Core +#cd $CMSSW_BASE/src +#[ ! -d Core ] && git clone https://gitlab.cern.ch/cms-analysis/general/DasAnalysisSystem/Core.git +# +## And JetToolbox +#[ ! -d JMEAnalysis/JetToolbox ] && ( +# git clone https://github.com/cms-jet/JetToolbox.git JMEAnalysis/JetToolbox -b jetToolbox_120X +# cd JMEAnalysis/JetToolbox +# patch -p1 <$BASE_DIR/jetToolbox_120X.patch +#) +# +## Set up scram tools in CMSSW -- must be done after fetching Core +#cd $CMSSW_BASE +#for xml in $BASE_DIR/tools/etc/*.xml; do +# scram setup $xml +#done diff --git a/setup b/setup index 9f22c47..60acbf1 100644 --- a/setup +++ b/setup @@ -3,19 +3,20 @@ case "$(hostname)" in tput setaf 2 echo "Setting up environment for DESY (naf)." tput op - module use -a /afs/desy.de/group/cms/modulefiles/ - module load cmssw + source /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc13-opt/setup.sh source /cvmfs/grid.desy.de/etc/profile.d/grid-ui-env.sh ;; *cern.ch) tput setaf 2 echo "Setting up environment for CERN (lxplus)." tput op + source /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc13-opt/setup.sh ;; *iihe.ac.be) tput setaf 2 echo "Setting up environment for IIHE T2B cluster." tput op + source /cvmfs/sft.cern.ch/lcg/views/LCG_104/x86_64-el9-gcc13-opt/setup.sh ;; *) tput setaf 3 @@ -24,7 +25,6 @@ case "$(hostname)" in ;; esac -source /cvmfs/cms.cern.ch/cmsset_default.sh source /cvmfs/cms.cern.ch/rucio/setup-py3.sh source /cvmfs/cms.cern.ch/crab3/crab.sh diff --git a/setup.sh.in b/setup.sh.in index 8fde749..7d148e0 100644 --- a/setup.sh.in +++ b/setup.sh.in @@ -5,6 +5,7 @@ export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/python:$PYTHONPATH export DARWIN_FIRE_AND_FORGET=@CMAKE_INSTALL_FULL_LIBDIR@ # TODO use ldd or link statically # Convenience +export DAS_BASE=@CMAKE_SOURCE_DIR@ export DARWIN_BASE=@CMAKE_SOURCE_DIR@/Darwin export DARWIN_TABLES=@CMAKE_SOURCE_DIR@/tables export CORE_BASE=@CMAKE_SOURCE_DIR@/Core diff --git a/tunfold.xml.in b/tunfold.xml.in deleted file mode 100644 index f19a1e2..0000000 --- a/tunfold.xml.in +++ /dev/null @@ -1,13 +0,0 @@ -<tool name="tunfold" version="17.9"> - <lib name="tunfold"/> - <info url="https://www.desy.de/~sschmitt/tunfold.html"/> - <client> - <environment name="TUNFOLD_BASE" default="${CMAKE_SOURCE_DIR}/TUnfold"/><!-- FIXME Needed? --> - <environment name="INCLUDE" default="${CMAKE_INSTALL_FULL_INCLUDEDIR}/TUnfold"/> - <environment name="LIBDIR" default="${CMAKE_INSTALL_FULL_LIBDIR}"/> - </client> - <use name="root_cxxdefaults"/> - <lib name="XMLIO" /> - <lib name="XMLParser" /> - <runtime name="LD_LIBRARY_PATH" value="$LIBDIR" type="path"/> -</tool> -- GitLab