Skip to content

Commit

Permalink
Added some code to support adding nodes in arrays. This code will
Browse files Browse the repository at this point in the history
expand the array and count every subtask individually. rb
  • Loading branch information
rqbanerjee authored and = committed Aug 2, 2010
1 parent bace307 commit 17998a6
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions starcluster/balancers/sge/__init__.py
Expand Up @@ -23,7 +23,7 @@ class SGEStats(object):
jobs = []
jobstats = []
_default_fields = \
["JB_job_number","state","JB_submission_time","queue_name","slots"]
["JB_job_number","state","JB_submission_time","queue_name","slots","tasks"]

def parse_qhost(self,string):
"""
Expand Down Expand Up @@ -64,9 +64,31 @@ def parse_qstat(self,string, fields=None):
if node2.nodeType == Node.TEXT_NODE:
hash[tag] = node2.data
#grab the submit time on all jobs, the last job's val stays
self.jobs.append(hash)
if 'tasks' in hash and hash['tasks'].find('-') > 0:
self.job_multiply(hash)
else:
self.jobs.append(hash)
return self.jobs

def job_multiply(self,hash):
"""
this function deals with sge jobs with a task range, ie qsub -t 1-20:1
makes 20 jobs. self.jobs needs to represent that it is 20 jobs instead
of just 1.
"""
sz_range = hash['tasks']
dashpos = sz_range.find('-')
colpos = sz_range.find(':')
start = int(sz_range[0:dashpos])
fin = int(sz_range[dashpos+1:colpos])
gran = int(sz_range[colpos+1:len(sz_range)])
log.debug("start = %d, fin = %d, dashpos = %d, gran = %d,\n sz_range = %s." % \
(start,fin,dashpos,gran, sz_range))
num_jobs = (fin - start) / gran
log.debug("This job expands to %d tasks." % num_jobs)
for n in range(0,num_jobs):
self.jobs.append(hash)

def parse_qacct(self,string,dtnow):
"""
This method parses qacct -j output and makes a neat array and
Expand Down

0 comments on commit 17998a6

Please sign in to comment.