6 """A class containing all information necessary to run given bash commands in an arbitrary batch system."""
8 def __init__(self, name, hours=0, nCores=1, memMB=0, basedir=""):
24 def write(self, useSingularity=True, extraDirs=[]):
25 executable =
"#!/bin/sh -\n"
29 platform =
str(os.environ[
'COMPILER_PATH']).
split(
'/')[-1].
replace(
'el9',
'almalinux9')
30 executable +=
'if [ "$1" != "--really" ]; then \n'
31 executable +=
' exec singularity exec -e --no-home'
32 for dir
in [
"/cvmfs",
"/var", self.
basedir,
"$(pwd | cut -d '/' -f 1-2)"] + extraDirs:
33 executable +=
' -B '+dir
34 executable +=
' /cvmfs/atlas.cern.ch/repo/containers/fs/singularity/'
35 executable += platform +
' /bin/bash -- "$0" --really "$@";\n'
37 executable +=
"shift;\n\n"
38 executable +=
"export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase\n"
39 executable +=
"source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh\n"
41 executable +=
"ulimit -f 1000000;\n"
42 executable +=
"cd "+self.
basedir+
"\n\n"
45 executable += cmd+
"\n"
46 executable +=
"exit 0\n"
50 with open(filename,
'w')
as f:
54 st = os.stat(filename)
55 os.chmod(filename, st.st_mode | stat.S_IEXEC)