本文整理汇总了Python中DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB.getJobOptParameter方法的典型用法代码示例。如果您正苦于以下问题:Python JobDB.getJobOptParameter方法的具体用法?Python JobDB.getJobOptParameter怎么用?Python JobDB.getJobOptParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB
的用法示例。
在下文中一共展示了JobDB.getJobOptParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OptimizerModule
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import getJobOptParameter [as 别名]
#.........这里部分代码省略.........
jobDef = {}
# If not jdl in jobinfo load it
if 'jdl' not in jobDef:
if self.requiredJobInfo == 'jdlOriginal':
result = self.jobDB.getJobJDL(job, original=True)
if not result['OK']:
self.log.error("No JDL for job", "%s" % job)
return S_ERROR("No JDL for job")
jobDef['jdl'] = result['Value']
if self.requiredJobInfo == 'jdl':
result = self.jobDB.getJobJDL(job)
if not result['OK']:
self.log.error("No JDL for job", "%s" % job)
return S_ERROR("No JDL for job")
jobDef['jdl'] = result['Value']
# Load the classad if needed
if 'jdl' in jobDef and 'classad' not in jobDef:
try:
classad = ClassAd(jobDef['jdl'])
except BaseException:
self.log.debug("Cannot load JDL")
return S_ERROR('Illegal Job JDL')
if not classad.isOK():
self.log.debug("Warning: illegal JDL for job %s, will be marked problematic" % (job))
return S_ERROR('Illegal Job JDL')
jobDef['classad'] = classad
return S_OK(jobDef)
#############################################################################
def getOptimizerJobInfo(self, job, reportName):
"""This method gets job optimizer information that will
be used for
"""
self.log.verbose("self.jobDB.getJobOptParameter(%s,'%s')" % (job, reportName))
result = self.jobDB.getJobOptParameter(job, reportName)
if result['OK']:
value = result['Value']
if not value:
self.log.warn('JobDB returned null value for %s %s' % (job, reportName))
return S_ERROR('No optimizer info returned')
else:
try:
return S_OK(eval(value))
except BaseException as x:
return S_ERROR('Could not evaluate optimizer parameters: %s' % repr(x))
return result
#############################################################################
def setOptimizerJobInfo(self, job, reportName, value):
"""This method sets the job optimizer information that will subsequently
be used for job scheduling and TURL queries on the WN.
"""
self.log.verbose("self.jobDB.setJobOptParameter(%s,'%s','%s')" % (job, reportName, value))
if not self.am_Enabled():
return S_OK()
return self.jobDB.setJobOptParameter(job, reportName, str(value))
#############################################################################
def setOptimizerChain(self, job, value):
"""This method sets the job optimizer chain, in principle only needed by
one of the optimizers.
"""
self.log.verbose("self.jobDB.setOptimizerChain(%s,%s)" % (job, value))
if not self.am_Enabled():
return S_OK()
示例2: OptimizerModule
# 需要导入模块: from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB [as 别名]
# 或者: from DIRAC.WorkloadManagementSystem.DB.JobDB.JobDB import getJobOptParameter [as 别名]
#.........这里部分代码省略.........
def initializeOptimizer( self ):
""" To be overwritten by inheriting class
"""
return S_OK()
#############################################################################
def execute( self ):
""" The main agent execution method
"""
result = self.initializeOptimizer()
if not result[ 'OK' ]:
return result
self._initResult = result[ 'Value' ]
condition = { 'Status' : self.startingMajorStatus }
if self.startingMinorStatus:
condition[ 'MinorStatus' ] = self.startingMinorStatus
result = self.jobDB.selectJobs( condition )
if not result['OK']:
self.log.warn( 'Failed to get a job list from the JobDB' )
return S_ERROR( 'Failed to get a job list from the JobDB' )
if not len( result['Value'] ):
self.log.verbose( 'No pending jobs to process' )
return S_OK( 'No work to do' )
for job in result['Value']:
result = self.getJobDefinition( job )
if not result['OK']:
self.setFailedJob( job, result[ 'Message' ], '' )
continue
jobDef = result[ 'Value' ]
result = self.optimizeJob( job, jobDef[ 'classad' ] )
return S_OK()
#############################################################################
def optimizeJob( self, job, classAdJob ):
""" Call the corresponding Optimizer checkJob method
"""
self.log.info( 'Job %s will be processed by %sAgent' % ( job, self.am_getModuleParam( 'optimizerName' ) ) )
result = self.checkJob( job, classAdJob )
if not result['OK']:
self.setFailedJob( job, result['Message'], classAdJob )
return result
#############################################################################
def getJobDefinition( self, job, jobDef = False ):
""" Retrieve JDL of the Job and return jobDef dictionary
"""
if jobDef == False:
jobDef = {}
#If not jdl in jobinfo load it
if 'jdl' not in jobDef:
if 'jdlOriginal' == self.requiredJobInfo:
result = self.jobDB.getJobJDL( job, original = True )
if not result[ 'OK' ]:
self.log.error( "No JDL for job", "%s" % job )
return S_ERROR( "No JDL for job" )
jobDef[ 'jdl' ] = result[ 'Value' ]
if 'jdl' == self.requiredJobInfo:
result = self.jobDB.getJobJDL( job )
if not result[ 'OK' ]:
self.log.error( "No JDL for job", "%s" % job )
return S_ERROR( "No JDL for job" )
jobDef[ 'jdl' ] = result[ 'Value' ]
#Load the classad if needed
if 'jdl' in jobDef and not 'classad' in jobDef:
try:
classad = ClassAd( jobDef[ 'jdl' ] )
except:
self.log.debug( "Cannot load JDL" )
return S_ERROR( 'Illegal Job JDL' )
if not classad.isOK():
self.log.debug( "Warning: illegal JDL for job %s, will be marked problematic" % ( job ) )
return S_ERROR( 'Illegal Job JDL' )
jobDef[ 'classad' ] = classad
return S_OK( jobDef )
#############################################################################
def getOptimizerJobInfo( self, job, reportName ):
"""This method gets job optimizer information that will
be used for
"""
self.log.verbose( "self.jobDB.getJobOptParameter(%s,'%s')" % ( job, reportName ) )
result = self.jobDB.getJobOptParameter( job, reportName )
if result['OK']:
value = result['Value']
if not value:
self.log.warn( 'JobDB returned null value for %s %s' % ( job, reportName ) )
return S_ERROR( 'No optimizer info returned' )
else:
try:
return S_OK( eval( value ) )
except Exception, x:
return S_ERROR( 'Could not evaluate optimizer parameters' )
return result