dvc.stage: log time duration on stage collection walk in verbose mode

This commit is contained in:
Saugat Pachhai (सौगात)
2022-04-27 18:04:14 +03:00
committed by Ruslan Kuprieiev
parent 46fac33ba5
commit 36d53bd403
4 changed files with 38 additions and 9 deletions
+4
View File
@@ -0,0 +1,4 @@
/tests
/dvc
/.github
/bin
+13 -3
View File
@@ -1,10 +1,13 @@
__pycache__/
neatlynx.conf
neatlynx/__pycache__
.idea
/cache
*.pyc
.env/
.env2.7/
.env*/
.venv
env/
venv/
.python-version
.dvc.conf.lock
@@ -26,6 +29,7 @@ innosetup/config.ini
.coverage
.coverage.*
coverage.xml
*.sw?
@@ -40,3 +44,9 @@ scripts/ci/gcp-creds.json
*~
/dvc/_dvc_version.py
.mypy_cache/
.pytest_cache/
.nox/
.tox/
htmlcov/
+5
View File
@@ -298,10 +298,15 @@ class Index:
if __name__ == "__main__":
import logging
from funcy import log_durations
from dvc.logger import setup
from dvc.repo import Repo
setup(level=logging.TRACE) # type: ignore[attr-defined]
repo = Repo()
index = Index(repo, repo.fs)
print(index)
+16 -6
View File
@@ -1,6 +1,7 @@
import fnmatch
import logging
import os
import time
import typing
from contextlib import suppress
from functools import partial, wraps
@@ -15,6 +16,8 @@ from typing import (
Union,
)
from funcy.debug import format_time
from dvc.exceptions import (
DvcException,
NoOutputOrStageError,
@@ -36,6 +39,14 @@ if typing.TYPE_CHECKING:
PIPELINE_FILE = "dvc.yaml"
def log_walk(seq):
for root, dirs, files in seq:
start = time.perf_counter()
yield root, dirs, files
duration = format_time(time.perf_counter() - start)
logger.trace("%s in collecting stages from %s", duration, root)
class StageInfo(NamedTuple):
stage: "Stage"
filter_info: Optional[str] = None
@@ -470,12 +481,11 @@ class StageLoad:
# trailing slash needed to check if a directory is gitignored
return dir_path in outs or is_ignored(f"{dir_path}{sep}")
for root, dirs, files in self.repo.dvcignore.walk(
self.fs, self.repo.root_dir
):
logger.trace( # type: ignore[attr-defined]
"Collect repo walking '%s'", root
)
walk_iter = self.repo.dvcignore.walk(self.fs, self.repo.root_dir)
if logger.isEnabledFor(logging.TRACE): # type: ignore[attr-defined]
walk_iter = log_walk(walk_iter)
for root, dirs, files in walk_iter:
dvcfile_filter = partial(is_dvcfile_and_not_ignored, root)
for file in filter(dvcfile_filter, files):
file_path = os.path.join(root, file)