26"""This module defines the ButlerLocation class."""
33from .
import iterify, doImport
41 assembler : function object
42 Function object or importable string to a function object that can be called
with the assembler
43 signature: (dataId, componentDict, cls).
44 disassembler : function object
45 Function object
or importable string to a function object that can be called
with the disassembler
46 signature: (object, dataId, componentDict).
49 instantiate an object to be returned.
50 dataId : dict
or DataId
51 The dataId that
is used to look up components.
52 mapper : Mapper instance
53 A reference to the mapper that created this ButlerComposite object.
57 """Information about a butler composite object. Some details come from the policy and some are filled
58 in by the butler. Component info
is used
while assembling
and disassembling a composite object
in
59 butler. It
is used
as an input to assemblers
and disassemblers (which are part of the butler public
65 The datasetType of the component.
67 The python object instance that
is this component.
69 The name of the function
in the parent object to set this component.
70 Optional - may be
None
72 The name of the function
in the parent object to get this component.
73 Optional - may be
None
75 If true, indicates that the obj should be a list of objects found via butlerSubset.
77 If true, indicates that the obj should
not be serialized when performing a butler.put.
79 def __init__(self, datasetType, obj, setter, getter, subset, inputOnly):
88 return 'ComponentInfo(datasetType:%s, obj:%s, setter:%s, getter:%s, subset:%s)' % \
92 return 'ButlerComposite(assembler:%s, disassembler:%s, python:%s, dataId:%s, mapper:%s, ' \
93 'componentInfo:%s, repository:%s)' % \
102 def __init__(self, assembler, disassembler, python, dataId, mapper):
103 self.
assembler = doImport(assembler)
if isinstance(assembler, str)
else assembler
104 self.
disassembler = doImport(disassembler)
if isinstance(disassembler, str)
else disassembler
105 self.
python = doImport(python)
if isinstance(python, str)
else python
111 def add(self, id, datasetType, setter, getter, subset, inputOnly):
112 """Add a description of a component needed to fetch the composite dataset.
117 The name of the component in the policy definition.
119 The name of the datasetType of the component.
120 setter : string
or None
121 The name of the function used to set this component into the python type that contains it.
122 Specifying a setter
is optional, use
None if the setter won
't be specified or used.
123 getter : string or None
124 The name of the function used to get this component
from the python type that contains it.
125 Specifying a setter
is optional, use
None if the setter won
't be specified or used.
127 If true, indicates that the obj should be a list of objects found via butlerSubset.
129 If true, indicates that the obj should not be serialized when performing a butler.put.
149 """ButlerLocation is a struct-like class that holds information needed to
150 persist and retrieve an object using the LSST Persistence Framework.
152 Mappers should create
and return ButlerLocations
from their
153 map_{datasetType} methods.
157 pythonType - string
or class instance
158 This
is the type of python object that should be created when reading the location.
160 cppType - string
or None
161 The type of cpp object represented by the location (optional, may be
None)
164 The type of storage the object
is in or should be place into.
166 locationList - list of string
167 A list of URI to place the object
or where the object might be found. (Typically when reading the
168 length
is expected to be exactly 1).
171 The dataId that was passed
in when mapping the location. This may include keys that were
not used
for
172 mapping this location.
174 mapper - mapper
class instance
175 The mapper object that mapped this location.
177 storage - storage
class instance
178 The storage interface that can be used to read
or write this location.
181 The dataId components that were used to map this location. If the mapper had to look up keys those
182 will be
in this dict (even though they may
not appear
in the dataId parameter). If the dataId
183 parameter contained keys that were
not required to map this item then those keys will NOT be
in this
187 The datasetType that this location represents.
190 Additional metadata to be passed to the persistence framework,
194 yaml_tag = u"!ButlerLocation"
197 yaml_loader = yaml.UnsafeLoader
198 except AttributeError:
199 yaml_loader = yaml.Loader
200 yaml_dumper = yaml.Dumper
204 'ButlerLocation(pythonType=%r, cppType=%r, storageName=%r, storage=%r, locationList=%r,' \
205 ' additionalData=%r, mapper=%r, dataId=%r)' % \
209 def __init__(self, pythonType, cppType, storageName, locationList, dataId, mapper, storage,
210 usedDataId=None, datasetType=None, additionalData=None):
218 for k, v
in dataId.items():
231 """Representer for dumping to YAML
236 return dumper.represent_mapping(ButlerLocation.yaml_tag,
237 {
'pythonType': obj.pythonType,
'cppType': obj.cppType,
238 'storageName': obj.storageName,
239 'locationList': obj.locationList,
'mapper': obj.mapper,
240 'storage': obj.storage,
'dataId': obj.dataId})
244 obj = loader.construct_mapping(node)
Class for storing generic metadata.
def __init__(self, datasetType, obj, setter, getter, subset, inputOnly)
def __init__(self, assembler, disassembler, python, dataId, mapper)
def add(self, id, datasetType, setter, getter, subset, inputOnly)
def setRepository(self, repository)
def from_yaml(loader, node)
def setRepository(self, repository)
def __init__(self, pythonType, cppType, storageName, locationList, dataId, mapper, storage, usedDataId=None, datasetType=None, additionalData=None)
def getLocationsWithRoot(self)
def getAdditionalData(self)
daf::base::PropertySet * set