Skip to content

Cleanup debug log messages when loading stages #5125

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

Merged
merged 3 commits into from
Dec 18, 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
5 changes: 0 additions & 5 deletions dvc/parsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ def resolve_stage(self, skip_checks=False):
definition = deepcopy(self.definition)

wdir = self._resolve_wdir(context, name, definition.get(WDIR_KWD))
if self.wdir != wdir:
logger.debug(
"Stage %s has different wdir than dvc.yaml file", name
)

vars_ = definition.pop(VARS_KWD, [])
# FIXME: Should `vars` be templatized?
check_interpolations(vars_, f"{self.where}.{name}.vars", self.relpath)
Expand Down
5 changes: 1 addition & 4 deletions dvc/stage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,7 @@ def changed_deps(self):

if self.is_callback:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole callback logic can be deleted now, it has been obsoleted since 1.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How so? The callback is still present on the outputs during run/repro, so let's remove it later at the same time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a checkbox #4841 . Sure, can do that separately, just saying.

logger.debug(
'%s is a "callback" stage '
"(has a command and no dependencies) and thus always "
"considered as changed.",
self,
"%s has a command but no dependencies", self.addressing
)
return True

Expand Down
23 changes: 19 additions & 4 deletions dvc/stage/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from copy import deepcopy
from itertools import chain

from funcy import cached_property, get_in, lcat, project
from funcy import cached_property, get_in, lcat, once, project

from dvc import dependency, output
from dvc.hash_info import HashInfo
Expand All @@ -24,13 +24,19 @@ def __init__(self, dvcfile, data, lockfile_data=None):
self.data = data or {}
self.stages_data = self.data.get("stages", {})
self.repo = self.dvcfile.repo
self.lockfile_data = lockfile_data or {}
self._lockfile_data = lockfile_data or {}

@cached_property
def resolver(self):
wdir = PathInfo(self.dvcfile.path).parent
return DataResolver(self.repo, wdir, self.data)

@cached_property
def lockfile_data(self):
if not self._lockfile_data:
logger.debug("Lockfile for '%s' not found", self.dvcfile.relpath)
return self._lockfile_data

@staticmethod
def fill_from_lock(stage, lock_data=None):
"""Fill values for params, checksums for outs and deps from lock."""
Expand Down Expand Up @@ -88,6 +94,14 @@ def load_stage(cls, dvcfile, name, stage_data, lock_data=None):
cls.fill_from_lock(stage, lock_data)
return stage

@once
def lockfile_needs_update(self):
# if lockfile does not have all of the entries that dvc.yaml says it
# should have, provide a debug message once
# pylint: disable=protected-access
lockfile = self.dvcfile._lockfile.relpath
logger.debug("Lockfile '%s' needs to be updated.", lockfile)

def __getitem__(self, name):
if not name:
raise StageNameUnspecified(self.dvcfile)
Expand All @@ -97,8 +111,9 @@ def __getitem__(self, name):
except EntryNotFound:
raise StageNotFound(self.dvcfile, name)

if not self.lockfile_data.get(name):
logger.debug(
if self.lockfile_data and name not in self.lockfile_data:
self.lockfile_needs_update()
logger.trace( # type: ignore[attr-defined]
"No lock entry found for '%s:%s'", self.dvcfile.relpath, name,
)

Expand Down