本文整理汇总了Python中DIRAC.RequestManagementSystem.Client.ReqClient.ReqClient.getRequestInfo方法的典型用法代码示例。如果您正苦于以下问题:Python ReqClient.getRequestInfo方法的具体用法?Python ReqClient.getRequestInfo怎么用?Python ReqClient.getRequestInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.RequestManagementSystem.Client.ReqClient.ReqClient
的用法示例。
在下文中一共展示了ReqClient.getRequestInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RequestTasks
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.ReqClient import ReqClient [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.ReqClient.ReqClient import getRequestInfo [as 别名]
#.........这里部分代码省略.........
""" Submit requests one by one
"""
submitted = 0
failed = 0
startTime = time.time()
for taskID in sorted( taskDict ):
if not taskDict[taskID]['TaskObject']:
taskDict[taskID]['Success'] = False
failed += 1
continue
res = self.submitTaskToExternal( taskDict[taskID]['TaskObject'] )
if res['OK']:
taskDict[taskID]['ExternalID'] = res['Value']
taskDict[taskID]['Success'] = True
submitted += 1
else:
self.log.error( "Failed to submit task to RMS", res['Message'] )
taskDict[taskID]['Success'] = False
failed += 1
self.log.info( 'submitTasks: Submitted %d tasks to RMS in %.1f seconds' % ( submitted, time.time() - startTime ) )
if failed:
self.log.info( 'submitTasks: Failed to submit %d tasks to RMS.' % ( failed ) )
return S_OK( taskDict )
def submitTaskToExternal( self, oRequest ):
""" Submits a request using ReqClient
"""
if isinstance( oRequest, self.requestClass ):
return self.requestClient.putRequest( oRequest )
else:
return S_ERROR( "Request should be a Request object" )
def updateTransformationReservedTasks( self, taskDicts ):
taskNameIDs = {}
noTasks = []
for taskDict in taskDicts:
transID = taskDict['TransformationID']
taskID = taskDict['TaskID']
taskName = str( transID ).zfill( 8 ) + '_' + str( taskID ).zfill( 8 )
res = self.requestClient.getRequestInfo( taskName )
if res['OK']:
taskNameIDs[taskName] = res['Value'][0]
elif re.search( "Failed to retrieve RequestID for Request", res['Message'] ):
noTasks.append( taskName )
else:
self.log.warn( "Failed to get requestID for request", res['Message'] )
return S_OK( {'NoTasks':noTasks, 'TaskNameIDs':taskNameIDs} )
def getSubmittedTaskStatus( self, taskDicts ):
updateDict = {}
for taskDict in taskDicts:
transID = taskDict['TransformationID']
taskID = taskDict['TaskID']
oldStatus = taskDict['ExternalStatus']
taskName = str( transID ).zfill( 8 ) + '_' + str( taskID ).zfill( 8 )
res = self.requestClient.getRequestStatus( taskName )
newStatus = ''
if res['OK']:
# FIXME: for compatibility between old and new RMS
try:
# old
newStatus = res['Value']['RequestStatus']
except TypeError:
# new
newStatus = res['Value']
elif re.search( "Failed to retrieve RequestID for Request", res['Message'] ):
newStatus = 'Failed'
else:
self.log.info( "getSubmittedTaskStatus: Failed to get requestID for request", res['Message'] )
if newStatus and ( newStatus != oldStatus ):
if newStatus not in updateDict:
updateDict[newStatus] = []
updateDict[newStatus].append( taskID )
return S_OK( updateDict )
def getSubmittedFileStatus( self, fileDicts ):
taskFiles = {}
for fileDict in fileDicts:
transID = fileDict['TransformationID']
taskID = fileDict['TaskID']
taskName = str( transID ).zfill( 8 ) + '_' + str( taskID ).zfill( 8 )
if taskName not in taskFiles:
taskFiles[taskName] = {}
taskFiles[taskName][fileDict['LFN']] = fileDict['Status']
updateDict = {}
for taskName in sorted( taskFiles ):
lfnDict = taskFiles[taskName]
res = self.requestClient.getRequestFileStatus( taskName, lfnDict.keys() )
if not res['OK']:
self.log.warn( "getSubmittedFileStatus: Failed to get files status for request", res['Message'] )
continue
for lfn, newStatus in res['Value'].items():
if newStatus == lfnDict[lfn]:
pass
elif newStatus == 'Done':
updateDict[lfn] = 'Processed'
elif newStatus == 'Failed':
updateDict[lfn] = 'Problematic'
return S_OK( updateDict )
示例2: RequestTasks
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.ReqClient import ReqClient [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.ReqClient.ReqClient import getRequestInfo [as 别名]
#.........这里部分代码省略.........
return S_OK( taskDict )
def submitTaskToExternal( self, oRequest ):
""" Submits a request using ReqClient
"""
if isinstance( oRequest, self.requestClass ):
return self.requestClient.putRequest( oRequest )
else:
return S_ERROR( "Request should be a Request object" )
def updateTransformationReservedTasks( self, taskDicts ):
requestNameIDs = {}
noTasks = []
for taskDict in taskDicts:
requestName = _requestName( taskDict['TransformationID'], taskDict['TaskID'] )
# FIXME: trying to see if it is in the old system
reqID = self.__getRequestIDOLDSystem( requestName )
# FIXME: and in the new, if it is not in the previous one
if not reqID:
reqID = self.__getRequestID( requestName )
if reqID:
requestNameIDs[requestName] = reqID
else:
noTasks.append( requestName )
return S_OK( {'NoTasks':noTasks, 'TaskNameIDs':requestNameIDs} )
def __getRequestIDOLDSystem( self, requestName ):
""" for the OLD RMS
"""
# FIXME: this should disappear
try:
res = RequestClient().getRequestInfo( requestName )
if res['OK']:
return res['Value'][0]
else:
return 0
except RuntimeError:
return 0
def __getRequestID( self, requestName ):
""" Getting the info from the new RMS
"""
# FIXME: this should stay
res = self.requestClient.getRequestInfo( requestName )
if res['OK']:
return res['Value'][0]
else:
return 0
def getSubmittedTaskStatus( self, taskDicts ):
updateDict = {}
for taskDict in taskDicts:
transID = taskDict['TransformationID']
taskID = taskDict['TaskID']
oldStatus = taskDict['ExternalStatus']
requestName = _requestName( transID, taskID )
# FIXME: trying to see if it is in the old system
newStatus = self.__getRequestStatusOLDSystem( requestName )
# FIXME: and in the new, if it is not in the previous one
if not newStatus['OK']:
newStatus = self.__getRequestStatus( requestName )