Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stage: hide unwanted warnings #3763

Merged
merged 1 commit into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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