Move Repo.collect and collect_granular to Repo.stage (#4993)

This commit is contained in:
Saugat Pachhai
2020-11-30 14:28:16 +05:45
committed by GitHub
parent 56322d0a53
commit bc1d10532a
14 changed files with 718 additions and 596 deletions
-31
View File
@@ -1,7 +1,6 @@
import os
import pytest
from funcy import raiser
from dvc.repo import NotDvcRepoError, Repo, locked
from dvc.utils.fs import remove
@@ -73,36 +72,6 @@ def test_locked(mocker):
]
def test_collect_optimization(tmp_dir, dvc, mocker):
(stage,) = tmp_dir.dvc_gen("foo", "foo text")
# Forget cached stages and graph and error out on collection
dvc._reset()
mocker.patch(
"dvc.repo.Repo.stages",
property(raiser(Exception("Should not collect"))),
)
# Should read stage directly instead of collecting the whole graph
dvc.collect(stage.path)
dvc.collect_granular(stage.path)
def test_collect_optimization_on_stage_name(tmp_dir, dvc, mocker, run_copy):
tmp_dir.dvc_gen("foo", "foo")
stage = run_copy("foo", "bar", name="copy-foo-bar")
# Forget cached stages and graph and error out on collection
dvc._reset()
mocker.patch(
"dvc.repo.Repo.stages",
property(raiser(Exception("Should not collect"))),
)
# Should read stage directly instead of collecting the whole graph
assert dvc.collect("copy-foo-bar") == [stage]
assert dvc.collect_granular("copy-foo-bar") == [(stage, None)]
def test_skip_graph_checks(tmp_dir, dvc, mocker, run_copy):
# See https://github.com/iterative/dvc/issues/2671 for more info
mock_build_graph = mocker.patch("dvc.repo.build_graph")