Skip to content

Commit

Permalink
Allow prerequisite inputs to be optional, but assume they are required.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed May 20, 2021
1 parent 4f1c9e1 commit e2a2d1a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion python/lsst/pipe/base/connectionTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import dataclasses
import typing
from typing import Callable, Iterable, Optional
from typing import Callable, ClassVar, Iterable, Optional

from lsst.daf.butler import (
CollectionSearch,
Expand Down Expand Up @@ -194,6 +194,12 @@ class BaseInput(DimensionedConnection):
"""
deferLoad: bool = False

optional: ClassVar[bool] = False
"""Quanta are not generated and never (fully) executed when there are no
datasets for a non-optional input connection, and most input connections
cannot be made optional.
"""


@dataclasses.dataclass(frozen=True)
class Input(BaseInput):
Expand Down Expand Up @@ -225,6 +231,12 @@ class PrerequisiteInput(BaseInput):
using the DatasetType, registry, quantum dataId, and input collections
passed to it. If no function is specified, the default temporal spatial
lookup will be used.
optional : `bool`, optional
If `True` (`False` is default), generate quanta for this task even
when no input datasets for this connection exist. Missing optional
inputs will cause `ButlerQuantumContext.get` to return `None` or a
smaller container (never a same-size container with some `None`
elements) during execution.
Notes
-----
Expand All @@ -249,10 +261,12 @@ class PrerequisiteInput(BaseInput):
between dimensions are not desired (e.g. a task that wants all detectors
in each visit for which the visit overlaps a tract, not just those where
that detector+visit combination overlaps the tract).
- Prerequisite inputs may be optional (regular inputs are never optional).
"""
lookupFunction: Optional[Callable[[DatasetType, Registry, DataCoordinate, CollectionSearch],
Iterable[DatasetRef]]] = None
optional: bool = False


@dataclasses.dataclass(frozen=True)
Expand Down

0 comments on commit e2a2d1a

Please sign in to comment.