def _collect_paths( repo: "Repo", targets: Iterable[str], recursive: bool = False, rev: str = None, ) -> StrPaths: from dvc.fs.repo import RepoFileSystem from dvc.utils import relpath fs_paths = [os.path.abspath(target) for target in targets] fs = RepoFileSystem(repo=repo) target_paths: StrPaths = [] for fs_path in fs_paths: if recursive and fs.isdir(fs_path): target_paths.extend(fs.find(fs_path)) rel = relpath(fs_path) if not fs.exists(fs_path): if rev == "workspace" or rev == "": logger.warning("'%s' was not found in current workspace.", rel) else: logger.warning("'%s' was not found at: '%s'.", rel, rev) target_paths.append(fs_path) return target_paths
def _collect_from_revision( self, targets: Optional[List[str]] = None, revision: Optional[str] = None, recursive: bool = False, onerror: Optional[Callable] = None, props: Optional[Dict] = None, ): from dvc.fs.repo import RepoFileSystem fs = RepoFileSystem(self.repo) plots = _collect_plots(self.repo, targets, revision, recursive) res: Dict[str, Any] = {} for fs_path, rev_props in plots.items(): if fs.isdir(fs_path): plot_files = [] for pi in fs.find(fs_path): plot_files.append((pi, relpath(pi, self.repo.root_dir))) else: plot_files = [(fs_path, relpath(fs_path, self.repo.root_dir))] props = props or {} for path, repo_path in plot_files: joined_props = {**rev_props, **props} res[repo_path] = {"props": joined_props} res[repo_path].update({ "data_source": partial( parse, fs, path, props=joined_props, onerror=onerror, ) }) return res