def show(self, targets=None, revs=None, props=None): from .data import NoMetricInHistoryError data = self.collect(targets, revs) # If any mentioned plot doesn't have any data then that's an error targets = [targets] if isinstance(targets, str) else targets or [] for target in targets: if not any("data" in d[target] for d in data.values()): raise NoMetricInHistoryError(target) # No data at all is a special error with a special message if not data: raise NoPlotsError() return self.render(data, revs, props, self.repo.plot_templates)
def show(repo, targets=None, revs=None, props=None) -> dict: if isinstance(targets, str): targets = [targets] if props is None: props = {} # Collect plot data files with associated props plots = {} for rev in repo.brancher(revs=revs): if revs is not None and rev not in revs: continue for datafile, file_props in _collect_plots(repo, targets).items(): # props from command line overwrite plot props from out definition full_props = {**file_props, **props} if datafile in plots: saved_rev, saved_props = plots[datafile] if saved_props != props: logger.warning( f"Inconsistent plot props for '{datafile}' in " f"'{saved_rev}' and '{rev}'. " f"Going to use ones from '{saved_rev}'") else: plots[datafile] = rev, full_props if not plots: if targets: raise NoMetricInHistoryError(", ".join(targets)) try: datafile, plot = _show(repo, datafile=None, revs=revs, props=props) except NoDataOrTemplateProvided: raise NoPlotsError() return {datafile: plot} return { datafile: _show(repo, datafile=datafile, revs=revs, props=props)[1] for datafile, (_, props) in plots.items() }