22 """Module defining connection types to be used within a
23 `PipelineTaskConnections` class.
26 __all__ = [
"InitInput",
"InitOutput",
"Input",
"PrerequisiteInput",
27 "Output",
"BaseConnection"]
31 from typing
import Callable, Iterable, Optional
33 from lsst.daf.butler
import (
38 ExpandedDataCoordinate,
43 @dataclasses.dataclass(frozen=
True)
45 """Base class used for declaring PipelineTask connections
50 The name used to identify the dataset type
52 The storage class used when (un)/persisting the dataset type
54 Indicates if this connection should expect to contain multiple objects
55 of the given dataset type
60 multiple: bool =
False
65 This is a method used to turn a connection into a descriptor.
66 When a connection is added to a connection class, it is a class level
67 variable. This method makes accessing this connection, on the
68 instance of the connection class owning this connection, return a
69 result specialized for that instance. In the case of connections
70 this specifically means names specified in a config instance will
71 be visible instead of the default names for the connection.
79 if not hasattr(inst,
'_connectionCache'):
80 object.__setattr__(inst,
'_connectionCache', {})
83 if idSelf
in inst._connectionCache:
84 return inst._connectionCache[idSelf]
87 for field
in dataclasses.fields(self):
88 params[field.name] = getattr(self, field.name)
90 params[
'name'] = inst._nameOverrides[self.varName]
93 return inst._connectionCache.setdefault(idSelf, self.__class__(**params))
96 @dataclasses.dataclass(frozen=
True)
98 """Class used for declaring PipelineTask connections that includes
104 The name used to identify the dataset type
106 The storage class used when (un)/persisting the dataset type
108 Indicates if this connection should expect to contain multiple objects
109 of the given dataset type
110 dimensions : iterable of `str`
111 The `lsst.daf.butler.Butler` `lsst.daf.butler.Registry` dimensions used
112 to identify the dataset type identified by the specified name
114 dimensions: typing.Iterable[str] = ()
117 """Construct a true `DatasetType` instance with normalized dimensions.
120 universe : `lsst.daf.butler.DimensionUniverse`
121 Set of all known dimensions to be used to normalize the dimension
122 names specified in config.
125 datasetType : `DatasetType`
126 The `DatasetType` defined by this connection.
128 return DatasetType(self.name,
129 universe.extract(self.dimensions),
133 @dataclasses.dataclass(frozen=
True)
135 """Class used for declaring PipelineTask input connections
140 The default name used to identify the dataset type
142 The storage class used when (un)/persisting the dataset type
144 Indicates if this connection should expect to contain multiple objects
145 of the given dataset type
146 dimensions : iterable of `str`
147 The `lsst.daf.butler.Butler` `lsst.daf.butler.Registry` dimensions used
148 to identify the dataset type identified by the specified name
150 Indicates that this dataset type will be loaded as a
151 `lsst.daf.butler.DeferredDatasetHandle`. PipelineTasks can use this
152 object to load the object at a later time.
154 deferLoad: bool =
False
157 @dataclasses.dataclass(frozen=
True)
162 @dataclasses.dataclass(frozen=
True)
164 """Class used for declaring PipelineTask prerequisite connections
169 The default name used to identify the dataset type
171 The storage class used when (un)/persisting the dataset type
173 Indicates if this connection should expect to contain multiple objects
174 of the given dataset type
175 dimensions : iterable of `str`
176 The `lsst.daf.butler.Butler` `lsst.daf.butler.Registry` dimensions used
177 to identify the dataset type identified by the specified name
179 Indicates that this dataset type will be loaded as a
180 `lsst.daf.butler.DeferredDatasetHandle`. PipelineTasks can use this
181 object to load the object at a later time.
182 lookupFunction: `typing.Callable`, optional
183 An optional callable function that will look up PrerequisiteInputs
184 using the DatasetType, registry, quantum dataId, and input collections
185 passed to it. If no function is specified, the default temporal spatial
188 lookupFunction: Optional[Callable[[DatasetType, Registry, ExpandedDataCoordinate, CollectionSearch],
189 Iterable[DatasetRef]]] =
None
192 @dataclasses.dataclass(frozen=
True)
197 @dataclasses.dataclass(frozen=
True)
202 @dataclasses.dataclass(frozen=
True)