-
Notifications
You must be signed in to change notification settings - Fork 20
/
env.sh
145 lines (125 loc) · 5.13 KB
/
env.sh
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
#!/usr/bin/env bash
run_cmd() {
"$@"
RESULT=$?
if (( $RESULT != 0 )); then
echo "Error while running '$@'"
kill -INT $$
fi
}
get_os_prefix() {
local os_version=$1
local for_global_tag=$2
if (( $os_version >= 8 )); then
echo el
elif (( $os_version < 6 )); then
echo error
else
if [[ $for_global_tag == 1 || $os_version == 6 ]]; then
echo slc
else
echo cc
fi
fi
}
do_install_cmssw() {
local this_file="$( [ ! -z "$ZSH_VERSION" ] && echo "${(%):-%x}" || echo "${BASH_SOURCE[0]}" )"
local this_dir="$( cd "$( dirname "$this_file" )" && pwd )"
export SCRAM_ARCH=$1
local CMSSW_VER=$2
if ! [ -f "$this_dir/soft/$CMSSW_VER/.installed" ]; then
run_cmd mkdir -p "$this_dir/soft"
run_cmd cd "$this_dir/soft"
run_cmd source /cvmfs/cms.cern.ch/cmsset_default.sh
if [ -d $CMSSW_VER ]; then
echo "Removing incomplete $CMSSW_VER installation..."
run_cmd rm -rf $CMSSW_VER
fi
echo "Creating $CMSSW_VER area in $PWD ..."
run_cmd scramv1 project CMSSW $CMSSW_VER
run_cmd cd $CMSSW_VER/src
run_cmd eval `scramv1 runtime -sh`
#install CMSSW updates not in official releases
local master_ver=`echo $CMSSW_VER | cut -d'_' -f 2`
local sub_ver=`echo $CMSSW_VER | cut -d'_' -f 3`
local subsub_ver=`echo $CMSSW_VER | cut -d'_' -f 4`
if [[ $master_ver == "14" && $sub_ver == "0" ]]; then
run_cmd echo "=> Installing addons for CMSSW_"${master_ver}"_"$sub_ver
run_cmd git cms-merge-topic -u cms-tau-pog:CMSSW_14_0_X_NanoProd_Addon_Powheg
run_cmd git cms-merge-topic -u cms-tau-pog:CMSSW_14_0_X_tau-pog_BoostedDeepTau
run_cmd wget https://github.com/cms-tau-pog/RecoTauTag-TrainingFiles/raw/refs/heads/BoostedDeepTau_v2/BoostedDeepTauId/boosteddeepTau_RunIIv2p0_{core,inner,outer}.pb -P RecoTauTag/TrainingFiles/data/BoostedDeepTauId/
run_cmd git cms-merge-topic -u cms-tau-pog:CMSSW_14_0_X_tau-pog_DeepTauNoDA
run_cmd wget https://github.com/cms-tau-pog/RecoTauTag-TrainingFiles/raw/refs/heads/deepTau_v2p5_noDomainAdaptation/DeepTauId/deepTau_2018v2p5_noDomainAdaptation_{core,inner,outer}.pb -P RecoTauTag/TrainingFiles/data/DeepTauId/
fi
run_cmd mkdir NanoProd
run_cmd ln -s "$this_dir/NanoProd" NanoProd/NanoProd
run_cmd scram b -j8
run_cmd cd "$this_dir"
run_cmd touch "$this_dir/soft/$CMSSW_VER/.installed"
fi
}
install_cmssw() {
local this_file="$( [ ! -z "$ZSH_VERSION" ] && echo "${(%):-%x}" || echo "${BASH_SOURCE[0]}" )"
local this_dir="$( cd "$( dirname "$this_file" )" && pwd )"
local scram_arch=$1
local cmssw_version=$2
local node_os=$3
local target_os=$4
if [[ $node_os == $target_os ]]; then
local env_cmd=""
local env_cmd_args=""
else
local env_cmd="cmssw-$target_os"
if ! command -v $env_cmd &> /dev/null; then
echo "Unable to do a cross-platform installation for $cmssw_version SCRAM_ARCH=$scram_arch. $env_cmd is not available."
return 1
fi
local env_cmd_args="--command-to-run"
fi
if ! [ -f "$this_dir/soft/$CMSSW_VER/.installed" ]; then
run_cmd $env_cmd $env_cmd_args /usr/bin/env -i HOME=$HOME bash "$this_file" install_cmssw $scram_arch $cmssw_version
fi
}
action() {
# determine the directory of this file
local this_file="$( [ ! -z "$ZSH_VERSION" ] && echo "${(%):-%x}" || echo "${BASH_SOURCE[0]}" )"
local this_dir="$( cd "$( dirname "$this_file" )" && pwd )"
export PYTHONPATH="$this_dir:$PYTHONPATH"
export LAW_HOME="$this_dir/.law"
export LAW_CONFIG_FILE="$this_dir/NanoProd/config/law.cfg"
export ANALYSIS_PATH="$this_dir"
export ANALYSIS_DATA_PATH="$ANALYSIS_PATH/data"
export X509_USER_PROXY="$ANALYSIS_DATA_PATH/voms.proxy"
run_cmd mkdir -p "$ANALYSIS_DATA_PATH"
local os_version=$(cat /etc/os-release | grep VERSION_ID | sed -E 's/VERSION_ID="([0-9]+).*"/\1/')
local os_prefix=$(get_os_prefix $os_version)
local node_os=$os_prefix$os_version
local default_cmssw_ver=CMSSW_14_0_18
local target_os_version=8
local target_os_prefix=$(get_os_prefix $target_os_version)
local target_os_gt_prefix=$(get_os_prefix $target_os_version 1)
local target_os=$target_os_prefix$target_os_version
export DEFAULT_CMSSW_BASE="$ANALYSIS_PATH/soft/$default_cmssw_ver"
run_cmd install_cmssw ${target_os_gt_prefix}${target_os_version}_amd64_gcc12 $default_cmssw_ver $node_os $target_os
if [ ! -z $ZSH_VERSION ]; then
autoload bashcompinit
bashcompinit
fi
source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh LCG_105 x86_64-${os_prefix}${os_version}-gcc13-opt
source /afs/cern.ch/user/m/mrieger/public/law_sw/setup.sh
source "$( law completion )" ""
source /cvmfs/cms.cern.ch/rucio/setup-py3.sh &> /dev/null
if [[ $node_os == $target_os ]]; then
export CMSSW_SINGULARITY=""
local env_cmd=""
else
export CMSSW_SINGULARITY="/cvmfs/cms.cern.ch/common/cmssw-$target_os"
local env_cmd="$CMSSW_SINGULARITY --command-to-run"
fi
alias cmsEnv="$env_cmd env -i HOME=$HOME ANALYSIS_PATH=$ANALYSIS_PATH X509_USER_PROXY=$X509_USER_PROXY DEFAULT_CMSSW_BASE=$DEFAULT_CMSSW_BASE KRB5CCNAME=$KRB5CCNAME $ANALYSIS_PATH/RunKit/cmsEnv.sh"
}
if [ "X$1" = "Xinstall_cmssw" ]; then
do_install_cmssw "${@:2}"
else
action "$@"
fi