22 """Retrieve collections of metadata or data based on a set of data references 24 Use this as a base task for creating graphs and reports for a set of data. 29 __all__ = [
"DataRefListRunner",
"GetRepositoryDataTask"]
33 """A task runner that calls run with a list of data references 35 Differs from the default TaskRunner by providing all data references at once, 36 instead of iterating over them one at a time. 40 """Return a list of targets (arguments for __call__); one entry per invocation 42 return [parsedCmd.id.refList]
45 """Run GetRepositoryDataTask.run on a single target 47 @param dataRefList: argument dict for run; contains one key: dataRefList 50 - None if doReturnResults false 51 - A pipe_base Struct containing these fields if doReturnResults true: 52 - dataRefList: the argument dict sent to runDataRef 53 - metadata: task metadata after execution of runDataRef 54 - result: result returned by task runDataRef 56 task = self.TaskClass(config=self.config, log=self.log)
57 result = task.runDataRef(dataRefList)
59 if self.doReturnResults:
60 return pipeBase.Struct(
61 dataRefList=dataRefList,
62 metadata=task.metadata,
68 """Retrieve data from a repository, e.g. for plotting or analysis purposes 70 ConfigClass = pexConfig.Config
71 RunnerClass = DataRefListRunner
72 _DefaultName =
"getTaskData" 75 pipeBase.CmdLineTask.__init__(self, *args, **kwargs)
79 """Get data from a repository for a collection of data references 81 @param dataRefList: a list of data references 83 raise NotImplementedError(
"subclass must specify a run method")
86 """Get a list of data IDs in a form that can be used as dictionary keys 88 @param dataRefList: a list of data references 89 @return a pipe_base Struct with fields: 90 - idKeyTuple: a tuple of dataRef data ID keys 91 - idValList: a list of data ID value tuples, each tuple contains values in the order in idKeyTuple 94 raise RuntimeError(
"No data refs")
95 idKeyTuple = tuple(sorted(dataRefList[0].dataId.keys()))
98 for dataRef
in dataRefList:
99 idValTuple = tuple(dataRef.dataId[key]
for key
in idKeyTuple)
100 idValList.append(idValTuple)
102 return pipeBase.Struct(
103 idKeyTuple=idKeyTuple,
108 """Retrieve a list of data 110 @param dataRefList: a list of data references 111 @param datasetType: datasetType of data to be retrieved 112 @return a list of data, one entry per dataRef in dataRefList (in order) 114 return [dataRef.get(datasetType=datasetType)
for dataRef
in dataRefList]
117 """Retrieve a list of dictionaries of metadata 119 @param dataRefList: a list of data references 120 @param datasetType: datasetType of metadata (or any object that supports get(name)) 121 @return a list of dicts of metadata: 122 - each entry in the list corresponds to a dataRef in dataRefList 123 - each dict contains name: item of metadata, for each name in nameList; 124 numeric and string values will be returned as arrays 127 for dataRef
in dataRefList:
128 metadata = dataRef.get(datasetType=datasetType)
129 valList.append(dict((name, metadata.getArray(name))
for name
in nameList))
def getMetadataItems(self, dataRefList, datasetType, nameList)
def runDataRef(self, dataRefList)
def __init__(self, args, kwargs)
def getIdList(self, dataRefList)
def getTargetList(parsedCmd)
def __call__(self, dataRefList)
def getDataList(self, dataRefList, datasetType)