本文整理汇总了Python中JobManager.updateJobsStatus方法的典型用法代码示例。如果您正苦于以下问题:Python JobManager.updateJobsStatus方法的具体用法?Python JobManager.updateJobsStatus怎么用?Python JobManager.updateJobsStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JobManager
的用法示例。
在下文中一共展示了JobManager.updateJobsStatus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import updateJobsStatus [as 别名]
#.........这里部分代码省略.........
self.logger.info("jobInfo.validation: "+jobInfo.validation)
#check db to see if no run/jobconfig already there
cursor.execute('select run, jobconfiguration from JOBSTATUS')
alreadyInJobDb = False
for row in cursor:
if row[0]==str(jobInfo.runNumber) and row[1]==str(jobInfo.jobConfiguration.name):
alreadyInJobDb = True
break
if not alreadyInJobDb:
self.jobInformationList.append(jobInfo)
cursor.execute("insert into JOBSTATUS(id, run, jobconfiguration, status, validation) values (null, ?, ?, ?, ?)", (jobInfo.runNumber, jobInfo.jobConfiguration.name, jobInfo.status, jobInfo.validation))
self.logger.info(jobInfo.runNumber+'_'+jobInfo.jobConfiguration.name+" added to jobInformation list")
else:
self.logger.info(jobInfo.runNumber+'_'+jobInfo.jobConfiguration.name+" already exist in the job DB")
# set run as 'seen' in runstatus DB
cursor.execute("update RUNSTATUS set status=? where run=?",('OK',str(runInfo.runNumber)))
connection.commit()
else:
self.logger.debug("-> No new runs found in run DB")
###===============================================================###
# check job with status = NEW that are not in current job list
# ie job modified by external progs after the deamon start
# reprocess attribute ?
self.logger.debug("looking for new jobs in job DB")
newJobs = self.newJobsFromDb()
for newJob in newJobs:
alreadyInJobList = False
for jobInfo in self.jobInformationList:
if str(jobInfo.runNumber)==str(newJob.runNumber) and str(jobInfo.jobConfiguration.name)==str(newJob.jobConfiguration.name):
alreadyInJobList=True
break
if not alreadyInJobList:
self.jobInformationList.append(newJob)
self.logger.debug("job "+jobInfo.runNumber+'_'+jobInfo.jobConfiguration.name+" added to jobInformation list")
else:
self.logger.debug("job "+jobInfo.runNumber+'_'+jobInfo.jobConfiguration.name+" already in jobInformation list")
###===============================================================###
# update validation state from DB for jobs with validation=WAITING
for jobInfo in self.jobInformationList:
if jobInfo.validation=="WAITING":
cursor.execute('select validation from JOBSTATUS where run=? and jobconfiguration=?',(jobInfo.runNumber, jobInfo.jobConfiguration.name))
jobInfo.validation = cursor.fetchone()[0]
###=============================###
# update job status from JobManager
self.jobManager.updateJobsStatus()
###===========================================================###
# remove job DONE or validation=BAD from self.jobInformationList
# do not touch the DB
for jobInfo in reversed(self.jobInformationList):
if jobInfo.validation=="BAD" or jobInfo.status=="DONE":
self.logger.debug("removing jobInformation "+jobInfo.runNumber+'_'+jobInfo.jobConfiguration.name+ ", status: "+jobInfo.status+", validation: "+jobInfo.validation)
#delete the jobInfo associated config file
cmd = 'rm '+jobInfo.jobConfigModulePath.strip('.py')+'.*'
commands.getoutput(cmd)
#remove jobInfo form list
self.jobInformationList.remove(jobInfo)
connection.close()
return
def submitBatchJobs(self):
jobInfoList=[]
#select jobs to be processed (is validated==NONE or YES? is set/dependencies complete ?)
for jobInfo in self.jobInformationList:
if (jobInfo.validation=="NONE" or jobInfo.validation=="YES") and jobInfo.status=="NEW":
jobInfoList.append(jobInfo)
#print jobInfoList
self.jobManager.addNewJobs(jobInfoList)
return
def processBatchJobs(self):
self.jobManager.processJobs()
return