def run(self): if self.args.show_vega: if not self.args.targets: logger.error("please specify a target for `--show-vega`") return 1 if len(self.args.targets) > 1: logger.error( "you can only specify one target for `--show-vega`") return 1 try: plots = self._func(targets=self.args.targets, props=self._props()) if self.args.show_vega: target = self.args.targets[0] logger.info(plots[target]) return 0 path = self.args.out or "plots.html" path = os.path.join(os.getcwd(), path) write(path, plots) logger.info(f"file://{path}") except DvcException: logger.exception("") return 1 return 0
def _run(self, target, revs=None): metrics, plots = self.repo.live.show(target=target, revs=revs) html_path = self.args.target + ".html" write(html_path, plots, metrics) logger.info(f"\nfile://{os.path.abspath(html_path)}") return 0
def create_summary(out): from dvc.utils.html import write assert out.live and out.live["html"] metrics, plots = out.repo.live.show(str(out.path_info)) html_path = out.path_info.with_suffix(".html") write(html_path, plots, metrics) logger.info(f"\nfile://{os.path.abspath(html_path)}")
def summary(path: str, revs: List[str] = None): try: root = Repo.find_root() except NotDvcRepoError: root = os.getcwd() metrics, plots = Repo(root_dir=root, uninitialized=True).live.show(path, revs) html_path = path + ".html" write(html_path, plots, metrics) logger.info(f"\nfile://{os.path.abspath(html_path)}")
def write_html( self, path: StrPath, plots: Dict[str, Dict], metrics: Optional[Dict[str, Dict]] = None, html_template_path: Optional[StrPath] = None, ): if not html_template_path: html_template_path = self.repo.config.get("plots", {}).get( "html_template", None) if html_template_path and not os.path.isabs(html_template_path): html_template_path = os.path.join(self.repo.dvc_dir, html_template_path) from dvc.utils.html import write write(path, plots, metrics, html_template_path)
def run(self): from pathlib import Path if self.args.show_vega: if not self.args.targets: logger.error("please specify a target for `--show-vega`") return 1 if len(self.args.targets) > 1: logger.error( "you can only specify one target for `--show-vega`" ) return 1 try: plots = self._func(targets=self.args.targets, props=self._props()) if self.args.show_vega: target = self.args.targets[0] logger.info(plots[target]) return 0 rel: str = self.args.out or "plots.html" path = (Path.cwd() / rel).resolve() write(path, plots) except DvcException: logger.exception("") return 1 assert path.is_absolute() # as_uri throws ValueError if not absolute url = path.as_uri() logger.info(url) if self.args.open: import webbrowser opened = webbrowser.open(rel) if not opened: logger.error("Failed to open. Please try opening it manually.") return 1 return 0