2828
2929import dataclasses
3030import typing
31- from typing import Callable , Iterable , Optional
31+ from typing import Callable , ClassVar , Iterable , Optional
3232
3333from lsst .daf .butler import (
3434 CollectionSearch ,
@@ -194,6 +194,12 @@ class BaseInput(DimensionedConnection):
194194 """
195195 deferLoad : bool = False
196196
197+ optional : ClassVar [bool ] = False
198+ """Quanta are not generated and never (fully) executed when there are no
199+ datasets for a non-optional input connection, and most input connections
200+ cannot be made optional.
201+ """
202+
197203
198204@dataclasses .dataclass (frozen = True )
199205class Input (BaseInput ):
@@ -225,6 +231,12 @@ class PrerequisiteInput(BaseInput):
225231 using the DatasetType, registry, quantum dataId, and input collections
226232 passed to it. If no function is specified, the default temporal spatial
227233 lookup will be used.
234+ optional : `bool`, optional
235+ If `True` (`False` is default), generate quanta for this task even
236+ when no input datasets for this connection exist. Missing optional
237+ inputs will cause `ButlerQuantumContext.get` to return `None` or a
238+ smaller container (never a same-size container with some `None`
239+ elements) during execution.
228240
229241 Notes
230242 -----
@@ -249,10 +261,12 @@ class PrerequisiteInput(BaseInput):
249261 between dimensions are not desired (e.g. a task that wants all detectors
250262 in each visit for which the visit overlaps a tract, not just those where
251263 that detector+visit combination overlaps the tract).
264+ - Prerequisite inputs may be optional (regular inputs are never optional).
252265
253266 """
254267 lookupFunction : Optional [Callable [[DatasetType , Registry , DataCoordinate , CollectionSearch ],
255268 Iterable [DatasetRef ]]] = None
269+ optional : bool = False
256270
257271
258272@dataclasses .dataclass (frozen = True )
0 commit comments