Skip to content

Commit

Permalink
stage: hide unwanted warnings (iterative#3763)
Browse files Browse the repository at this point in the history
These messages all correpond to expected behaviour, so there is no need
to polute the output with unnecessary warnings.
  • Loading branch information
efiop authored May 8, 2020
1 parent fc42ca7 commit 2a16b02
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 25 deletions.
4 changes: 1 addition & 3 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import logging
import os
from contextlib import contextmanager
from functools import wraps
Expand Down Expand Up @@ -435,8 +434,7 @@ def _collect_stages(self):
for file_name in filter(is_valid_filename, files):
path = os.path.join(root, file_name)
stage_loader = Dvcfile(self, path).stages
with stage_loader.log_level(at=logging.DEBUG):
stages.extend(stage_loader.values())
stages.extend(stage_loader.values())
outs.update(
out.fspath
for stage in stages
Expand Down
6 changes: 3 additions & 3 deletions dvc/stage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ def _changed_outs(self):
def stage_changed(self, warn=False):
changed = self.md5 != self._compute_md5()
if changed and warn:
logger.warning("DVC-file '{}' changed.".format(self.relpath))
logger.debug("DVC-file '{}' changed.".format(self.relpath))
return changed

@rwlocked(read=["deps", "outs"])
def changed(self):
if self._changed():
logger.warning("{} changed.".format(self))
logger.debug("{} changed.".format(self))
return True

logger.debug("{} didn't change.".format(self))
Expand Down Expand Up @@ -831,5 +831,5 @@ def stage_status(self):

def stage_changed(self, warn=False):
if self.cmd_changed and warn:
logger.warning("'cmd' of {} has changed.".format(self))
logger.debug("'cmd' of {} has changed.".format(self))
return self.cmd_changed
21 changes: 2 additions & 19 deletions dvc/stage/loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import os
from collections import Mapping, defaultdict
from contextlib import contextmanager
from copy import deepcopy
from itertools import chain

Expand Down Expand Up @@ -30,14 +29,6 @@ def __init__(self, dvcfile, stages_data, lockfile_data=None):
self.dvcfile = dvcfile
self.stages_data = stages_data or {}
self.lockfile_data = lockfile_data or {}
self._log_level = logging.WARNING

@contextmanager
def log_level(self, at):
"""Change log_level temporarily for StageLoader."""
self._log_level, level = at, self._log_level
yield
self._log_level = level

def filter(self, item=None):
if not item:
Expand Down Expand Up @@ -154,11 +145,8 @@ def __getitem__(self, name):
raise StageNotFound(self.dvcfile, name)

if not self.lockfile_data.get(name):
logger.log(
self._log_level,
"No lock entry found for '%s:%s'",
self.dvcfile.relpath,
name,
logger.debug(
"No lock entry found for '%s:%s'", self.dvcfile.relpath, name,
)

return self.load_stage(
Expand Down Expand Up @@ -187,11 +175,6 @@ def __init__(self, dvcfile, stage_data, stage_text=None):
def filter(self, item=None):
return self

@contextmanager
def log_level(self, *args, **kwargs):
"""No-op context manager."""
yield

def __getitem__(self, item):
if item:
logger.warning(
Expand Down

0 comments on commit 2a16b02

Please sign in to comment.