Skip to content

Commit

Permalink
make_dvcyaml: skip metrics plots when plot=False (#652)
Browse files Browse the repository at this point in the history
* make_dvcyaml: skip metrics plots when plot=False

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Delete _dvclive_version.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: David de la Iglesia Castro <daviddelaiglesiacastro@gmail.com>
  • Loading branch information
3 people authored Aug 4, 2023
1 parent 36e8c4c commit 6f8181e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dvclive/dvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ def make_dvcyaml(live):
dvcyaml["metrics"] = [os.path.relpath(live.metrics_file, live.dir)]
plots = []
plots_path = Path(live.plots_dir)
if live._metrics:
metrics_path = (plots_path / Metric.subfolder).relative_to(live.dir).as_posix()
metrics_config = {metrics_path: {"x": "step"}}
metrics_path = plots_path / Metric.subfolder
if metrics_path.exists():
metrics_relpath = metrics_path.relative_to(live.dir).as_posix()
metrics_config = {metrics_relpath: {"x": "step"}}
plots.append(metrics_config)
if live._images:
images_path = (plots_path / Image.subfolder).relative_to(live.dir)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_dvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ def test_make_dvcyaml_metrics(tmp_dir):
}


def test_make_dvcyaml_metrics_no_plots(tmp_dir):
live = Live()
live.log_metric("bar", 2, plot=False)
make_dvcyaml(live)

assert load_yaml(live.dvc_file) == {
"metrics": ["metrics.json"],
}


def test_make_dvcyaml_summary(tmp_dir):
live = Live()
live.summary["bar"] = 2
Expand Down

0 comments on commit 6f8181e

Please sign in to comment.