CompositeAssembler¶
-
class
lsst.daf.butler.
CompositeAssembler
(storageClass)¶ Bases:
object
Class for providing assembler and disassembler support for composites.
- Parameters
- storageClass
StorageClass
StorageClass
to be used with this assembler.
- storageClass
- Attributes
- storageClass
StorageClass
- storageClass
Methods Summary
assemble
(components[, pytype])Construct an object from components based on storageClass.
disassemble
(composite[, subset, override])Generic implementation of a disassembler.
getComponent
(composite, componentName)Attempt to retrieve component from composite object by heuristic.
getValidComponents
(composite)Extract all non-None components from a composite.
handleParameters
(inMemoryDataset[, parameters])Modify the in-memory dataset using the supplied parameters, returning a possibly new object.
Methods Documentation
-
assemble
(components, pytype=None)¶ Construct an object from components based on storageClass.
This generic implementation assumes that instances of objects can be created either by passing all the components to a constructor or by calling setter methods with the name.
- Parameters
- components
dict
Collection of components from which to assemble a new composite object. Keys correspond to composite names in the
StorageClass
.- pytype
type
, optional Override the type from the
CompositeAssembler.storageClass
to use when assembling the final object.
- components
- Returns
- composite
object
New composite object assembled from components.
- composite
- Raises
- ValueError
Some components could not be used to create the object or, alternatively, some components were not defined in the associated StorageClass.
-
disassemble
(composite, subset=None, override=None)¶ Generic implementation of a disassembler.
This implementation attempts to extract components from the parent by looking for attributes of the same name or getter methods derived from the component name.
- Parameters
- composite
object
Parent composite object consisting of components to be extracted.
- subsetiterable, optional
Iterable containing subset of components to extract from composite. Must be a subset of those defined in
CompositeAssembler.storageClass
.- override
object
, optional Object to use for disassembly instead of parent. This can be useful when called from subclasses that have composites in a hierarchy.
- composite
- Returns
- components
dict
dict
with keys matching the components defined inCompositeAssembler.storageClass
and values beingDatasetComponent
instances describing the component. Returns None if this is not a compositeCompositeAssembler.storageClass
.
- components
- Raises
- ValueError
A requested component can not be found in the parent using generic lookups.
- TypeError
The parent object does not match the supplied
CompositeAssembler.storageClass
.
-
getComponent
(composite, componentName)¶ Attempt to retrieve component from composite object by heuristic.
Will attempt a direct attribute retrieval, or else getter methods of the form “get_componentName” and “getComponentName”.
-
getValidComponents
(composite)¶ Extract all non-None components from a composite.
-
handleParameters
(inMemoryDataset, parameters=None)¶ Modify the in-memory dataset using the supplied parameters, returning a possibly new object.
For safety, if any parameters are given to this method an exception will be raised. This is to protect the user from thinking that parameters have been applied when they have not been applied.
- Parameters
- inMemoryDataset
object
Object to modify based on the parameters.
- parameters
dict
Parameters to apply. Values are specific to the parameter. Supported parameters are defined in the associated
StorageClass
. If no relevant parameters are specified the inMemoryDataset will be return unchanged.
- inMemoryDataset
- Returns
- inMemoryDataset
object
Updated form of supplied in-memory dataset, after parameters have been used.
- inMemoryDataset
- Raises
- ValueError
Parameters have been provided to this default implementation.