Skip to content

Commit

Permalink
Feature: option to use containers for ND280 RDP
Browse files Browse the repository at this point in the history
  • Loading branch information
NickHastings committed Jan 7, 2025
1 parent 0d13df4 commit efb5538
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions ganga/GangaND280/ND280Control/runND280RDP.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,21 @@ class runND280RDP(IPrepareApp):
comparable=1,
doc='Location of shared resources. Presence of this attribute implies the application has been prepared.',
),
'container': SimpleItem(
defvalue=None, doc='Path to container', typelist=['type(None)', 'str']
),
'binds': SimpleItem(
defvalue=[],
doc='Container paths to bind',
typelist=['str'],
sequence=1,
strict_sequence=0,
),
},
)
_category = 'applications'
_name = 'runND280RDP'
_exportmethods = ['prepare']

def __init__(self):
super(runND280RDP, self).__init__()

Expand Down Expand Up @@ -142,7 +151,15 @@ def configure(self, masterappconfig):

argsStr = ' '.join(args)
# Create the bash script and put it in input dir.
self._scriptname = job.inputdir + 'runND280.sh'
script = '#!/bin/bash\n'
if self.container:
bs = ' '.join([f'--bind {b}' for b in self.binds])
script += 'AM_IN_CONTAINER="$1"\n'
script += 'if [ "$AM_IN_CONTAINER" = "" ]; then\n'
script += f' exec apptainer exec {bs} {self.container} {self._scriptname} "1"\n'
script += 'fi\n'

for f in self.cmtsetup:
script += 'source ' + f + '\n'
script += 'cd ' + job.outputdir + '\n'
Expand All @@ -151,8 +168,6 @@ def configure(self, masterappconfig):
FileBuffer('runND280.sh', script), executable=1
)

self._scriptname = job.inputdir + 'runND280.sh'

# Possibly gives job a name after run/subrun numbers
if job.inputdata:
infiles = job.inputdata.get_dataset_filenames()
Expand Down

0 comments on commit efb5538

Please sign in to comment.