Skip to content

Commit

Permalink
Merge pull request #29 from lucmos/feature/logging
Browse files Browse the repository at this point in the history
Overwrite Lightning logging configuration
  • Loading branch information
Flegyas committed Jan 13, 2022
2 parents 39af6db + 1871afb commit 926284f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 12 additions & 0 deletions src/nn_template/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

from nn_core.console_logging import NNRichHandler

# Required workaround because PyTorch Lightning configures the logging on import,
# thus the logging configuration defined in the __init__.py must be called before
# the lightning import otherwise it has no effect.
# See https://github.com/PyTorchLightning/pytorch-lightning/issues/1503
#
# Force the execution of __init__.py if this file is executed directly.
lightning_logger = logging.getLogger("pytorch_lightning")
# Remove all handlers associated with the lightning logger.
for handler in lightning_logger.handlers[:]:
lightning_logger.removeHandler(handler)
lightning_logger.propagate = True

FORMAT = "%(message)s"
logging.basicConfig(
format=FORMAT,
Expand Down
9 changes: 0 additions & 9 deletions src/nn_template/run.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# Required workaround because PyTorch Lightning configures the logging on import,
# thus the logging configuration defined in the __init__.py must be called before
# the lightning import otherwise it has no effect.
# See https://github.com/PyTorchLightning/pytorch-lightning/issues/1503
#
# Force the execution of __init__.py if this file is executed directly.
import nn_template # isort:skip # noqa

import logging
from operator import xor
from typing import List, Optional, Tuple
Expand All @@ -23,7 +15,6 @@

pylogger = logging.getLogger(__name__)


RESUME_MODES = {
"continue": {
"restore_model": True,
Expand Down

0 comments on commit 926284f

Please sign in to comment.