Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add curly brackets to bash variables #55

Merged
merged 1 commit into from
Dec 17, 2024
Merged
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
10 changes: 5 additions & 5 deletions processor/setup_law_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
action() {

_addpy() {
[ ! -z "$1" ] && export PYTHONPATH="$1:${PYTHONPATH}" && echo "Add $1 to PYTHONPATH"
[ ! -z "${1}" ] && export PYTHONPATH="${1}:${PYTHONPATH}" && echo "Add ${1} to PYTHONPATH"
}
_addbin() {
[ ! -z "$1" ] && export PATH="$1:${PATH}" && echo "Add $1 to PATH"
[ ! -z "${1}" ] && export PATH="${1}:${PATH}" && echo "Add ${1} to PATH"
}

SPAWNPOINT=$(pwd)
Expand Down Expand Up @@ -80,10 +80,10 @@ action() {

export ANALYSIS_DATA_PATH=$(pwd)

# start a luigid scheduler using $LUIGIPORT
# start a luigid scheduler using ${LUIGIPORT}
if [[ ! -z "${LUIGIPORT}" ]]; then
echo "Starting luigid scheduler on port $LUIGIPORT"
luigid --background --logdir logs --state-path luigid_state.pickle --port=$LUIGIPORT
echo "Starting luigid scheduler on port ${LUIGIPORT}"
luigid --background --logdir logs --state-path luigid_state.pickle --port=${LUIGIPORT}
fi
}

Expand Down
52 changes: 26 additions & 26 deletions processor/tasks/scripts/compile_crown.sh
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
#! /bin/bash
CROWNFOLDER=$1
ANALYSIS=$2
CONFIG=$3
SAMPLES=$4
ERAS=$5
SCOPE=$6
SHIFTS=$7
INSTALLDIR=$8
BUILDDIR=$9
CROWNFOLDER=${1}
ANALYSIS=${2}
CONFIG=${3}
SAMPLES=${4}
ERAS=${5}
SCOPE=${6}
SHIFTS=${7}
INSTALLDIR=${8}
BUILDDIR=${9}
TARBALLNAME=${10}
EXECUTALBE_THREADS=${11}
# setup with analysis clone if needed
set -o pipefail
set -e
source $ANALYSIS_PATH/CROWN/init.sh $ANALYSIS
source ${ANALYSIS_PATH}/CROWN/init.sh ${ANALYSIS}
# remove conda prefix from $PATH so cmakes uses the LCG stack python and not the conda one
if [[ ! -z "${CONDA_PREFIX}" ]]; then
PATH=$(echo $PATH | sed "s@$CONDA_PREFIX@@g")
# PATH=$(echo $PATH | sed 's%/cvmfs/etp.kit.edu/[^:]*:%%g')
PATH=$(echo ${PATH} | sed "s@${CONDA_PREFIX}@@g")
# PATH=$(echo ${PATH} | sed 's%/cvmfs/etp.kit.edu/[^:]*:%%g')
CONDA_PYTHON_EXE=""
CONDA_EXE=""
CONDA_PREFIX=""
fi
# use a fourth of the machine for compiling
THREADS_AVAILABLE=$(grep -c ^processor /proc/cpuinfo)
THREADS=$(( THREADS_AVAILABLE / 4 ))
echo "Using $THREADS threads for the compilation"
echo "Using ${THREADS} threads for the compilation"
which cmake

if cmake $CROWNFOLDER \
-DANALYSIS=$ANALYSIS \
-DCONFIG=$CONFIG \
-DSAMPLES=$SAMPLES \
-DERAS=$ERAS \
-DSCOPES=$SCOPE \
-DSHIFTS=$SHIFTS \
-DTHREADS=$EXECUTALBE_THREADS \
-DINSTALLDIR=$INSTALLDIR \
if cmake ${CROWNFOLDER} \
-DANALYSIS=${ANALYSIS} \
-DCONFIG=${CONFIG} \
-DSAMPLES=${SAMPLES} \
-DERAS=${ERAS} \
-DSCOPES=${SCOPE} \
-DSHIFTS=${SHIFTS} \
-DTHREADS=${EXECUTALBE_THREADS} \
-DINSTALLDIR=${INSTALLDIR} \
-DPRODUCTION=True \
-B$BUILDDIR 2>&1 |tee $BUILDDIR/cmake.log; then
-B${BUILDDIR} 2>&1 |tee ${BUILDDIR}/cmake.log; then
echo "CMake finished successfully"
else
echo "-------------------------------------------------------------------------"
echo "CMake failed, check the log file $BUILDDIR/cmake.log for more information"
echo "CMake failed, check the log file ${BUILDDIR}/cmake.log for more information"
echo "-------------------------------------------------------------------------"
sleep 0.1 # wait for the log file to be written
exit 1
fi
cd $BUILDDIR
cd ${BUILDDIR}
echo "Finished preparing the compilation and starting to compile"
make install -j $THREADS 2>&1 |tee $BUILDDIR/build.log
make install -j ${THREADS} 2>&1 |tee ${BUILDDIR}/build.log
echo "Finished the compilation"
60 changes: 30 additions & 30 deletions processor/tasks/scripts/compile_crown_friends.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#! /bin/bash
CROWNFOLDER=$1
ANALYSIS=$2
CONFIG=$3
SAMPLES=$4
ERAS=$5
SCOPE=$6
SHIFTS=$7
INSTALLDIR=$8
BUILDDIR=$9
CROWNFOLDER=${1}
ANALYSIS=${2}
CONFIG=${3}
SAMPLES=${4}
ERAS=${5}
SCOPE=${6}
SHIFTS=${7}
INSTALLDIR=${8}
BUILDDIR=${9}
TARBALLNAME=${10}
QUANTITIESMAP=${11}
# setup with analysis clone if needed
set -o pipefail
set -e
source $ANALYSIS_PATH/CROWN/init.sh $ANALYSIS
# remove conda prefix from $PATH so cmakes uses the LCG stack python and not the conda one
source ${ANALYSIS_PATH}/CROWN/init.sh ${ANALYSIS}
# remove conda prefix from ${PATH} so cmakes uses the LCG stack python and not the conda one
if [[ ! -z "${CONDA_PREFIX}" ]]; then
PATH=$(echo $PATH | sed "s@$CONDA_PREFIX@@g")
# PATH=$(echo $PATH | sed 's%/cvmfs/etp.kit.edu/[^:]*:%%g')
PATH=$(echo ${PATH} | sed "s@${CONDA_PREFIX}@@g")
# PATH=$(echo ${PATH} | sed 's%/cvmfs/etp.kit.edu/[^:]*:%%g')
CONDA_PYTHON_EXE=""
CONDA_EXE=""
CONDA_PREFIX=""
Expand All @@ -26,34 +26,34 @@ fi
THREADS_AVAILABLE=$(grep -c ^processor /proc/cpuinfo)
# THREADS=$(( THREADS_AVAILABLE / 4 ))
THREADS=2
echo "Using $THREADS threads for the compilation"
echo "Using ${THREADS} threads for the compilation"
which cmake

if cmake $CROWNFOLDER \
-DANALYSIS=$ANALYSIS \
-DCONFIG=$CONFIG \
-DSAMPLES=$SAMPLES \
-DERAS=$ERAS \
-DSCOPES=$SCOPE \
-DSHIFTS=$SHIFTS \
-DINSTALLDIR=$INSTALLDIR \
if cmake ${CROWNFOLDER} \
-DANALYSIS=${ANALYSIS} \
-DCONFIG=${CONFIG} \
-DSAMPLES=${SAMPLES} \
-DERAS=${ERAS} \
-DSCOPES=${SCOPE} \
-DSHIFTS=${SHIFTS} \
-DINSTALLDIR=${INSTALLDIR} \
-DPRODUCTION=True \
-DFRIENDS=true \
-DQUANTITIESMAP=$QUANTITIESMAP \
-B$BUILDDIR 2>&1 | tee $BUILDDIR/cmake.log; then
-DQUANTITIESMAP=${QUANTITIESMAP} \
-B${BUILDDIR} 2>&1 | tee ${BUILDDIR}/cmake.log; then
echo "CMake finished successfully"
else
echo "-------------------------------------------------------------------------"
echo "CMake failed, check the log file $BUILDDIR/cmake.log for more information"
echo "CMake failed, check the log file ${BUILDDIR}/cmake.log for more information"
echo "-------------------------------------------------------------------------"
sleep 0.1 # wait for the log file to be written
exit 1
fi

cd $BUILDDIR
cd ${BUILDDIR}
echo "Finished preparing the compilation and starting to compile"
make install -j $THREADS 2>&1 |tee $BUILDDIR/build.log
make install -j ${THREADS} 2>&1 |tee ${BUILDDIR}/build.log
echo "Finished the compilation and starting to make the *.tar.gz archive"
cd $INSTALLDIR
touch $TARBALLNAME
tar -czvf $TARBALLNAME --exclude=$TARBALLNAME .
cd ${INSTALLDIR}
touch ${TARBALLNAME}
tar -czvf ${TARBALLNAME} --exclude=${TARBALLNAME} .
38 changes: 19 additions & 19 deletions processor/tasks/scripts/compile_crown_lib.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
#! /bin/bash
CROWNFOLDER=$1
INSTALLDIR=$2
BUILDDIR=$3
ANALYSIS=$4
CROWNFOLDER=${1}
INSTALLDIR=${2}
BUILDDIR=${3}
ANALYSIS=${4}

echo "Crown folder: $CROWNFOLDER"
echo "Install dir: $INSTALLDIR"
echo "Build dir: $BUILDDIR"
echo "Crown folder: ${CROWNFOLDER}"
echo "Install dir: ${INSTALLDIR}"
echo "Build dir: ${BUILDDIR}"
# setup with analysis clone if needed
set -o pipefail
set -e
source $ANALYSIS_PATH/CROWN/init.sh $ANALYSIS
# remove conda prefix from $PATH so cmakes uses the LCG stack python and not the conda one
source ${ANALYSIS_PATH}/CROWN/init.sh ${ANALYSIS}
# remove conda prefix from ${PATH} so cmakes uses the LCG stack python and not the conda one
if [[ ! -z "${CONDA_PREFIX}" ]]; then
PATH=$(echo $PATH | sed "s@$CONDA_PREFIX@@g")
# PATH=$(echo $PATH | sed 's%/cvmfs/etp.kit.edu/[^:]*:%%g')
PATH=$(echo ${PATH} | sed "s@${CONDA_PREFIX}@@g")
# PATH=$(echo ${PATH} | sed 's%/cvmfs/etp.kit.edu/[^:]*:%%g')
CONDA_PYTHON_EXE=""
CONDA_EXE=""
CONDA_PREFIX=""
fi
# use a fourth of the machine for compiling
THREADS_AVAILABLE=$(grep -c ^processor /proc/cpuinfo)
THREADS=$(( THREADS_AVAILABLE / 4 ))
echo "Using $THREADS threads for the compilation"
echo "Using ${THREADS} threads for the compilation"
which cmake

if cmake $CROWNFOLDER \
if cmake ${CROWNFOLDER} \
-DBUILD_CROWNLIB_ONLY=ON \
-DINSTALLDIR=$INSTALLDIR \
-DANALYSIS=$ANALYSIS \
-B$BUILDDIR 2>&1 |tee $BUILDDIR/cmake.log; then
-DINSTALLDIR=${INSTALLDIR} \
-DANALYSIS=${ANALYSIS} \
-B${BUILDDIR} 2>&1 |tee ${BUILDDIR}/cmake.log; then
echo "CMake finished successfully"
else
echo "-------------------------------------------------------------------------"
echo "CMake failed, check the log file $BUILDDIR/cmake.log for more information"
echo "CMake failed, check the log file ${BUILDDIR}/cmake.log for more information"
echo "-------------------------------------------------------------------------"
sleep 0.1 # wait for the log file to be written
exit 1
fi
cd $BUILDDIR
cd ${BUILDDIR}
echo "Finished preparing the compilation and starting to compile"
make install -j $THREADS 2>&1 |tee $BUILDDIR/build.log
make install -j ${THREADS} 2>&1 |tee ${BUILDDIR}/build.log
echo "Finished the compilation crownlib build successfully"
6 changes: 3 additions & 3 deletions scripts/os-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
if ! command -v lsb_release &> /dev/null
then
source /etc/os-release
distro=$NAME
os_version=$VERSION_ID
distro=${NAME}
os_version=${VERSION_ID}
else
distro=$(lsb_release -i | cut -f2)
os_version=$(lsb_release -r | cut -f2)
fi
distro=${distro//[[:space:]]/}
distro="${distro//Linux/}"
distro="${distro//linux/}"
#echo "Trying to run Kingmaker on $distro Version $os_version"
#echo "Trying to run Kingmaker on ${distro} Version ${os_version}"
12 changes: 6 additions & 6 deletions scripts/python-formatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ FOUND_ISSUE=0
for FILENAME in $(find . -path ./law -prune -o -name "*.py");
do
# only run the check if the filename ends with .py
if [[ $FILENAME == *.py ]]; then
echo "Checking $FILENAME"
black --check $FILENAME
if [[ ${FILENAME} == *.py ]]; then
echo "Checking ${FILENAME}"
black --check ${FILENAME}
RETURN_VALUE=$?
if [ $RETURN_VALUE -ne 0 ]
if [ ${RETURN_VALUE} -ne 0 ]
then
black --diff $FILENAME 2> /dev/null
black --diff ${FILENAME} 2> /dev/null
FOUND_ISSUE=1
fi
fi
done

exit $FOUND_ISSUE
exit ${FOUND_ISSUE}
Loading