Skip to content

Commit

Permalink
Use Butler.put instead of Butler.putDirect
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Mar 29, 2023
1 parent 4855990 commit dd39aa6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
4 changes: 3 additions & 1 deletion python/lsst/pipe/base/butlerQuantumContext.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ def _put(self, value: Any, ref: DatasetRef) -> None:
self._checkMembership(ref, self.allOutputs)
if self.__full_butler is not None:
# If reference is resolved we need to unresolved it first.
# It is possible that we are putting a dataset into a different
# run than what was originally expected.
if ref.id is not None:
ref = ref.unresolved()
self.__full_butler.put(value, ref)
else:
self.__butler.putDirect(value, ref)
self.__butler.put(value, ref)

def get(
self,
Expand Down
13 changes: 3 additions & 10 deletions tests/test_pipelineTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,11 @@ def get(self, ref: DatasetRef) -> Any:
return None

def put(self, inMemoryDataset: Any, dsRef: DatasetRef, producer: Any = None):
# put requires unresolved ref
assert dsRef.id is None
key = dsRef.dataId
name = dsRef.datasetType.name
dsdata = self.datasets.setdefault(name, {})
dsdata[key] = inMemoryDataset

def putDirect(self, obj: Any, ref: DatasetRef):
# putDirect requires resolved ref
assert ref.id is not None
self.put(obj, ref.unresolved())


class AddConnections(pipeBase.PipelineTaskConnections, dimensions=["instrument", "visit"]):
input = pipeBase.connectionTypes.Input(
Expand Down Expand Up @@ -182,7 +175,7 @@ def _testRunQuantum(self, full_butler: bool) -> None:
dstype0 = connections.input.makeDatasetType(butler.registry.dimensions)
for i, quantum in enumerate(quanta):
ref = quantum.inputs[dstype0.name][0]
butler.putDirect(100 + i, ref)
butler.put(100 + i, ref)

# run task on each quanta
checked_get = False
Expand Down Expand Up @@ -265,7 +258,7 @@ def _testChain2(self, full_butler: bool) -> None:
dstype0 = task1Connections.input.makeDatasetType(butler.registry.dimensions)
for i, quantum in enumerate(quanta1):
ref = quantum.inputs[dstype0.name][0]
butler.putDirect(100 + i, ref)
butler.put(100 + i, ref)

butler_qc_factory = (
pipeBase.ButlerQuantumContext.from_full
Expand Down Expand Up @@ -313,7 +306,7 @@ def testButlerQC(self):
# add input data to butler
dstype0 = connections.input.makeDatasetType(butler.registry.dimensions)
ref = quantum.inputs[dstype0.name][0]
butler.putDirect(100, ref)
butler.put(100, ref)

butlerQC = pipeBase.ButlerQuantumContext.from_full(butler, quantum)

Expand Down

0 comments on commit dd39aa6

Please sign in to comment.