Skip to content

Commit

Permalink
Improve DuplicateOutputError log message
Browse files Browse the repository at this point in the history
  • Loading branch information
leeskelvin committed Mar 3, 2023
1 parent 45d22ff commit 071a31e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/changes/DM-38234.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`DuplicateOutputError` logger now produces a more helpful error message.
8 changes: 7 additions & 1 deletion python/lsst/pipe/base/pipeTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,20 @@ def orderPipeline(pipeline: List[TaskDef]) -> List[TaskDef]:
outputs = {} # maps task index to its output DatasetType names
allInputs = set() # all inputs of all tasks
allOutputs = set() # all outputs of all tasks
dsTypeTaskLabels = {} # maps DatasetType name to the label of its parent task
for idx, taskDef in enumerate(pipeline):
# task outputs
dsMap = {name: getattr(taskDef.connections, name) for name in taskDef.connections.outputs}
for dsTypeDescr in dsMap.values():
if dsTypeDescr.name in allOutputs:
raise DuplicateOutputError(
"DatasetType `{}' appears more than once as output".format(dsTypeDescr.name)
"DatasetType `{}' in task `{}' already appears as an output in task `{}'.".format(
dsTypeDescr.name,
taskDef.label,
dsTypeTaskLabels[dsTypeDescr.name],
)
)
dsTypeTaskLabels[dsTypeDescr.name] = taskDef.label
outputs[idx] = set(dsTypeDescr.name for dsTypeDescr in dsMap.values())
allOutputs.update(outputs[idx])

Expand Down

0 comments on commit 071a31e

Please sign in to comment.