-
Notifications
You must be signed in to change notification settings - Fork 1.3k
run: raise error when command is not specified #3850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b31700b
fd67d32
872e231
9b3f59a
c192b3c
a2f22f5
cb502c6
79c8bc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from tests.func.plots import run_copy_metrics # noqa: F401 | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created a |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,11 +3,10 @@ | |
| import yaml | ||
|
|
||
|
|
||
| def test_metrics_diff_simple(tmp_dir, scm, dvc): | ||
| def test_metrics_diff_simple(tmp_dir, scm, dvc, run_copy_metrics): | ||
| def _gen(val): | ||
| tmp_dir.gen({"m.yaml": str(val)}) | ||
| dvc.run(cmd="", metrics=["m.yaml"], single_stage=True) | ||
| dvc.scm.add(["m.yaml.dvc"]) | ||
| tmp_dir.gen({"m_temp.yaml": str(val)}) | ||
| run_copy_metrics("m_temp.yaml", "m.yaml", metrics=["m.yaml"]) | ||
|
Comment on lines
+8
to
+9
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar code exists on metrics/params. A temp file with suffix |
||
| dvc.scm.commit(str(val)) | ||
|
|
||
| _gen(1) | ||
|
|
@@ -19,13 +18,13 @@ def _gen(val): | |
| assert dvc.metrics.diff(a_rev="HEAD~2") == expected | ||
|
|
||
|
|
||
| def test_metrics_diff_yaml(tmp_dir, scm, dvc): | ||
| def test_metrics_diff_yaml(tmp_dir, scm, dvc, run_copy_metrics): | ||
| def _gen(val): | ||
| metrics = {"a": {"b": {"c": val, "d": 1, "e": str(val)}}} | ||
| tmp_dir.gen({"m.yaml": yaml.dump(metrics)}) | ||
| dvc.run(cmd="", metrics=["m.yaml"], single_stage=True) | ||
| dvc.scm.add(["m.yaml.dvc"]) | ||
| dvc.scm.commit(str(val)) | ||
| tmp_dir.gen({"m_temp.yaml": yaml.dump(metrics)}) | ||
| run_copy_metrics( | ||
| "m_temp.yaml", "m.yaml", metrics=["m.yaml"], commit=str(val) | ||
| ) | ||
|
|
||
| _gen(1) | ||
| _gen(2) | ||
|
|
@@ -36,13 +35,13 @@ def _gen(val): | |
| assert dvc.metrics.diff(a_rev="HEAD~2") == expected | ||
|
|
||
|
|
||
| def test_metrics_diff_json(tmp_dir, scm, dvc): | ||
| def test_metrics_diff_json(tmp_dir, scm, dvc, run_copy_metrics): | ||
| def _gen(val): | ||
| metrics = {"a": {"b": {"c": val, "d": 1, "e": str(val)}}} | ||
| tmp_dir.gen({"m.json": json.dumps(metrics)}) | ||
| dvc.run(cmd="", metrics=["m.json"], single_stage=True) | ||
| dvc.scm.add(["m.json.dvc"]) | ||
| dvc.scm.commit(str(val)) | ||
| tmp_dir.gen({"m_temp.json": json.dumps(metrics)}) | ||
| run_copy_metrics( | ||
| "m_temp.json", "m.json", metrics=["m.json"], commit=str(val) | ||
| ) | ||
|
|
||
| _gen(1) | ||
| _gen(2) | ||
|
|
@@ -52,13 +51,13 @@ def _gen(val): | |
| assert dvc.metrics.diff(a_rev="HEAD~2") == expected | ||
|
|
||
|
|
||
| def test_metrics_diff_json_unchanged(tmp_dir, scm, dvc): | ||
| def test_metrics_diff_json_unchanged(tmp_dir, scm, dvc, run_copy_metrics): | ||
| def _gen(val): | ||
| metrics = {"a": {"b": {"c": val, "d": 1, "e": str(val)}}} | ||
| tmp_dir.gen({"m.json": json.dumps(metrics)}) | ||
| dvc.run(cmd="", metrics=["m.json"], single_stage=True) | ||
| dvc.scm.add(["m.json.dvc"]) | ||
| dvc.scm.commit(str(val)) | ||
| tmp_dir.gen({"m_temp.json": json.dumps(metrics)}) | ||
| run_copy_metrics( | ||
| "m_temp.json", "m.json", metrics=["m.json"], commit=str(val) | ||
| ) | ||
|
|
||
| _gen(1) | ||
| _gen(2) | ||
|
|
@@ -67,12 +66,15 @@ def _gen(val): | |
| assert dvc.metrics.diff(a_rev="HEAD~2") == {} | ||
|
|
||
|
|
||
| def test_metrics_diff_broken_json(tmp_dir, scm, dvc): | ||
| def test_metrics_diff_broken_json(tmp_dir, scm, dvc, run_copy_metrics): | ||
| metrics = {"a": {"b": {"c": 1, "d": 1, "e": "3"}}} | ||
| tmp_dir.gen({"m.json": json.dumps(metrics)}) | ||
| dvc.run(cmd="", metrics_no_cache=["m.json"], single_stage=True) | ||
| dvc.scm.add(["m.json.dvc", "m.json"]) | ||
| dvc.scm.commit("add metrics") | ||
| tmp_dir.gen({"m_temp.json": json.dumps(metrics)}) | ||
| run_copy_metrics( | ||
| "m_temp.json", | ||
| "m.json", | ||
| metrics_no_cache=["m.json"], | ||
| commit="add metrics", | ||
| ) | ||
|
|
||
| (tmp_dir / "m.json").write_text(json.dumps(metrics) + "ma\nlformed\n") | ||
|
|
||
|
|
@@ -89,10 +91,10 @@ def test_metrics_diff_no_metrics(tmp_dir, scm, dvc): | |
| assert dvc.metrics.diff(a_rev="HEAD~1") == {} | ||
|
|
||
|
|
||
| def test_metrics_diff_new_metric(tmp_dir, scm, dvc): | ||
| def test_metrics_diff_new_metric(tmp_dir, scm, dvc, run_copy_metrics): | ||
| metrics = {"a": {"b": {"c": 1, "d": 1, "e": "3"}}} | ||
| tmp_dir.gen({"m.json": json.dumps(metrics)}) | ||
| dvc.run(cmd="", metrics_no_cache=["m.json"], single_stage=True) | ||
| tmp_dir.gen({"m_temp.json": json.dumps(metrics)}) | ||
| run_copy_metrics("m_temp.json", "m.json", metrics_no_cache=["m.json"]) | ||
|
|
||
| assert dvc.metrics.diff() == { | ||
| "m.json": { | ||
|
|
@@ -102,12 +104,15 @@ def test_metrics_diff_new_metric(tmp_dir, scm, dvc): | |
| } | ||
|
|
||
|
|
||
| def test_metrics_diff_deleted_metric(tmp_dir, scm, dvc): | ||
| def test_metrics_diff_deleted_metric(tmp_dir, scm, dvc, run_copy_metrics): | ||
| metrics = {"a": {"b": {"c": 1, "d": 1, "e": "3"}}} | ||
| tmp_dir.gen({"m.json": json.dumps(metrics)}) | ||
| dvc.run(cmd="", metrics_no_cache=["m.json"], single_stage=True) | ||
| dvc.scm.add(["m.json.dvc", "m.json"]) | ||
| dvc.scm.commit("add metrics") | ||
| tmp_dir.gen({"m_temp.json": json.dumps(metrics)}) | ||
| run_copy_metrics( | ||
| "m_temp.json", | ||
| "m.json", | ||
| metrics_no_cache=["m.json"], | ||
| commit="add metrics", | ||
| ) | ||
|
|
||
| (tmp_dir / "m.json").unlink() | ||
|
|
||
|
|
@@ -119,11 +124,14 @@ def test_metrics_diff_deleted_metric(tmp_dir, scm, dvc): | |
| } | ||
|
|
||
|
|
||
| def test_metrics_diff_with_unchanged(tmp_dir, scm, dvc): | ||
| tmp_dir.gen("metrics.yaml", "foo: 1\nxyz: 10") | ||
| dvc.run(metrics_no_cache=["metrics.yaml"], single_stage=True) | ||
| scm.add(["metrics.yaml", "metrics.yaml.dvc"]) | ||
| scm.commit("1") | ||
| def test_metrics_diff_with_unchanged(tmp_dir, scm, dvc, run_copy_metrics): | ||
| tmp_dir.gen("metrics_temp.yaml", "foo: 1\nxyz: 10") | ||
| run_copy_metrics( | ||
| "metrics_temp.yaml", | ||
| "metrics.yaml", | ||
| metrics_no_cache=["metrics.yaml"], | ||
| commit="1", | ||
| ) | ||
|
|
||
| tmp_dir.scm_gen("metrics.yaml", "foo: 2\nxyz: 10", commit="2") | ||
| tmp_dir.scm_gen("metrics.yaml", "foo: 3\nxyz: 10", commit="3") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def run_copy_metrics(tmp_dir, run_copy): | ||
| def run(file1, file2, commit=None, tag=None, **kwargs): | ||
| stage = tmp_dir.dvc.run( | ||
| cmd=f"python copy.py {file1} {file2}", | ||
| deps=[file1], | ||
| single_stage=True, | ||
| **kwargs, | ||
| ) | ||
|
|
||
| if hasattr(tmp_dir.dvc, "scm"): | ||
| files = [stage.path] | ||
| files += [ | ||
| os.fspath(out.path_info) | ||
| for out in stage.outs | ||
| if not out.use_cache | ||
| ] | ||
| tmp_dir.dvc.scm.add(files) | ||
| if commit: | ||
| tmp_dir.dvc.scm.commit(commit) | ||
| if tag: | ||
| tmp_dir.dvc.scm.tag(tag) | ||
| return stage | ||
|
|
||
| return run |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import run_copy_metrics # noqa: F401 |
Uh oh!
There was an error while loading. Please reload this page.