From 43e5ed0bb945b7b4b05c9ea1853fc8c3c6de700d Mon Sep 17 00:00:00 2001 From: Luc Papeleux <L.Papeleux@ULiege.be> Date: Wed, 13 Jul 2022 16:43:06 +0200 Subject: [PATCH] fix launchGuy for non interactive use (at, batch, slurm,...) by replacing '*Guy.pyw' by '*.py' in runBatch, runSge, runSlurm,... I also add a test to not close the gui when launching a nonInteractive job --- cfg/blueberry/launch.cfg | 2 +- parametricJob.py | 31 +++++++++++++++++++++++-------- postProLoop.py | 8 ++++---- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/cfg/blueberry/launch.cfg b/cfg/blueberry/launch.cfg index 12256a8..d66afc5 100644 --- a/cfg/blueberry/launch.cfg +++ b/cfg/blueberry/launch.cfg @@ -1,4 +1,4 @@ -self.pars['NB_THREADS'].val='6' +self.pars['NB_THREADS'].val='4' self.pars['NB_TASKS'].val='1' self.pars['RUNMETHOD'].vals=['interactive','at','batch'] self.pars['RUNMETHOD'].val='batch' diff --git a/parametricJob.py b/parametricJob.py index ce51a0f..95d7d01 100644 --- a/parametricJob.py +++ b/parametricJob.py @@ -296,7 +296,8 @@ class ParametricJob(PRMSet): #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()) ) + script = re.sub(r'(.+)Gui.pyw',r'\1.py', sys.argv[0]) #if launched through a Gui => use the basic script instead in batch + file.write('%s -x -i %d -d "%s"\n' % (script, launchId, os.getcwd()) ) file.close() os.chmod(scriptname,0o700) @@ -331,7 +332,9 @@ class ParametricJob(PRMSet): print("\t\t - '=' means running") print("\tuse 'atrm %s to kill the job" % batchId) print("\t\t or 'atrm%s.py' to kill the job" % batchId) - sys.exit() + # to avoid closing the gui + if not (re.match(r'(.+)Gui.pyw', sys.argv[0])): + sys.exit() def atrmScript(self, pid): filename = "atrm%s.py"%pid @@ -391,7 +394,10 @@ class ParametricJob(PRMSet): file.write("#$ %s\n" % self.pars['SGEARGS'].val) import socket file.write(". %s %s\n" % (cfgfile,socket.gethostname())) - file.write("%s -x -i $JOB_ID\n" % (sys.argv[0])) + #file.write('%s -x -i $jobId -d "%s"\n' % (sys.argv[0], os.getcwd()) ) + script = re.sub(r'(.+)Gui.pyw',r'\1.py', sys.argv[0]) + file.write("%s -x -i $JOB_ID\n" % (script)) + #file.write("%s -x -i $JOB_ID\n" % (sys.argv[0])) file.close() # send to sge print("sending job '%s' to SGE" % jobname) @@ -415,7 +421,9 @@ class ParametricJob(PRMSet): print("\tuse './%s' to get results from node disk" % self.cpNodeResultsScriptName(sgeId)) print("\tuse './%s' to clean results from node disk" % self.rmNodeResultsScriptName(sgeId)) print("\tuse './qDel%s.py' to kill your job, get results and clean node disk" % sgeId) - sys.exit() + # to avoid closing the gui + if not (re.match(r'(.+)Gui.pyw', sys.argv[0])): + sys.exit() def qDelScriptName(self, jobId): filename = "qDel%s.py"%jobId @@ -483,7 +491,8 @@ class ParametricJob(PRMSet): #file.write("echo 'squeue'\n") import socket file.write(". %s %s\n" % (cfgfile, socket.gethostname())) - file.write("srun %s -x -i $SLURM_JOB_ID \n" % (sys.argv[0])) + script = re.sub(r'(.+)Gui.pyw',r'\1.py', sys.argv[0]) + file.write("srun %s -x -i $SLURM_JOB_ID \n" % (script)) file.close() os.chmod(scriptname,0o700) # send to slurm @@ -508,7 +517,10 @@ class ParametricJob(PRMSet): print("\tuse ' sstat -a --format=JobID,NTasks,MaxRSS,MaxVMSize -j %s ' to get information about your running job (adapt format to your needs)" % slurmId) print("\tuse ' scancel %s ' to kill your job" % slurmId) print("\tuse ' sacct --format=JobID,NTasks,NCPUS,CPUTime,Elapsed,MaxRSS,MaxVMSize -j %s ' to get information about your finished job (adapt format to your needs)" % slurmId) - sys.exit() + + # to avoid closing the gui + if not (re.match(r'(.+)Gui.pyw', sys.argv[0])): + sys.exit() def sCancelScriptName(self, jobId): filename = "sCancel%s.py"%jobId @@ -608,7 +620,8 @@ class ParametricJob(PRMSet): # Lanch the job import socket file.write('. %s %s\n' % (cfgfile, socket.gethostname())) - file.write('%s -x -i $PBS_JOBID\n' % (sys.argv[0])) + script = re.sub(r'(.+)Gui.pyw',r'\1.py', sys.argv[0]) + file.write('%s -x -i $PBS_JOBID\n' % (script)) file.write('qstat -f $PBS_JOBID\n') file.close() os.chmod(scriptname,0o700) @@ -648,7 +661,9 @@ class ParametricJob(PRMSet): print "\tuse ' qdel %s ' to kill your job" % PbsId #print "\tuse ' sacct --format=JobID,NTasks,NCPUS,CPUTime,Elapsed,MaxRSS,MaxVMSize -j %s ' to get information about your finished job (adapt format to your needs)" % PbsId ''' - sys.exit() + # to avoid closing the gui + if not (re.match(r'(.+)Gui.pyw', sys.argv[0])): + sys.exit() def PBSCancelScriptName(self, jobId): filename = "qdel%s.py"%jobId diff --git a/postProLoop.py b/postProLoop.py index d66fdfe..d09e9e2 100755 --- a/postProLoop.py +++ b/postProLoop.py @@ -148,10 +148,10 @@ class PostProLoop(PRMSet): if shutil.which(self.pars[key].val): return True else: - print "%s is not found (%s)...."%self.pars[key].val - print "\t Check installation and accessibility..." - print "\t Use 'externalProgramPathGui' to define the full program path (recommanded)" - print "\t or add %s in your user path (not recommanded)"%key + print ("%s is not found (%s)...."%self.pars[key].val) + print ("\t Check installation and accessibility...") + print ("\t Use 'externalProgramPathGui' to define the full program path (recommanded)") + print ("\t or add %s in your user path (not recommanded)"%key) return False ''' if distutils.spawn.find_executable(os.path.splitext(self.pars[key].val)[0]): -- GitLab