Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 1 addition & 47 deletions dvc/command/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,6 @@ def run(self):
return 0


class CmdMetricsAdd(CmdBase):
def run(self):
try:
self.repo.metrics.add(self.args.path)
except DvcException:
msg = f"failed to add metric file '{self.args.path}'"
logger.exception(msg)
return 1

return 0


class CmdMetricsRemove(CmdBase):
def run(self):
try:
self.repo.metrics.remove(self.args.path)
except DvcException:
msg = f"failed to remove metric file '{self.args.path}'"
logger.exception(msg)
return 1

return 0


def _show_diff(diff, markdown=False, no_path=False, old=False):
from collections import OrderedDict

Expand Down Expand Up @@ -145,7 +121,7 @@ def run(self):


def add_parser(subparsers, parent_parser):
METRICS_HELP = "Commands to add, manage, collect, and display metrics."
METRICS_HELP = "Commands to display and compare metrics."

metrics_parser = subparsers.add_parser(
"metrics",
Expand All @@ -162,17 +138,6 @@ def add_parser(subparsers, parent_parser):

fix_subparsers(metrics_subparsers)

METRICS_ADD_HELP = "Mark a DVC-tracked file as a metric."
metrics_add_parser = metrics_subparsers.add_parser(
"add",
parents=[parent_parser],
description=append_doc_link(METRICS_ADD_HELP, "metrics/add"),
help=METRICS_ADD_HELP,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
metrics_add_parser.add_argument("path", help="Path to a metric file.")
metrics_add_parser.set_defaults(func=CmdMetricsAdd)

METRICS_SHOW_HELP = "Print metrics, with optional formatting."
metrics_show_parser = metrics_subparsers.add_parser(
"show",
Expand Down Expand Up @@ -291,14 +256,3 @@ def add_parser(subparsers, parent_parser):
help="Show old metric value.",
)
metrics_diff_parser.set_defaults(func=CmdMetricsDiff)

METRICS_REMOVE_HELP = "Remove metric mark on a DVC-tracked file."
metrics_remove_parser = metrics_subparsers.add_parser(
"remove",
parents=[parent_parser],
description=append_doc_link(METRICS_REMOVE_HELP, "metrics/remove"),
help=METRICS_REMOVE_HELP,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
metrics_remove_parser.add_argument("path", help="Path to a metric file.")
metrics_remove_parser.set_defaults(func=CmdMetricsRemove)
4 changes: 2 additions & 2 deletions dvc/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ def __init__(self, paths):
class NoMetricsError(DvcException):
def __init__(self):
super().__init__(
"no metric files in this repository. "
"Use `dvc metrics add` to add a metric file to track."
"no metric files in this repository. Use `-m/-M` options for "
"`dvc run` to mark stage outputs as metrics."
)


Expand Down
10 changes: 0 additions & 10 deletions dvc/repo/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@ class Metrics:
def __init__(self, repo):
self.repo = repo

def add(self, *args, **kwargs):
from dvc.repo.metrics.add import add

return add(self.repo, *args, **kwargs)

def show(self, *args, **kwargs):
from dvc.repo.metrics.show import show

return show(self.repo, *args, **kwargs)

def remove(self, *args, **kwargs):
from dvc.repo.metrics.remove import remove

return remove(self.repo, *args, **kwargs)

def diff(self, *args, **kwargs):
from .diff import diff

Expand Down
5 changes: 0 additions & 5 deletions dvc/repo/metrics/add.py

This file was deleted.

22 changes: 0 additions & 22 deletions dvc/repo/metrics/modify.py

This file was deleted.

5 changes: 0 additions & 5 deletions dvc/repo/metrics/remove.py

This file was deleted.

8 changes: 1 addition & 7 deletions scripts/completion/dvc.bash
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,8 @@ _dvc_list='-R --recursive --dvc-only --rev'
_dvc_list_COMPGEN=_dvc_compgen_files
_dvc_freeze=''
_dvc_freeze_COMPGEN=_dvc_compgen_DVCFiles
_dvc_metrics='add diff modify remove show'
_dvc_metrics_add='-t --type -x --xpath'
_dvc_metrics_add_COMPGEN=_dvc_compgen_files
_dvc_metrics='diff show'
_dvc_metrics_diff='--targets -t --type -x --xpath -R --show-json --show-md --no-path --old'
_dvc_metrics_modify='-t --type -x --xpath'
_dvc_metrics_modify_COMPGEN=_dvc_compgen_files
_dvc_metrics_remove=''
_dvc_metrics_remove_COMPGEN=_dvc_compgen_files
_dvc_metrics_show='-t --type -x --xpath -a --all-branches -T --all-tags -R --recursive'
_dvc_metrics_show_COMPGEN=_dvc_compgen_files
_dvc_move=''
Expand Down
4 changes: 2 additions & 2 deletions scripts/completion/dvc.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _dvc_commands() {
"install:Install DVC git hooks into the repository."
"list:List repository contents, including files and directories tracked by DVC and by Git."
"lock:Lock DVC-file."
"metrics:Commands to add, manage, collect and display metrics."
"metrics:Commands to display and compare metrics."
"move:Rename or move a DVC controlled data file or a directory."
"params:Commands to display params."
"pull:Pull data files from a DVC remote storage."
Expand Down Expand Up @@ -182,7 +182,7 @@ _dvc_list=(
)

_dvc_metrics=(
"1:Sub command:(add show diff modify remove)"
"1:Sub command:(show diff)"
)

_dvc_move=(
Expand Down
10 changes: 8 additions & 2 deletions tests/func/test_repro.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,17 @@ def test(self):
stages = self.dvc.reproduce(file1_stage)
self.assertEqual(len(stages), 0)

self.dvc.metrics.add(file1)
d = load_yaml(file1_stage)
d["outs"][0]["metric"] = True
dump_yaml(file1_stage, d)

stages = self.dvc.reproduce(file1_stage)
self.assertEqual(len(stages), 0)

self.dvc.metrics.remove(file1)
d = load_yaml(file1_stage)
d["outs"][0]["metric"] = False
dump_yaml(file1_stage, d)

stages = self.dvc.reproduce(file1_stage)
self.assertEqual(len(stages), 0)

Expand Down