mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-01 23:08:43 +01:00
plots diff: use exp switch_repo context instead of brancher
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
8cb2646023
commit
96449f157c
+33
-26
@@ -121,51 +121,58 @@ class Plots:
|
||||
|
||||
}
|
||||
"""
|
||||
from dvc.repo.experiments.brancher import switch_repo
|
||||
from dvc.utils.collections import ensure_list
|
||||
|
||||
targets = ensure_list(targets)
|
||||
targets = [self.repo.dvcfs.from_os_path(target) for target in targets]
|
||||
|
||||
for rev in self.repo.brancher(revs=revs):
|
||||
# .brancher() adds unwanted workspace
|
||||
if revs is not None and rev not in revs:
|
||||
continue
|
||||
rev = rev or "workspace"
|
||||
|
||||
res: Dict = {}
|
||||
definitions = _collect_definitions(
|
||||
self.repo,
|
||||
targets=targets,
|
||||
revision=rev,
|
||||
onerror=onerror,
|
||||
props=props,
|
||||
)
|
||||
if definitions:
|
||||
res[rev] = {"definitions": definitions}
|
||||
|
||||
data_targets = _get_data_targets(definitions)
|
||||
|
||||
res[rev]["sources"] = self._collect_data_sources(
|
||||
targets=data_targets,
|
||||
recursive=recursive,
|
||||
props=props,
|
||||
if revs is None:
|
||||
revs = ["workspace"]
|
||||
else:
|
||||
revs = list(revs)
|
||||
if "workspace" in revs:
|
||||
# reorder revs to match repo.brancher ordering
|
||||
revs.remove("workspace")
|
||||
revs = ["workspace"] + revs
|
||||
for rev in revs:
|
||||
with switch_repo(self.repo, rev) as (repo, _):
|
||||
res: Dict = {}
|
||||
definitions = _collect_definitions(
|
||||
repo,
|
||||
targets=targets,
|
||||
revision=rev,
|
||||
onerror=onerror,
|
||||
props=props,
|
||||
)
|
||||
yield res
|
||||
if definitions:
|
||||
res[rev] = {"definitions": definitions}
|
||||
|
||||
data_targets = _get_data_targets(definitions)
|
||||
|
||||
res[rev]["sources"] = self._collect_data_sources(
|
||||
repo,
|
||||
targets=data_targets,
|
||||
recursive=recursive,
|
||||
props=props,
|
||||
onerror=onerror,
|
||||
)
|
||||
yield res
|
||||
|
||||
@error_handler
|
||||
def _collect_data_sources(
|
||||
self,
|
||||
repo: "Repo",
|
||||
targets: Optional[List[str]] = None,
|
||||
recursive: bool = False,
|
||||
props: Optional[Dict] = None,
|
||||
onerror: Optional[Callable] = None,
|
||||
):
|
||||
fs = self.repo.dvcfs
|
||||
fs = repo.dvcfs
|
||||
|
||||
props = props or {}
|
||||
|
||||
plots = _collect_plots(self.repo, targets, recursive)
|
||||
plots = _collect_plots(repo, targets, recursive)
|
||||
res: Dict[str, Any] = {}
|
||||
for fs_path, rev_props in plots.items():
|
||||
joined_props = {**rev_props, **props}
|
||||
|
||||
Reference in New Issue
Block a user