本文整理汇总了Python中Job.Job.ncpus方法的典型用法代码示例。如果您正苦于以下问题:Python Job.ncpus方法的具体用法?Python Job.ncpus怎么用?Python Job.ncpus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Job.Job
的用法示例。
在下文中一共展示了Job.ncpus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getJobs
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import ncpus [as 别名]
def getJobs(self):
self.numCpusInUse = 0
#p = PBSQuery.PBSQuery()
#jobslist = p.getjobs()
jobslist = pbs.pbs_statjob(self.con, "", "NULL", "NULL")
for jobInst in jobslist:
job = Job(jobInst.name)
#print "name is"+jobInst.name+"text is",jobInst.text,"next is",jobInst.next,"and this is",jobInst.this
for attrib in jobInst.attribs:
#print attrib.name+" is the name and the value is "+attrib.value
if attrib.name == 'Resource_List':
if attrib.resource == "nodes": #Value corresponding to nodes is in format (nodes=)X:ppn=Y[:property1[:propertyN]]
#value is an array of one item
if ":" in attrib.value: #Node data may be colon separated with procs per node and node properties
#print "value for nodes is %s" % attrib.value
#nodes,ppnstring = attrib.value.split(":")
nodeDataList = attrib.value.split(":")
job.numNodes = int(nodeDataList[0])
iterNum = 0 ##Needed to iterate through our properies and skip the first one.
for item in nodeDataList:
if "=" in item: #An equals suggests a nodes= or ppn= assignment
label,value = item.split("=")
if label == 'ppn':
job.ppn = int(value)
##No else, as it would match the walltime entry!
else: #No equals sign means this is a property
if iterNum > 0: ##unless its the num_nodes int we stripped off earlier!
job.properties.append(item)
#If node has a "cloud" property, its cloud, else hardware
iterNum += 1
else: #ppn not specified so is taken to be one
job.numNodes = int(attrib.value)
job.ppn = 1
job.ncpus = job.numNodes
elif attrib.resource == "walltime":
job.walltime = attrib.value
elif attrib.resource == "nodect":
job.nodect = attrib.value
else:
print "attrib resource is %s" % attrib.resource
elif attrib.name == 'qtime':
job.qtime = int(attrib.value)
elif attrib.name == 'job_state':
if attrib.value == 'Q':
job.status = 'queued'
self.queuedJobs.append(job)
elif attrib.value == 'R':
job.status = 'running'
self.numCpusInUse += job.ncpus
else:
job.status = 'other' #We are not interested in complete or errored jobs.
else:
pass
#print "Attrib name is %s and value is %s" % (attrib.name, attrib.value)
##Now we have acquired all the information we need from each job. Store the job
# data in our self.jobs array
job.ncpus = job.numNodes * job.ppn
self.jobs.append(job)
self.numJobs = len(self.jobs)
self.numQueuedJobs = len(self.queuedJobs)