From b11c6dd8b2d9ca5a7d59db8b630e27801815c48b Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Thu, 30 Jan 2025 12:28:36 -0700 Subject: [PATCH] Store output refs in quantum metadata --- python/lsst/ctrl/mpexec/singleQuantumExecutor.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/python/lsst/ctrl/mpexec/singleQuantumExecutor.py b/python/lsst/ctrl/mpexec/singleQuantumExecutor.py index 26f35a4a..6c33e816 100644 --- a/python/lsst/ctrl/mpexec/singleQuantumExecutor.py +++ b/python/lsst/ctrl/mpexec/singleQuantumExecutor.py @@ -273,9 +273,9 @@ def _execute( task = self.taskFactory.makeTask(task_node, limited_butler, init_input_refs) logInfo(None, "start", metadata=quantumMetadata) # type: ignore[arg-type] try: - quantumMetadata["caveats"] = self.runQuantum( + caveats, outputsPut = self.runQuantum( task, quantum, task_node, limited_butler, quantum_id=quantum_id - ).value + ) except Exception as e: _LOG.error( "Execution of task '%s' on quantum %s failed. Exception %s: %s", @@ -285,6 +285,11 @@ def _execute( str(e), ) raise + else: + quantumMetadata["caveats"] = caveats.value + # Stringify the UUID for easier compatibility with + # PropertyList. + quantumMetadata["outputs"] = [str(ref.id) for ref in outputsPut] logInfo(None, "end", metadata=quantumMetadata) # type: ignore[arg-type] fullMetadata = task.getFullMetadata() fullMetadata["quantum"] = quantumMetadata @@ -483,7 +488,7 @@ def runQuantum( /, limited_butler: LimitedButler, quantum_id: uuid.UUID | None = None, - ) -> QuantumSuccessCaveats: + ) -> tuple[QuantumSuccessCaveats, list[DatasetRef]]: """Execute task on a single quantum. Parameters @@ -503,6 +508,9 @@ def runQuantum( ------- flags : `QuantumSuccessCaveats` Flags that describe qualified successes. + outputsPut : list[ `lsst.daf.butler.DatasetRef` ] + Record of all the datasets that were written by this quantum + being executed. """ flags = QuantumSuccessCaveats.NO_CAVEATS @@ -556,7 +564,7 @@ def runQuantum( flags |= QuantumSuccessCaveats.ALL_OUTPUTS_MISSING if not butlerQC.outputsPut == butlerQC.allOutputs: flags |= QuantumSuccessCaveats.ANY_OUTPUTS_MISSING - return flags + return flags, butlerQC.outputRefsPut def writeMetadata( self, quantum: Quantum, metadata: Any, task_node: TaskNode, /, limited_butler: LimitedButler