Skip to content

Commit e2a2d1a

Browse files
committed
Allow prerequisite inputs to be optional, but assume they are required.
1 parent 4f1c9e1 commit e2a2d1a

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

python/lsst/pipe/base/connectionTypes.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import dataclasses
3030
import typing
31-
from typing import Callable, Iterable, Optional
31+
from typing import Callable, ClassVar, Iterable, Optional
3232

3333
from 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)
199205
class 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

Comments
 (0)