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

Merge branch 'papeleux' into 'master'

parametricJob : fix kill scripts

See merge request am-dept/linuxbin!38
parents e54a67dc e9dd37c9
No related branches found
Tags v3047
No related merge requests found
add2env PATH "/opt/cmake/bin" front
add2env PATH "/opt/gmsh/bin" front
add2env LD_LIBRARY_PATH "/opt/gmsh/lib"
add2env PYTHONPATH "/opt/gmsh/lib"
add2env PATH "/opt/matlab/bin"
add2env LD_LIBRARY_PATH "/opt/mumps/lib"
add2env LIB "/opt/mumps/lib"
add2env INCLUDE "/opt/mumps/include"
# Intel compiler and/or TBB/MKL
#
# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
if [ -d /opt/intel ] ; then
#. /opt/intel/oneapi/setvars.sh intel64
# since last update of one api latest -> 2022.2.0 (not complete)
. /opt/intel/oneapi/tbb/latest/env/vars.sh intel64
. /opt/intel/oneapi/mkl/latest/env/vars.sh intel64
. /opt/intel/oneapi/compiler/latest/env/vars.sh intel64
#. /opt/intel/oneapi/tbb/2021.6.0/env/vars.sh intel64
#. /opt/intel/oneapi/mkl/2022.1.0/env/vars.sh intel64
#. /opt/intel/oneapi/compiler/2022.1.0/env/vars.sh intel64
fi
# Intel compiler and/or TBB/MKL
#
# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
if [ -d /opt/intel ] ; then
#. /opt/intel/oneapi/setvars.sh intel64
. /opt/intel/oneapi/tbb/latest/env/vars.sh intel64
. /opt/intel/oneapi/mkl/latest/env/vars.sh intel64
. /opt/intel/oneapi/compiler/latest/env/vars.sh intel64
fi
# Parasolid
add2env PATH "/opt/parasolid/shared_object"
add2env INCLUDE "/opt/parasolid"
export P_SCHEMA=/opt/parasolid/schema
export SAM_ZONE=200000000
add2env PATH "/opt/samcef"
#
add2env PATH "/opt/cmake/bin" front
......@@ -4,7 +4,7 @@
#from future import standard_library
#standard_library.install_aliases()
import sys, os, os.path, shutil, socket, platform, glob, fnmatch
import datetime, tarfile, subprocess, string
import datetime, tarfile, subprocess, string, re
from prmClasses import *
# -- Base Class ----------------------------------------------------------------
......@@ -35,7 +35,6 @@ class ParametricJob(PRMSet):
return niceCmd
def getMailData(self):
import re
fromAddr = "%s@%s" % (os.path.basename(sys.argv[0]), socket.gethostbyaddr(socket.gethostname())[0])
toAddr = self.pars['MAIL_ADDR'].val
if re.match('(.+)@(.+)',toAddr):
......@@ -166,7 +165,6 @@ class ParametricJob(PRMSet):
return cfgfile
def hasSysCmd(self, cmd):
import subprocess
status, result = subprocess.getstatusoutput("which %s" % cmd)
return status==0
......@@ -269,7 +267,6 @@ class ParametricJob(PRMSet):
# get guess profile
cfgfile = self.guessProfile()
cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile)
import re
m = re.compile(cfgFileName+'([0-9]+)\\'+cfgFileExtension)
#print (cfgFileName+'([0-9]+)\\'+cfgFileExtension)
launchId = 0
......@@ -297,7 +294,7 @@ class ParametricJob(PRMSet):
#file.write("echo \"at JobId = $jobId\"\n")
#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]) #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.write('setsid %s -x -i %d -d "%s"\n' % (script, launchId, os.getcwd()) ) # setsid added to generate a new process group (used to easily kill process tree), else the process group is the same as atd daemon (=> killScript kill all at process running)
file.close()
os.chmod(scriptname,0o700)
......@@ -312,14 +309,12 @@ class ParametricJob(PRMSet):
#shcmd="at now + 1 minutes -f %s" % (scriptname)
#shcmd="at now %s" % scriptname
print("shcmd = ", shcmd)
import subprocess
status, result = subprocess.getstatusoutput(shcmd)
if status!=0:
print("Job submission FAILED!")
else:
print("Submission SUCCESSFUL!")
#print "result = ", result
import re
m = re.search('job ([0-9]+)',result)
batchId = m.group(1)
#print m.group
......@@ -402,14 +397,12 @@ class ParametricJob(PRMSet):
# send to sge
print("sending job '%s' to SGE" % jobname)
shcmd="qsub ./%s" % scriptname
import subprocess
status, result = subprocess.getstatusoutput(shcmd)
print(result)
if status!=0:
print("Job submission FAILED!")
else:
print("Submission SUCCESSFUL!")
import re
m = re.compile('Your job ([0-9]+)').match(result)
sgeId = m.group(1)
if m:
......@@ -498,14 +491,12 @@ class ParametricJob(PRMSet):
# send to slurm
print("sending job '%s' to Slurm" % jobname)
shcmd="sbatch ./%s" % scriptname
import subprocess
status, result = subprocess.getstatusoutput(shcmd)
print(result)
if status!=0:
print("Job submission FAILED!")
else:
print("Submission SUCCESSFUL!")
import re
m = re.compile('Submitted batch job ([0-9]+)').match(result)
slurmId = m.group(1)
if m:
......@@ -628,7 +619,6 @@ class ParametricJob(PRMSet):
# send to PBS
print('sending job "%s" to PBS' % jobname)
shcmd='qsub ./%s' % scriptname
import subprocess
status, result = subprocess.getstatusoutput(shcmd)
print('command status = ', status)
print('command result = ', result)
......@@ -644,23 +634,6 @@ class ParametricJob(PRMSet):
self.PBSCancelScript(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)
'''
#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
if not (re.match(r'(.+)Gui.pyw', sys.argv[0])):
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