From efb553813328f982a3d80eb8ab1ff7b2f6f7f7f2 Mon Sep 17 00:00:00 2001 From: Nick Hastings Date: Wed, 8 Jan 2025 08:31:52 +0900 Subject: [PATCH] Feature: option to use containers for ND280 RDP --- ganga/GangaND280/ND280Control/runND280RDP.py | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ganga/GangaND280/ND280Control/runND280RDP.py b/ganga/GangaND280/ND280Control/runND280RDP.py index ad32f85b81..00b5aeac0c 100644 --- a/ganga/GangaND280/ND280Control/runND280RDP.py +++ b/ganga/GangaND280/ND280Control/runND280RDP.py @@ -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__() @@ -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' @@ -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()