-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* plots: allow dir plots * first scenario * separate dvclive tests * rename index to step * another test * refactor * its ok to have step in data * sort plots * introduce --logs * add logs to run commands * variable name refactoring * fix logs option * fixup * cmd: run: fix unit tests * plots: modify: fix tests * improve dir handling * fixup * dvclive: logs summary * api: introduce logs summarization method * handle no repo case * fix granular dir plots * api: dvclive: simplify * dvclive: roll back logs flag * cmd: introduce logs * api: adjust to logs * test: dvclive fix * rename logs to dvclive * live: command: add uninitialized * outs: dvclive type * dvclive: support providing config via evn variables * dvclive: treat as metrics * dvclive integration: add support for summary on/off * dvc integration: add temporary test for configuration export * remove requirements * cmd: introduce logs * rename logs to dvclive * cmd: introduce logs * remove logs leftowvers * dvclive: env: adjust to chekpoints env variables * command: live: remove unnecessary help * fix linter suggestions * type hinting * review refactor * replace dvclive with live * stage: loading: move live loading to separate method * stage: serialize: allow only single live output * live: add show/diff * stage: serialize: roll back single live enforcing * fixup * rebase fixups * output: live: force single instance * live: command: add unit tests * Update dvc/output/base.py Co-authored-by: Ruslan Kuprieiev <[email protected]> * Update dvc/stage/__init__.py Co-authored-by: Ruslan Kuprieiev <[email protected]> * Update dvc/stage/serialize.py Co-authored-by: Ruslan Kuprieiev <[email protected]> * review v2 * live: fix summary tracking by experiments * naming fixups * api: live: add tests * tests: api: separate live tests Co-authored-by: Ruslan Kuprieiev <[email protected]>
- Loading branch information
Showing
36 changed files
with
810 additions
and
89 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import logging | ||
import os | ||
from typing import List | ||
|
||
from dvc.exceptions import NotDvcRepoError | ||
from dvc.repo import Repo | ||
from dvc.utils.html import write | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
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)}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import argparse | ||
import logging | ||
import os | ||
|
||
from dvc.command import completion | ||
from dvc.command.base import CmdBase, fix_subparsers | ||
from dvc.utils.html import write | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CmdLive(CmdBase): | ||
UNINITIALIZED = True | ||
|
||
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 | ||
|
||
|
||
class CmdLiveShow(CmdLive): | ||
def run(self): | ||
return self._run(self.args.target) | ||
|
||
|
||
class CmdLiveDiff(CmdLive): | ||
def run(self): | ||
return self._run(self.args.target, self.args.revs) | ||
|
||
|
||
def shared_parent_parser(): | ||
parent_parser = argparse.ArgumentParser(add_help=False) | ||
parent_parser.add_argument( | ||
"target", help="Logs dir to produce summary from", | ||
).complete = completion.DIR | ||
parent_parser.add_argument( | ||
"-o", | ||
"--out", | ||
default=None, | ||
help="Destination path to save plots to", | ||
metavar="<path>", | ||
).complete = completion.DIR | ||
return parent_parser | ||
|
||
|
||
def add_parser(subparsers, parent_parser): | ||
LIVE_DESCRIPTION = ( | ||
"Commands to visualize and compare dvclive-produced logs." | ||
) | ||
live_parser = subparsers.add_parser( | ||
"live", | ||
parents=[parent_parser], | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
description=LIVE_DESCRIPTION, | ||
) | ||
live_subparsers = live_parser.add_subparsers( | ||
dest="cmd", | ||
help="Use `dvc live CMD --help` to display command-specific help.", | ||
) | ||
|
||
fix_subparsers(live_subparsers) | ||
|
||
SHOW_HELP = "Visualize dvclive directory content." | ||
live_show_parser = live_subparsers.add_parser( | ||
"show", | ||
parents=[parent_parser, shared_parent_parser()], | ||
help=SHOW_HELP, | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
live_show_parser.set_defaults(func=CmdLiveShow) | ||
|
||
DIFF_HELP = ( | ||
"Show multiple versions of dvclive data, " | ||
"by plotting it in single view." | ||
) | ||
live_diff_parser = live_subparsers.add_parser( | ||
"diff", | ||
parents=[parent_parser, shared_parent_parser()], | ||
help=DIFF_HELP, | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
live_diff_parser.add_argument( | ||
"--revs", | ||
nargs="*", | ||
default=None, | ||
help="Git revision (e.g. SHA, branch, tag)", | ||
metavar="<commit>", | ||
) | ||
live_diff_parser.set_defaults(func=CmdLiveDiff) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,28 +7,10 @@ | |
from dvc.exceptions import DvcException | ||
from dvc.schema import PLOT_PROPS | ||
from dvc.utils import format_link | ||
from dvc.utils.html import write | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
PAGE_HTML = """<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>DVC Plot</title> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
</head> | ||
<body> | ||
{divs} | ||
</body> | ||
</html>""" | ||
|
||
DIV_HTML = """<div id = "{id}"></div> | ||
<script type = "text/javascript"> | ||
var spec = {vega_json}; | ||
vegaEmbed('#{id}', spec); | ||
</script>""" | ||
|
||
|
||
class CmdPlots(CmdBase): | ||
def _func(self, *args, **kwargs): | ||
|
@@ -58,16 +40,10 @@ def run(self): | |
logger.info(plots[target]) | ||
return 0 | ||
|
||
divs = [ | ||
DIV_HTML.format(id=f"plot{i}", vega_json=plot) | ||
for i, plot in enumerate(plots.values()) | ||
] | ||
html = PAGE_HTML.format(divs="\n".join(divs)) | ||
path = self.args.out or "plots.html" | ||
|
||
path = os.path.join(os.getcwd(), path) | ||
with open(path, "w") as fobj: | ||
fobj.write(html) | ||
|
||
write(path, plots) | ||
|
||
logger.info(f"file://{path}") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.