mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-10 23:10:42 +01:00
merge plot ids across dvc.yaml files
This commit is contained in:
committed by
Dave Berenbaum
parent
d81a1bbf56
commit
7e7d0e1dd8
+1
-3
@@ -8,7 +8,6 @@ import dpath.options
|
||||
from funcy import get_in, last
|
||||
|
||||
from dvc.repo.plots import _normpath, infer_data_sources
|
||||
from dvc.utils.plots import get_plot_id
|
||||
|
||||
from .convert import _get_converter
|
||||
|
||||
@@ -42,8 +41,7 @@ class PlotsData:
|
||||
for plot_id, plot_definition in config_file_content.get(
|
||||
"data", {}
|
||||
).items():
|
||||
full_id = get_plot_id(plot_id, config_file)
|
||||
groups[full_id].append((rev, plot_id, plot_definition))
|
||||
groups[plot_id].append((rev, plot_id, plot_definition))
|
||||
return dict(groups)
|
||||
|
||||
def get_definition_data(self, target_files, rev):
|
||||
|
||||
@@ -367,14 +367,11 @@ def infer_data_sources(plot_id, config=None):
|
||||
def _matches(targets, config_file, plot_id):
|
||||
import re
|
||||
|
||||
from dvc.utils.plots import get_plot_id
|
||||
|
||||
if not targets:
|
||||
return True
|
||||
|
||||
full_id = get_plot_id(plot_id, config_file)
|
||||
if any(
|
||||
(re.match(target, plot_id) or re.match(target, full_id)) for target in targets
|
||||
(re.match(target, plot_id) or re.match(target, plot_id)) for target in targets
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
def get_plot_id(config_plot_id: str, config_file_path: str = ""):
|
||||
return (
|
||||
f"{config_file_path}::{config_plot_id}" if config_file_path else config_plot_id
|
||||
)
|
||||
@@ -426,5 +426,5 @@ def test_show_plots_defined_with_native_os_path(tmp_dir, dvc, scm, capsys):
|
||||
assert "errors" not in json_out
|
||||
|
||||
json_data = json_out["data"]
|
||||
assert json_data[f"dvc.yaml::{top_level_plot}"]
|
||||
assert json_data[f"{top_level_plot}"]
|
||||
assert json_data[stage_plot]
|
||||
|
||||
@@ -440,8 +440,8 @@ def test_repo_with_config_plots(tmp_dir, capsys, repo_with_config_plots):
|
||||
html_result = extract_vega_specs(
|
||||
html_path,
|
||||
[
|
||||
"dvc.yaml::linear_train_vs_test",
|
||||
"dvc.yaml::confusion_train_vs_test",
|
||||
"linear_train_vs_test",
|
||||
"confusion_train_vs_test",
|
||||
],
|
||||
)
|
||||
ble = _update_datapoints(
|
||||
@@ -456,5 +456,5 @@ def test_repo_with_config_plots(tmp_dir, capsys, repo_with_config_plots):
|
||||
},
|
||||
)
|
||||
|
||||
assert html_result["dvc.yaml::linear_train_vs_test"]["data"]["values"] == ble
|
||||
assert html_result["linear_train_vs_test"]["data"]["values"] == ble
|
||||
# TODO check json results once vscode is able to handle flexible plots
|
||||
|
||||
@@ -29,9 +29,9 @@ def test_group_definitions():
|
||||
grouped = PlotsData(data).group_definitions()
|
||||
|
||||
assert grouped == {
|
||||
"config_file_1::plot_id_1": [("v1", "plot_id_1", {})],
|
||||
"config_file_1::plot_id_2": [("v1", "plot_id_2", {})],
|
||||
"config_file_2::plot_id_3": [
|
||||
"plot_id_1": [("v1", "plot_id_1", {})],
|
||||
"plot_id_2": [("v1", "plot_id_2", {})],
|
||||
"plot_id_3": [
|
||||
("v1", "plot_id_3", {}),
|
||||
("v2", "plot_id_3", {}),
|
||||
],
|
||||
@@ -103,7 +103,7 @@ def test_match_renderers(M):
|
||||
},
|
||||
]
|
||||
assert renderer.properties == {
|
||||
"title": "config_file_1::plot_id_1",
|
||||
"title": "plot_id_1",
|
||||
"x": "x",
|
||||
"y": "y",
|
||||
"x_label": "x",
|
||||
|
||||
Reference in New Issue
Block a user