Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark E Smith committed Apr 24, 2024
1 parent a4fe6bd commit 3b3d5e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 16 additions & 3 deletions ganga/GangaLHCb/Lib/Applications/GaudiExec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from os import rename, path, unlink, listdir, chmod
from os import stat as os_stat
import os
import random
import tempfile
import time
Expand Down Expand Up @@ -557,7 +558,18 @@ def execCmd(self, cmd):
if isLbEnv:
initialCommand = 'source /cvmfs/lhcb.cern.ch/lib/LbEnv && source LbLogin.sh -c %s && make -j%s' % (
self.platform, self.nMakeCores)
rc, stdout, stderr = _exec_cmd(initialCommand, self.directory)
if self.useApptainer or 'slc6' in self.platform:
try:
logger.info('Building inside apptainer: %s' % self.containerLocation)
cmd_to_run = 'apptainer exec --bind $PWD --bind %s --bind /cvmfs:/cvmfs:ro ' % os.environ['TMPDIR']\
+ self.containerLocation + ' bash -c "%s"' % initialCommand
rc, stdout, stderr = _exec_cmd(cmd_to_run, self.directory)
except BaseException:
logger.error('Failed to build the application inside a container. '
'Perhaps the specified container location is not accessible.')
raise GangaException('Failed to execute make command')
else:
rc, stdout, stderr = _exec_cmd(initialCommand, self.directory)
if rc != 0:
logger.error("Failed to perform initial make on a Cmake based project")
logger.error("This is required so that the './run' target exists and is callable within the project")
Expand All @@ -569,10 +581,11 @@ def execCmd(self, cmd):
if self.useApptainer or 'slc6' in self.platform:
try:
logger.info('Building inside apptainer: %s' % self.containerLocation)
cmd_to_run = 'apptainer exec --bind $PWD --bind /tmp --bind /cvmfs:/cvmfs:ro '\
cmd_to_run = 'apptainer exec --bind $PWD --bind %s --bind /cvmfs:/cvmfs:ro ' % os.environ['TMPDIR']\
+ self.containerLocation + ' bash -c "source ' + cmd_file.name + '"'
rc, stdout, stderr = _exec_cmd(cmd_to_run, self.directory)
except BaseException:
except BaseException as err:
print(err)
logger.error('Failed to build the application inside a container. '
'Perhaps the specified container location is not accessible.')
raise GangaException('Failed to execute make command')
Expand Down
2 changes: 0 additions & 2 deletions ganga/GangaLHCb/Lib/RTHandlers/GaudiExecRTHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ def prepareCommand(app):
full_cmd += ' dbTags.py'
if app.extraArgs:
full_cmd += " " + " ".join(app.extraArgs)
if app.useApptainer or 'slc6' in app.platform:
full_cmd = 'apptainer exec --env "PATH=$PATH" --bind $PWD --bind /cvmfs:/cvmfs:ro %s bash -c "%s"' % (app.containerLocation, full_cmd)

return full_cmd

Expand Down

0 comments on commit 3b3d5e7

Please sign in to comment.