mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
dvc.stage: log time duration on stage collection walk in verbose mode
This commit is contained in:
committed by
Ruslan Kuprieiev
parent
46fac33ba5
commit
36d53bd403
@@ -0,0 +1,4 @@
|
||||
/tests
|
||||
/dvc
|
||||
/.github
|
||||
/bin
|
||||
+13
-3
@@ -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/
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user