mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
logger: type-safe logger.trace (#10083)
* use logger.getChild from `dvc.log` instead of `logging.getLogger` I got tired adding `# type: ignore[attr-defined]` while using `logger.trace`. So, now you need to import logger from `from dvc.log import logger` and create a child logger using `logger.getChild(__name__)`. `logger.getChild` will return a logger type-hinted as a logger having a `trace` method. So, from now on, instead of: ```python import logging logger = logging.getogger(__name__) ``` you'll have to do following: ```python from dvc.log import logger logger = logger.getChild(__name__) ``` * remove all dvc imports from dvc.logger * use Tqdm back
This commit is contained in:
@@ -7,8 +7,7 @@ from dvc.cli import main
|
||||
from dvc.dvcfile import PROJECT_FILE
|
||||
from dvc.exceptions import OverlappingOutputPathsError
|
||||
from dvc.repo import Repo
|
||||
from dvc.repo.plots import PlotMetricTypeError
|
||||
from dvc.utils import onerror_collect
|
||||
from dvc.repo.plots import PlotMetricTypeError, onerror_collect
|
||||
from dvc.utils.fs import remove
|
||||
from dvc.utils.serialize import EncodingError, YAMLFileCorruptedError, modify_yaml
|
||||
from tests.utils.plots import get_plot
|
||||
|
||||
@@ -4,7 +4,7 @@ import re
|
||||
import subprocess
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from contextlib import contextmanager
|
||||
from contextlib import contextmanager, suppress
|
||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
@@ -108,7 +108,8 @@ def test_analytics(tmp_path, server):
|
||||
assert match, "no match for the pid"
|
||||
pid = int(match.group(1).strip())
|
||||
|
||||
psutil.Process(pid).wait(timeout=10)
|
||||
with suppress(psutil.NoSuchProcess):
|
||||
psutil.Process(pid).wait(timeout=10)
|
||||
assert not os.path.exists(report_file)
|
||||
assert f"Process {pid} exiting with 0" in logfile.read_text(encoding="utf8")
|
||||
assert server.RequestHandlerClass.hits == {"POST": 1}
|
||||
@@ -138,7 +139,8 @@ def test_updater(tmp_dir, dvc, server):
|
||||
assert match, "no match for the pid"
|
||||
pid = int(match.group(1).strip())
|
||||
|
||||
psutil.Process(pid).wait(timeout=10)
|
||||
with suppress(psutil.NoSuchProcess):
|
||||
psutil.Process(pid).wait(timeout=10)
|
||||
assert f"Process {pid} exiting with 0" in logfile.read_text(encoding="utf8")
|
||||
assert server.RequestHandlerClass.hits == {"GET": 1}
|
||||
# check that the file is saved correctly
|
||||
|
||||
Reference in New Issue
Block a user