From 02fb2a26daa5ecf9a9e2c2c4b49dec3240f0164d Mon Sep 17 00:00:00 2001 From: Luc Papeleux <L.Papeleux@ULiege.be> Date: Thu, 25 Jun 2020 16:24:14 +0200 Subject: [PATCH] debug RunBatch for delayed start --- parametricJob.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/parametricJob.py b/parametricJob.py index f351a8a..1a53bec 100644 --- a/parametricJob.py +++ b/parametricJob.py @@ -265,18 +265,34 @@ class ParametricJob(PRMSet): # AT/BATCH SPECIFIC def runBatch(self): # get guess profile - cfgfile = self.guessProfile() + cfgfile = self.guessProfile() + cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile) + import re + m = re.compile(cfgFileName+'([0-9]+)\.'+cfgFileExtension) + launchId = 0 + for fn in os.listdir('.'): + out = m.search(fn) + if out : + outId = int(out.group(1)) + if outId > launchId : + lauchId = outId + launchId +=1 + print ("launchId =", launchId) + os.system("cp %s %s%s%s"%(self.cfgfile, cfgFileName, launchId, cfgFileExtension)) + # build script - scriptname="runbatch.sh" + scriptname="runbatch%d.sh"%launchId file = open(scriptname,"w") file.write("#!/bin/bash\n") # this avoids /bin/sh when sh=dash file.write(". %s\n" % cfgfile) - file.write("echo `atq`\n") - file.write("jobId=`atq | awk '{if ($1>jobId)jobId=$1} END {print jobId}'`\n") - file.write("echo \"at JobId = $jobId\"\n") - file.write('%s -x -i $jobId -d "%s"\n' % (sys.argv[0], os.getcwd()) ) + #file.write("echo `atq`\n") + #file.write("jobId=`atq | awk '{if ($1>jobId)jobId=$1} END {print jobId}'`\n") + #file.write("echo \"at JobId = $jobId\"\n") + #file.write('%s -x -i $jobId -d "%s"\n' % (sys.argv[0], os.getcwd()) ) + file.write('%s -x -i %d -d "%s"\n' % (sys.argv[0], launchId, os.getcwd()) ) file.close() os.chmod(scriptname,0o700) + print("starting script in batch mode: %s" % scriptname) #shcmd="at %s -f %s" % (self.pars['BATCHTIME'].val, scriptname) if self.pars['RUNMETHOD'].val == "at" : @@ -300,8 +316,8 @@ class ParametricJob(PRMSet): batchId = m.group(1) #print m.group if m: - cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile) - os.system("cp %s %s%s%s"%(self.cfgfile, cfgFileName, batchId, cfgFileExtension)) + #cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile) + #os.system("cp %s %s%s%s"%(self.cfgfile, cfgFileName, batchId, cfgFileExtension)) self.atrmScript(batchId) print("\tuse 'atq' and find job number %s to check the status of your job" % batchId) print("\t\t - 'a' means waiting in the queue 'a'") -- GitLab