本文整理汇总了Python中pandatools.Client.listDatasetsByGUIDs方法的典型用法代码示例。如果您正苦于以下问题:Python Client.listDatasetsByGUIDs方法的具体用法?Python Client.listDatasetsByGUIDs怎么用?Python Client.listDatasetsByGUIDs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandatools.Client
的用法示例。
在下文中一共展示了Client.listDatasetsByGUIDs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_pick_dataset
# 需要导入模块: from pandatools import Client [as 别名]
# 或者: from pandatools.Client import listDatasetsByGUIDs [as 别名]
#.........这里部分代码省略.........
# bulk lookup
nEventsPerLoop = 500
iEventsTotal = 0
while iEventsTotal < len(runEvtList):
tmpRunEvtList = runEvtList[iEventsTotal:iEventsTotal+nEventsPerLoop]
iEventsTotal += nEventsPerLoop
paramStr = 'Run, Evt: %s, Stream: %s, Dataset pattern: %s' % (tmpRunEvtList,self.pick_stream_name, self.pick_dataset_pattern)
logger.debug(paramStr)
logger.info('.')
# check with ELSSI
if self.pick_stream_name == '':
guidListELSSI = elssiIF.doLookup(tmpRunEvtList,tokens=streamRef,amitag=self.event_pick_amitag,extract=True)
else:
guidListELSSI = elssiIF.doLookup(tmpRunEvtList,stream=self.pick_stream_name,tokens=streamRef,amitag=self.event_pick_amitag,extract=True)
if len(guidListELSSI) == 0 or guidListELSSI == None:
errStr = ''
for tmpLine in elssiIF.output:
errStr += tmpLine + '\n'
errStr = "GUID was not found in ELSSI.\n" + errStr
raise ApplicationConfigurationError(errStr)
# check attribute
attrNames, attrVals = guidListELSSI
def getAttributeIndex(attr):
for tmpIdx,tmpAttrName in enumerate(attrNames):
if tmpAttrName.strip() == attr:
return tmpIdx
errStr = "cannot find attribute=%s in %s provided by ELSSI" % (attr,str(attrNames))
raise ApplicationConfigurationError(errStr)
# get index
indexEvt = getAttributeIndex('EventNumber')
indexRun = getAttributeIndex('RunNumber')
indexTag = getAttributeIndex(streamRef)
# check events
for runNr,evtNr in tmpRunEvtList:
paramStr = 'Run:%s Evt:%s Stream:%s' % (runNr,evtNr,self.pick_stream_name)
# collect GUIDs
tmpguids = []
for attrVal in attrVals:
if runNr == attrVal[indexRun] and evtNr == attrVal[indexEvt]:
tmpGuid = attrVal[indexTag]
# check non existing
if tmpGuid == 'NOATTRIB':
continue
if not tmpGuid in tmpguids:
tmpguids.append(tmpGuid)
# not found
if tmpguids == []:
errStr = "no GUIDs were found in ELSSI for %s" % paramStr
raise ApplicationConfigurationError(errStr)
# append
for tmpguid in tmpguids:
if not tmpguid in guids:
guids.append(tmpguid)
guidRunEvtMap[tmpguid] = []
guidRunEvtMap[tmpguid].append((runNr,evtNr))
runEvtGuidMap[(runNr,evtNr)] = tmpguids
# convert to dataset names and LFNs
dsLFNs,allDSMap = Client.listDatasetsByGUIDs(guids,self.pick_dataset_pattern,verbose)
logger.debug(dsLFNs)
#populate DQ2Datase
if job and job.inputdata:
job.inputdata.dataset = []
job.inputdata.names = []
job.inputdata.guids = []
# check duplication
for runNr,evtNr in runEvtGuidMap.keys():
tmpLFNs = []
tmpAllDSs = {}
for tmpguid in runEvtGuidMap[(runNr,evtNr)]:
if tmpguid in dsLFNs:
tmpLFNs.append(dsLFNs[tmpguid])
job.inputdata.guids.append(tmpguid)
job.inputdata.names.append(dsLFNs[tmpguid][1])
if not ((dsLFNs[tmpguid][0]) in job.inputdata.dataset):
job.inputdata.dataset.append(dsLFNs[tmpguid][0])
else:
tmpAllDSs[tmpguid] = allDSMap[tmpguid]
if tmpguid in guidRunEvtMap:
del guidRunEvtMap[tmpguid]
# empty
if tmpLFNs == []:
paramStr = 'Run:%s Evt:%s Stream:%s' % (runNr,evtNr,self.pick_stream_name)
errStr = "Dataset pattern '%s' didn't pick up a file for %s\n" % (self.pick_dataset_pattern,paramStr)
for tmpguid,tmpAllDS in tmpAllDSs.iteritems():
errStr += " GUID:%s dataset:%s\n" % (tmpguid,str(tmpAllDS))
raise ApplicationConfigurationError(errStr)
# duplicated
if len(tmpLFNs) != 1:
paramStr = 'Run:%s Evt:%s Stream:%s' % (runNr,evtNr,self.pick_stream_name)
errStr = "Multiple LFNs %s were found in ELSSI for %s. Please set pick_dataset_pattern and/or pick_stream_name and or event_pick_amitag correctly." %(str(tmpLFNs),paramStr)
raise ApplicationConfigurationError(errStr)
# return
return guidRunEvtMap