From 08579a3481b55e5482493378da176057f717796d Mon Sep 17 00:00:00 2001 From: John Parejko Date: Tue, 19 Mar 2024 11:25:10 -0700 Subject: [PATCH] Allow None in butler put arguments This allows "optional" outputs in failure states. --- python/lsst/pipe/base/_quantumContext.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/lsst/pipe/base/_quantumContext.py b/python/lsst/pipe/base/_quantumContext.py index 306d4fb26..48280f937 100644 --- a/python/lsst/pipe/base/_quantumContext.py +++ b/python/lsst/pipe/base/_quantumContext.py @@ -348,7 +348,8 @@ def put( ``[calexp1, calexp2]``. Like wise if there is a single ref, then only a single object need be passed. The same restriction applies if dataset is directly a `list` of `~lsst.daf.butler.DatasetRef` - or a single `~lsst.daf.butler.DatasetRef`. + or a single `~lsst.daf.butler.DatasetRef`. If ``values.NAME`` is + None, no output is written. dataset : `OutputQuantizedConnection` or `list`[`DatasetRef`] \ or `DatasetRef` This argument may either be an `InputQuantizedConnection` which @@ -371,7 +372,9 @@ def put( " attributes must be passed as the values to put" ) for name, refs in dataset: - valuesAttribute = getattr(values, name) + valuesAttribute = getattr(values, name, None) + if valuesAttribute is None: + continue if isinstance(refs, list | tuple): if len(refs) != len(valuesAttribute): raise ValueError(f"There must be a object to put for every Dataset ref in {name}")