Skip to content

Commit

Permalink
CLI: redirect warnings to logger (iterative#3591)
Browse files Browse the repository at this point in the history
* redirect warnings module messages to logger to silent them in gdrive

* minor cleanup: remove unused var assignment

* dvc: don't ignore warnings manually

We use logger.captureWarnings() instead for CLI and for API this is harmful.

Co-authored-by: Ruslan Kuprieiev <[email protected]>
  • Loading branch information
shcheklein and efiop authored Apr 4, 2020
1 parent 7bd4733 commit 7b1dbd6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 10 deletions.
9 changes: 0 additions & 9 deletions dvc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,8 @@
----
Make your data science projects reproducible and shareable.
"""
import warnings

import dvc.logger
from dvc.version import __version__ # noqa: F401


dvc.logger.setup()

# Ignore numpy's runtime warnings: https://github.com/numpy/numpy/pull/432.
# We don't directly import numpy, but our dependency networkx does, causing
# these warnings in some environments. Luckily these warnings are benign and
# we can simply ignore them so that they don't show up when you are using dvc.
warnings.filterwarnings("ignore", message="numpy.dtype size changed")
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
1 change: 1 addition & 0 deletions dvc/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def _stack_trace(exc_info):


def disable_other_loggers():
logging.captureWarnings(True)
root = logging.root
for (logger_name, logger) in root.manager.loggerDict.items():
if logger_name != "dvc" and not logger_name.startswith("dvc."):
Expand Down
1 change: 0 additions & 1 deletion dvc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def main(argv=None):
int: command's return code.
"""
args = None
cmd = None
disable_other_loggers()

outerLogLevel = logger.level
Expand Down

0 comments on commit 7b1dbd6

Please sign in to comment.