26 """This module defines the ButlerLocation class.""" 31 from past.builtins
import basestring
34 from .
import iterify, doImport
42 assembler : function object 43 Function object or importable string to a function object that can be called with the assembler 44 signature: (dataId, componentDict, cls). 45 disassembler : function object 46 Function object or importable string to a function object that can be called with the disassembler 47 signature: (object, dataId, componentDict). 49 A python class object or importable string to a class object that can be used by the assembler to 50 instantiate an object to be returned. 51 dataId : dict or DataId 52 The dataId that is used to look up components. 53 mapper : Mapper instance 54 A reference to the mapper that created this ButlerComposite object. 58 """Information about a butler composite object. Some details come from the policy and some are filled 59 in by the butler. Component info is used while assembling and disassembling a composite object in 60 butler. It is used as an input to assemblers and disassemblers (which are part of the butler public 66 The datasetType of the component. 68 The python object instance that is this component. 70 The name of the function in the parent object to set this component. 71 Optional - may be None 73 The name of the function in the parent object to get this component. 74 Optional - may be None 76 If true, indicates that the obj should be a list of objects found via butlerSubset. 78 If true, indicates that the obj should not be serialized when performing a butler.put. 80 def __init__(self, datasetType, obj, setter, getter, subset, inputOnly):
89 return 'ComponentInfo(datasetType:%s, obj:%s, setter:%s, getter:%s, subset:%s)' % \
93 return 'ButlerComposite(assembler:%s, disassembler:%s, python:%s, dataId:%s, mapper:%s, ' \
94 'componentInfo:%s, repository:%s)' % \
103 def __init__(self, assembler, disassembler, python, dataId, mapper):
112 def add(self, id, datasetType, setter, getter, subset, inputOnly):
113 """Add a description of a component needed to fetch the composite dataset. 118 The name of the component in the policy definition. 120 The name of the datasetType of the component. 121 setter : string or None 122 The name of the function used to set this component into the python type that contains it. 123 Specifying a setter is optional, use None if the setter won't be specified or used. 124 getter : string or None 125 The name of the function used to get this component from the python type that contains it. 126 Specifying a setter is optional, use None if the setter won't be specified or used. 128 If true, indicates that the obj should be a list of objects found via butlerSubset. 130 If true, indicates that the obj should not be serialized when performing a butler.put. 150 """ButlerLocation is a struct-like class that holds information needed to 151 persist and retrieve an object using the LSST Persistence Framework. 153 Mappers should create and return ButlerLocations from their 154 map_{datasetType} methods. 158 pythonType - string or class instance 159 This is the type of python object that should be created when reading the location. 161 cppType - string or None 162 The type of cpp object represented by the location (optional, may be None) 165 The type of storage the object is in or should be place into. 167 locationList - list of string 168 A list of URI to place the object or where the object might be found. (Typically when reading the 169 length is expected to be exactly 1). 172 The dataId that was passed in when mapping the location. This may include keys that were not used for 173 mapping this location. 175 mapper - mapper class instance 176 The mapper object that mapped this location. 178 storage - storage class instance 179 The storage interface that can be used to read or write this location. 182 The dataId components that were used to map this location. If the mapper had to look up keys those 183 will be in this dict (even though they may not appear in the dataId parameter). If the dataId 184 parameter contained keys that were not required to map this item then those keys will NOT be in this 188 The datasetType that this location represents. 190 additionalData : `lsst.daf.base.PropertySet`, optional 191 Additional metadata to be passed to the persistence framework, 195 yaml_tag =
u"!ButlerLocation" 198 yaml_loader = yaml.FullLoader
199 except AttributeError:
200 yaml_loader = yaml.Loader
201 yaml_dumper = yaml.Dumper
205 'ButlerLocation(pythonType=%r, cppType=%r, storageName=%r, storage=%r, locationList=%r,' \
206 ' additionalData=%r, mapper=%r, dataId=%r)' % \
210 def __init__(self, pythonType, cppType, storageName, locationList, dataId, mapper, storage,
211 usedDataId=None, datasetType=None, additionalData=None):
213 self.
pythonType =
str(pythonType)
if isinstance(pythonType, basestring)
else pythonType
220 for k, v
in dataId.items():
233 """Representer for dumping to YAML 238 return dumper.represent_mapping(ButlerLocation.yaml_tag,
239 {
'pythonType': obj.pythonType,
'cppType': obj.cppType,
240 'storageName': obj.storageName,
241 'locationList': obj.locationList,
'mapper': obj.mapper,
242 'storage': obj.storage,
'dataId': obj.dataId})
246 obj = loader.construct_mapping(node)
def __init__(self, pythonType, cppType, storageName, locationList, dataId, mapper, storage, usedDataId=None, datasetType=None, additionalData=None)
def getAdditionalData(self)
def __init__(self, datasetType, obj, setter, getter, subset, inputOnly)
def from_yaml(loader, node)
def __init__(self, assembler, disassembler, python, dataId, mapper)
daf::base::PropertySet * set
def setRepository(self, repository)
def getLocationsWithRoot(self)
def add(self, id, datasetType, setter, getter, subset, inputOnly)
def setRepository(self, repository)
Class for storing generic metadata.