def show( repo, targets=None, typ=None, xpath=None, all_branches=False, all_tags=False, recursive=False, revs=None, all_commits=False, ): res = {} found = set() if not targets: # Iterate once to call `_collect_metrics` on all the stages targets = [None] for branch in repo.brancher( revs=revs, all_branches=all_branches, all_tags=all_tags, all_commits=all_commits, ): metrics = {} for target in targets: entries = _collect_metrics(repo, target, recursive, typ, xpath, branch) metric = _read_metrics(repo, entries, branch) if metric: found.add(target) metrics.update(metric) if metrics: res[branch] = metrics if not res and not any(targets): raise NoMetricsError() # Hide working tree metrics if they are the same as in the active branch try: active_branch = repo.scm.active_branch() except TypeError: pass # Detached head else: if res.get("working tree") == res.get(active_branch): res.pop("working tree", None) missing = set(targets) - found if missing: res[None] = missing return res
def show( repo, targets=None, all_branches=False, all_tags=False, recursive=False, revs=None, all_commits=False, ): res = {} metrics_found = False for rev in repo.brancher( revs=revs, all_branches=all_branches, all_tags=all_tags, all_commits=all_commits, ): metrics = _collect_metrics(repo, targets, rev, recursive) if not metrics_found and metrics: metrics_found = True vals = _read_metrics(repo, metrics, rev) if vals: res[rev] = vals if not res: if metrics_found: msg = ( "Could not parse metrics files. Use `-v` option to see more " "details." ) else: msg = ( "no metrics files in this repository. Use `-m/-M` options for " "`dvc run` to mark stage outputs as metrics." ) raise NoMetricsError(msg) # Hide workspace metrics if they are the same as in the active branch try: active_branch = repo.scm.active_branch() except (TypeError, SCMError): # TypeError - detached head # SCMError - no repo case pass else: if res.get("workspace") == res.get(active_branch): res.pop("workspace", None) return res
def show( repo, targets=None, typ=None, xpath=None, all_branches=False, all_tags=False, recursive=False, ): res = {} found = set() if not targets: # Iterate once to call `_collect_metrics` on all the stages targets = [None] for branch in repo.brancher(all_branches=all_branches, all_tags=all_tags): metrics = {} for target in targets: entries = _collect_metrics(repo, target, recursive, typ, xpath, branch) metric = _read_metrics(repo, entries, branch) if metric: found.add(target) metrics.update(metric) if metrics: res[branch] = metrics if not res and not any(targets): raise NoMetricsError() missing = set(targets) - found if missing: res[None] = missing return res
def show( self, path=None, typ=None, xpath=None, all_branches=False, all_tags=False, recursive=False, ): res = {} for branch in self.brancher(all_branches=all_branches, all_tags=all_tags): entries = _collect_metrics(self, path, recursive, typ, xpath, branch) metrics = _read_metrics(self, entries, branch) if metrics: res[branch] = metrics if not res: if path: raise BadMetricError(path) raise NoMetricsError() return res
def show( repo, targets=None, all_branches=False, all_tags=False, recursive=False, revs=None, all_commits=False, ): res = {} for rev in repo.brancher( revs=revs, all_branches=all_branches, all_tags=all_tags, all_commits=all_commits, ): metrics = _collect_metrics(repo, targets, recursive) vals = _read_metrics(repo, metrics, rev) if vals: res[rev] = vals if not res: raise NoMetricsError() # Hide working tree metrics if they are the same as in the active branch try: active_branch = repo.scm.active_branch() except TypeError: pass # Detached head else: if res.get("working tree") == res.get(active_branch): res.pop("working tree", None) return res