def render(data, revs=None, props=None, templates=None): """Renders plots""" props = props or {} # Merge data by plot file and apply overriding props plots = _prepare_plots(data, revs, props) result = {} for datafile, desc in plots.items(): try: result[datafile] = _render( datafile, desc["data"], desc["props"], templates ) except PlotParsingError as e: logger.debug( "failed to read '%s' on '%s'", e.path, e.revision, exc_info=True, ) if not any(result.values()): raise NoMetricsParsedError("plots") return result
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: raise NoMetricsParsedError("metrics") elif targets: raise MetricDoesNotExistError(targets) else: raise NoMetricsFoundError("metrics", "-m/-M") # 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