Skip to content

Commit

Permalink
Merge pull request #143 from lsst/tickets/DM-31801
Browse files Browse the repository at this point in the history
DM-31801: Use lsst prefix for loggers
  • Loading branch information
timj committed Nov 10, 2021
2 parents 18e3935 + 5fc0913 commit 4bcc444
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
22 changes: 18 additions & 4 deletions python/lsst/ap/verify/ap_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import argparse
import re
import warnings
import sys
import logging

import lsst.log

Expand All @@ -41,6 +43,18 @@
from .pipeline_driver import ApPipeParser, runApPipeGen2, runApPipeGen3
from .workspace import WorkspaceGen2, WorkspaceGen3

_LOG = logging.getLogger(__name__)


def _configure_logger():
"""Configure Python logging.
Does basic Python logging configuration and
forwards LSST logger to Python logging.
"""
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
lsst.log.configure_pylog_MDC("DEBUG", MDC_class=None)


class _InputOutputParser(argparse.ArgumentParser):
"""An argument parser for program-wide input and output.
Expand Down Expand Up @@ -187,8 +201,8 @@ def runApVerify(cmdLine=None):
The number of data IDs that were not successfully processed, up to 127,
or 127 if the task runner framework failed.
"""
lsst.log.configure()
log = lsst.log.Log.getLogger('ap.verify.ap_verify.main')
_configure_logger()
log = _LOG.getChild('main')
# TODO: what is LSST's policy on exceptions escaping into main()?
args = _ApVerifyParser().parse_args(args=cmdLine)
log.debug('Command-line arguments: %s', args)
Expand Down Expand Up @@ -244,8 +258,8 @@ def runIngestion(cmdLine=None):
an optional command line used to execute `runIngestion` from other
Python code. If `None`, `sys.argv` will be used.
"""
lsst.log.configure()
log = lsst.log.Log.getLogger('ap.verify.ap_verify.ingest')
_configure_logger()
log = _LOG.getChild('ingest')
# TODO: what is LSST's policy on exceptions escaping into main()?
args = _IngestOnlyParser().parse_args(args=cmdLine)
log.debug('Command-line arguments: %s', args)
Expand Down
8 changes: 5 additions & 3 deletions python/lsst/ap/verify/ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import tarfile
from glob import glob
import sqlite3
import logging

import lsst.utils
import lsst.log
import lsst.pex.config as pexConfig
import lsst.pipe.base as pipeBase

Expand All @@ -48,6 +48,8 @@
from lsst.pipe.tasks.ingestCalibs import IngestCalibsTask
from lsst.pipe.tasks.ingestCuratedCalibs import IngestCuratedCalibsTask

_LOG = logging.getLogger(__name__)


class DatasetIngestConfig(pexConfig.Config):
"""Settings and defaults for `DatasetIngestTask`.
Expand Down Expand Up @@ -615,7 +617,7 @@ def ingestDataset(dataset, workspace):
``obs`` package).
"""
# TODO: generalize to support arbitrary URIs (DM-11482)
log = lsst.log.Log.getLogger("ap.verify.ingestion.ingestDataset")
log = _LOG.getChild("ingestDataset")

ingester = DatasetIngestTask(config=_getConfig(DatasetIngestTask, dataset))
ingester.run(dataset, workspace)
Expand All @@ -637,7 +639,7 @@ def ingestDatasetGen3(dataset, workspace, processes=1):
processes : `int`
The number processes to use to ingest.
"""
log = lsst.log.Log.getLogger("ap.verify.ingestion.ingestDataset")
log = _LOG.getChild("ingestDataset")

ingester = Gen3DatasetIngestTask(dataset, workspace, config=_getConfig(Gen3DatasetIngestTask, dataset))
ingester.run(processes=processes)
Expand Down
8 changes: 5 additions & 3 deletions python/lsst/ap/verify/pipeline_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@
import os
import re
import subprocess
import logging

import lsst.log
import lsst.pipe.base as pipeBase
import lsst.ctrl.mpexec.execFixupDataId # not part of lsst.ctrl.mpexec
import lsst.ctrl.mpexec.cli.pipetask
import lsst.ap.pipe as apPipe
from lsst.ap.pipe.make_apdb import makeApdb

_LOG = logging.getLogger(__name__)


class ApPipeParser(argparse.ArgumentParser):
"""An argument parser for data needed by ``ap_pipe`` activities.
Expand Down Expand Up @@ -105,7 +107,7 @@ def runApPipeGen2(workspace, parsedCmdLine, processes=1):
``doReturnResults=False``. This object is valid even if
`~lsst.ap.pipe.ApPipeTask` was never run.
"""
log = lsst.log.Log.getLogger('ap.verify.pipeline_driver.runApPipeGen2')
log = _LOG.getChild('runApPipeGen2')

makeApdb(_getApdbArguments(workspace, parsedCmdLine))

Expand Down Expand Up @@ -158,7 +160,7 @@ def runApPipeGen3(workspace, parsedCmdLine, processes=1):
nonzero if there were errors. The exact meaning of nonzereo values
is an implementation detail.
"""
log = lsst.log.Log.getLogger('ap.verify.pipeline_driver.runApPipeGen3')
log = _LOG.getChild('runApPipeGen3')

makeApdb(_getApdbArguments(workspace, parsedCmdLine))

Expand Down

0 comments on commit 4bcc444

Please sign in to comment.