mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
Move Repo.collect and collect_granular to Repo.stage (#4993)
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user