Skip to content

Commit

Permalink
Proposed solution for running slc6 jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
egede committed Apr 24, 2024
1 parent 9596281 commit 829aaa6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ganga/GangaCore/Lib/Localhost/LocalHostExec.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ sys.path.insert(0,os.path.join(os.getcwd(),PYTHON_DIR))

runenv = dict()
result = subprocess.run(["bash", "-lc", "printenv"], capture_output=True, encoding='utf-8')
for line in result.stdout.split('\n'):
for line in result.stdout.split('\\n'):
varval = line.strip().split('=')
if len(varval) < 2:
pass
Expand Down
19 changes: 17 additions & 2 deletions ganga/GangaLHCb/Lib/RTHandlers/GaudiExecRTHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ def prepareCommand(app):
for _arg in app.run_args:
run_args += ' %s ' % _arg

run_cmd = ' export ganga_jobid=%s && ./run %s ' % (app.getJobObject().fqid, run_args)
run_cmd = f' export ganga_jobid={app.getJobObject().fqid} && ./run {run_args} '
if 'slc6' in app.platform:
run_cmd = f'sed -i "s/lb-run /lb-run --container apptainer /g" ./run && {run_cmd}'

if not app.useGaudiRun:
full_cmd = sourceEnv + run_cmd + 'python %s' % app.getWrapperScriptName()
Expand Down Expand Up @@ -792,13 +794,26 @@ def flush_streams(pipe):
# Extract any/_all_ (b/g)zip files on the WN
extractAllTarFiles('.')
runenv = dict()
result = subprocess.run(["bash", "-lc",
"source /cvmfs/lhcb.cern.ch/lib/LbEnv && printenv"],
capture_output=True, encoding='utf-8')
for line in result.stdout.split('\\n'):
varval = line.strip().split('=')
if len(varval) < 2:
pass
else:
content = ''.join(varval[1:])
if not str(content).startswith('() {'):
runenv[varval[0]] = content
print("Executing: %s" % '###COMMAND###'+' '+' '.join(sys.argv[1:]))
# Execute the actual command on the WN
# NB os.system caused the entire stream to be captured before being streamed in some cases
pipe = subprocess.Popen('###COMMAND###'+' '+' '.join(sys.argv[1:]), shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
universal_newlines=True, errors="replace")
universal_newlines=True, errors="replace", env=runenv)
# Flush the stdout/stderr as the process is running correctly
flush_streams(pipe)
Expand Down

0 comments on commit 829aaa6

Please sign in to comment.