StorageClass

class lsst.daf.butler.StorageClass(name: Optional[str] = None, pytype: Union[Type[CT_co], str, None] = None, components: Optional[Dict[str, lsst.daf.butler.core.storageClass.StorageClass]] = None, readComponents: Optional[Dict[str, lsst.daf.butler.core.storageClass.StorageClass]] = None, parameters: Union[Sequence[T_co], Set[T], None] = None, assembler: Optional[str] = None)

Bases: object

Class describing how a label maps to a particular Python type.

Parameters:
name : str

Name to use for this class.

pytype : type or str

Python type (or name of type) to associate with the StorageClass

components : dict, optional

dict mapping name of a component to another StorageClass.

readComponents : dict, optional

dict mapping name of a read-only component to another StorageClass.

parameters : Sequence or Set

Parameters understood by this StorageClass that can control reading of data from datastores.

assembler : str, optional

Fully qualified name of class supporting assembly and disassembly of a pytype instance.

Attributes Summary

assemblerClass Class to use to (dis)assemble an object from components.
components Component names mapped to associated StorageClass
defaultAssemblerName
parameters set of names of parameters supported by this StorageClass
pytype Python type associated with this StorageClass.
readComponents Read-only component names mapped to associated StorageClass

Methods Summary

allComponents() Return a mapping of all the read and read/write components to the corresponding storage class.
assembler() Return an instance of an assembler.
filterParameters(parameters, Any], subset) Filter out parameters that are not known to this StorageClass
isComposite() Boolean indicating whether this StorageClass is a composite or not.
knownParameters() Return set of all parameters known to this StorageClass
validateInstance(instance) Check that the supplied Python object has the expected Python type
validateParameters(parameters) Check that the parameters are known to this StorageClass

Attributes Documentation

assemblerClass

Class to use to (dis)assemble an object from components.

components

Component names mapped to associated StorageClass

defaultAssemblerName = 'lsst.daf.butler.core.assembler.CompositeAssembler'
parameters

set of names of parameters supported by this StorageClass

pytype

Python type associated with this StorageClass.

readComponents

Read-only component names mapped to associated StorageClass

Methods Documentation

allComponents() → Mapping[str, lsst.daf.butler.core.storageClass.StorageClass]

Return a mapping of all the read and read/write components to the corresponding storage class.

Returns:
comp : dict of [str, StorageClass]

The component name to storage class mapping.

assembler() → lsst.daf.butler.core.assembler.CompositeAssembler

Return an instance of an assembler.

Returns:
assembler : CompositeAssembler

Instance of the assembler associated with this StorageClass. Assembler is constructed with this StorageClass.

Raises:
TypeError

This StorageClass has no associated assembler.

filterParameters(parameters: Dict[str, Any], subset: Optional[Collection[T_co]] = None) → Dict[str, Any]

Filter out parameters that are not known to this StorageClass

Parameters:
parameters : dict, optional

Candidate parameters. Can be None if no parameters have been provided.

subset : Collection, optional

Subset of supported parameters that the caller is interested in using. The subset must be known to the StorageClass if specified. If None the supplied parameters will all be checked, else only the keys in this set will be checked.

Returns:
filtered : dict

Valid parameters. Empty dict if none are suitable.

Raises:
ValueError

Raised if the provided subset is not a subset of the supported parameters or if it is an empty set.

isComposite() → bool

Boolean indicating whether this StorageClass is a composite or not.

Returns:
isComposite : bool

True if this StorageClass is a composite, False otherwise.

knownParameters() → Set[str]

Return set of all parameters known to this StorageClass

The set includes parameters understood by components of a composite.

Returns:
known : set

All parameter keys of this StorageClass and the component storage classes.

validateInstance(instance: Any) → bool

Check that the supplied Python object has the expected Python type

Parameters:
instance : object

Object to check.

Returns:
isOk : bool

True if the supplied instance object can be handled by this StorageClass, False otherwise.

validateParameters(parameters: Optional[Collection[T_co]] = None) → None

Check that the parameters are known to this StorageClass

Does not check the values.

Parameters:
parameters : Collection, optional

Collection containing the parameters. Can be dict-like or set-like. The parameter values are not checked. If no parameters are supplied, always returns without error.

Raises:
KeyError

Some parameters are not understood by this StorageClass.