Skip to content
Snippets Groups Projects
Commit 4dd10a34 authored by mads's avatar mads
Browse files

hawc2_pbsjob included in cluster_simulation

parent c14d1135
No related branches found
No related tags found
2 merge requests!6Clustertools,!5Clustertools
Pipeline #
from wetb.hawc2.htc_file import HTCFile
from wetb.utils.cluster_tools.pbsjob import PBSJob
from wetb.hawc2.log_file import LogInterpreter
import os
import time
from wetb.utils.cluster_tools import pbsjob
class HAWC2PBSJob(PBSJob):
def __init__(self, host, username, password):
PBSJob.__init__(self, host, username, password)
def submit(self, job, cwd, pbs_out_file):
with open (cwd + job) as fid:
htcfilename = [l for l in fid if l.startswith('wine')][0].rsplit(" ", 1)[1].strip()
print (htcfilename)
htcfile = HTCFile(cwd + htcfilename)
self.log_filename = htcfile.simulation.logfile[0]
self.loginterpreter = LogInterpreter(htcfile.simulation.time_stop[0])
PBSJob.submit(self, job, cwd, pbs_out_file)
def status_monitor(self, update=5):
i = 0
self.loglinenumber = 0
while self.in_queue():
i += 1
print (i, self.status, self.get_nodeid())
if self.status is pbsjob.RUNNING:
#self.test()
scratch_log_filename = "/scratch/%s/%s.g-000.risoe.dk/%s" % (self.client.username, self.jobid, self.log_filename)
try:
n, out, err = self.client.execute('tail --lines=+%d %s' % (self.loglinenumber, scratch_log_filename))
self.loginterpreter.update_status(out)
print (self.loginterpreter.status, self.loginterpreter.pct, self.loginterpreter.remaining_time, self.loginterpreter.lastline)
with open("status" + self.jobid, 'w') as fid:
fid.write(";".join([self.loginterpreter.status, str(self.loginterpreter.pct), str(self.loginterpreter.remaining_time), self.loginterpreter.lastline]))
#print (out)
self.loglinenumber += out.count ("\n")
#print (err)
except Warning as e:
if not "tail: cannot open" in str(e):
print (str(e))
time.sleep(update)
print (i, self.status, self.get_nodeid())
def test(self):
self.log_filename = "logfiles/short.log"
scratch_log_filename = "/scratch/%s/%s.g-000.risoe.dk/%s" % (self.client.username, self.jobid, self.log_filename)
print (scratch_log_filename)
try:
n, out, err = self.client.execute('tail --lines=+%d %s' % (self.loglinenumber, scratch_log_filename))
print (n)
print (out)
self.loglinenumber += out.count ("\n")
print (err)
except Warning as e:
print (str(e))
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