Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-26739: Add task label to long log message #83

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 10 additions & 14 deletions python/lsst/ctrl/mpexec/singleQuantumExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def __init__(self, taskFactory, skipExisting=False, clobberPartialOutputs=False,

def execute(self, taskDef, quantum, butler):
# Docstring inherited from QuantumExecutor.execute
self.setupLogging(taskDef, quantum)
taskClass, config = taskDef.taskClass, taskDef.config
self.setupLogging(taskClass, config, quantum)

# check whether to skip or delete old outputs
if self.checkExistingOutputs(quantum, butler, taskDef):
Expand All @@ -98,29 +98,25 @@ def execute(self, taskDef, quantum, butler):
task = self.makeTask(taskClass, config, butler)
self.runQuantum(task, quantum, taskDef, butler)

def setupLogging(self, taskClass, config, quantum):
def setupLogging(self, taskDef, quantum):
"""Configure logging system for execution of this task.

Ths method can setup logging to attach task- or
quantum-specific information to log messages. Potentially this can
take into accout some info from task configuration as well.
take into account some info from task configuration as well.

Parameters
----------
taskClass : `type`
Sub-class of `~lsst.pipe.base.PipelineTask`.
config : `~lsst.pipe.base.PipelineTaskConfig`
Configuration object for this task
taskDef : `lsst.pipe.base.TaskDef`
The task definition.
quantum : `~lsst.daf.butler.Quantum`
Single Quantum instance.
"""
# include input dataIds into MDC
dataIds = set(ref.dataId for ref in chain.from_iterable(quantum.inputs.values()))
if dataIds:
if len(dataIds) == 1:
Log.MDC("LABEL", str(dataIds.pop()))
else:
Log.MDC("LABEL", '[' + ', '.join([str(dataId) for dataId in dataIds]) + ']')
# include quantum dataId and task label into MDC
label = taskDef.label
if quantum.dataId:
label += f":{quantum.dataId}"
Log.MDC("LABEL", label)

def checkExistingOutputs(self, quantum, butler, taskDef):
"""Decide whether this quantum needs to be executed.
Expand Down