mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 23:10:42 +01:00
* 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]>
95 lines
2.5 KiB
Python
95 lines
2.5 KiB
Python
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)
|