CLI: redirect warnings to logger (#3591)

* 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]>
This commit is contained in:
Ivan Shcheklein
2020-04-04 22:18:14 +03:00
committed by GitHub
co-authored by Ruslan Kuprieiev
parent 7bd473371c
commit 7b1dbd6109
3 changed files with 1 additions and 10 deletions
-9
View File
@@ -3,17 +3,8 @@ DVC
----
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
View File
@@ -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."):
-1
View File
@@ -33,7 +33,6 @@ def main(argv=None):
int: command's return code.
"""
args = None
cmd = None
disable_other_loggers()
outerLogLevel = logger.level