Skip to content
Snippets Groups Projects
Commit f2f2083a authored by Papeleux Luc's avatar Papeleux Luc
Browse files

fix import re for slurm & unify imports

parent e54a67dc
No related branches found
Tags v3035
No related merge requests found
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#from future import standard_library #from future import standard_library
#standard_library.install_aliases() #standard_library.install_aliases()
import sys, os, os.path, shutil, socket, platform, glob, fnmatch import sys, os, os.path, shutil, socket, platform, glob, fnmatch
import datetime, tarfile, subprocess, string import datetime, tarfile, subprocess, string, re
from prmClasses import * from prmClasses import *
# -- Base Class ---------------------------------------------------------------- # -- Base Class ----------------------------------------------------------------
...@@ -35,7 +35,6 @@ class ParametricJob(PRMSet): ...@@ -35,7 +35,6 @@ class ParametricJob(PRMSet):
return niceCmd return niceCmd
def getMailData(self): def getMailData(self):
import re
fromAddr = "%s@%s" % (os.path.basename(sys.argv[0]), socket.gethostbyaddr(socket.gethostname())[0]) fromAddr = "%s@%s" % (os.path.basename(sys.argv[0]), socket.gethostbyaddr(socket.gethostname())[0])
toAddr = self.pars['MAIL_ADDR'].val toAddr = self.pars['MAIL_ADDR'].val
if re.match('(.+)@(.+)',toAddr): if re.match('(.+)@(.+)',toAddr):
...@@ -166,7 +165,6 @@ class ParametricJob(PRMSet): ...@@ -166,7 +165,6 @@ class ParametricJob(PRMSet):
return cfgfile return cfgfile
def hasSysCmd(self, cmd): def hasSysCmd(self, cmd):
import subprocess
status, result = subprocess.getstatusoutput("which %s" % cmd) status, result = subprocess.getstatusoutput("which %s" % cmd)
return status==0 return status==0
...@@ -269,7 +267,6 @@ class ParametricJob(PRMSet): ...@@ -269,7 +267,6 @@ class ParametricJob(PRMSet):
# get guess profile # get guess profile
cfgfile = self.guessProfile() cfgfile = self.guessProfile()
cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile) cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile)
import re
m = re.compile(cfgFileName+'([0-9]+)\\'+cfgFileExtension) m = re.compile(cfgFileName+'([0-9]+)\\'+cfgFileExtension)
#print (cfgFileName+'([0-9]+)\\'+cfgFileExtension) #print (cfgFileName+'([0-9]+)\\'+cfgFileExtension)
launchId = 0 launchId = 0
...@@ -312,14 +309,12 @@ class ParametricJob(PRMSet): ...@@ -312,14 +309,12 @@ class ParametricJob(PRMSet):
#shcmd="at now + 1 minutes -f %s" % (scriptname) #shcmd="at now + 1 minutes -f %s" % (scriptname)
#shcmd="at now %s" % scriptname #shcmd="at now %s" % scriptname
print("shcmd = ", shcmd) print("shcmd = ", shcmd)
import subprocess
status, result = subprocess.getstatusoutput(shcmd) status, result = subprocess.getstatusoutput(shcmd)
if status!=0: if status!=0:
print("Job submission FAILED!") print("Job submission FAILED!")
else: else:
print("Submission SUCCESSFUL!") print("Submission SUCCESSFUL!")
#print "result = ", result #print "result = ", result
import re
m = re.search('job ([0-9]+)',result) m = re.search('job ([0-9]+)',result)
batchId = m.group(1) batchId = m.group(1)
#print m.group #print m.group
...@@ -402,14 +397,12 @@ class ParametricJob(PRMSet): ...@@ -402,14 +397,12 @@ class ParametricJob(PRMSet):
# send to sge # send to sge
print("sending job '%s' to SGE" % jobname) print("sending job '%s' to SGE" % jobname)
shcmd="qsub ./%s" % scriptname shcmd="qsub ./%s" % scriptname
import subprocess
status, result = subprocess.getstatusoutput(shcmd) status, result = subprocess.getstatusoutput(shcmd)
print(result) print(result)
if status!=0: if status!=0:
print("Job submission FAILED!") print("Job submission FAILED!")
else: else:
print("Submission SUCCESSFUL!") print("Submission SUCCESSFUL!")
import re
m = re.compile('Your job ([0-9]+)').match(result) m = re.compile('Your job ([0-9]+)').match(result)
sgeId = m.group(1) sgeId = m.group(1)
if m: if m:
...@@ -498,14 +491,12 @@ class ParametricJob(PRMSet): ...@@ -498,14 +491,12 @@ class ParametricJob(PRMSet):
# send to slurm # send to slurm
print("sending job '%s' to Slurm" % jobname) print("sending job '%s' to Slurm" % jobname)
shcmd="sbatch ./%s" % scriptname shcmd="sbatch ./%s" % scriptname
import subprocess
status, result = subprocess.getstatusoutput(shcmd) status, result = subprocess.getstatusoutput(shcmd)
print(result) print(result)
if status!=0: if status!=0:
print("Job submission FAILED!") print("Job submission FAILED!")
else: else:
print("Submission SUCCESSFUL!") print("Submission SUCCESSFUL!")
import re
m = re.compile('Submitted batch job ([0-9]+)').match(result) m = re.compile('Submitted batch job ([0-9]+)').match(result)
slurmId = m.group(1) slurmId = m.group(1)
if m: if m:
...@@ -628,7 +619,6 @@ class ParametricJob(PRMSet): ...@@ -628,7 +619,6 @@ class ParametricJob(PRMSet):
# send to PBS # send to PBS
print('sending job "%s" to PBS' % jobname) print('sending job "%s" to PBS' % jobname)
shcmd='qsub ./%s' % scriptname shcmd='qsub ./%s' % scriptname
import subprocess
status, result = subprocess.getstatusoutput(shcmd) status, result = subprocess.getstatusoutput(shcmd)
print('command status = ', status) print('command status = ', status)
print('command result = ', result) print('command result = ', result)
...@@ -644,23 +634,6 @@ class ParametricJob(PRMSet): ...@@ -644,23 +634,6 @@ class ParametricJob(PRMSet):
self.PBSCancelScript(PbsId) self.PBSCancelScript(PbsId)
print("\tuse ' qstat -f %s ' to check the status of the PBS scheduling queue of your job" % PbsId) print("\tuse ' qstat -f %s ' to check the status of the PBS scheduling queue of your job" % PbsId)
print("\tuse ' qdel %s ' to kill your job" % PbsId) print("\tuse ' qdel %s ' to kill your job" % PbsId)
'''
#import re
#m = re.compile('waiting for job ([0-9]+) to start').match(result)
#result : 3067709.frontal2
#m = re.compile('([0-9]+)\.(.+)').match(result)
#print "m = ", m
#PbsId = m.group(1)
if m:
cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile)
os.system("cp %s %s%s%s"%(self.cfgfile, cfgFileName, PbsId, cfgFileExtension))
self.PBSCancelScript(PbsId)
print "\tuse ' qstat -f %s ' to check the status of the PBS scheduling queue of your job" % PbsId
#print "\tuse ' sprio -l -j %s ' to check the factor priority of your job" % PbsId
#print "\tuse ' sstat -a --format=JobID,NTasks,MaxRSS,MaxVMSize -j %s ' to get information about your running job (adapt format to your needs)" % PbsId
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
'''
# to avoid closing the gui # to avoid closing the gui
if not (re.match(r'(.+)Gui.pyw', sys.argv[0])): if not (re.match(r'(.+)Gui.pyw', sys.argv[0])):
sys.exit() sys.exit()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment