Skip to content

plots: remove VegaConverter TODO and update misleading comment #10023

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

Merged
merged 1 commit into from
Oct 17, 2023
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
17 changes: 4 additions & 13 deletions dvc/render/converter/vega.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ def __init__(
self.plot_id = plot_id
self.inferred_properties: Dict = {}

# TODO we should be handling that in `convert`,
# to avoid stateful `self.inferred_properties`
self._infer_x_y()

def _infer_y_from_data(self):
if self.plot_id in self.data:
for lst in _lists(self.data[self.plot_id]):
Expand Down Expand Up @@ -296,16 +292,11 @@ def convert(
):
"""
Convert the data. Fill necessary fields ('x', 'y') and return both
generated datapoints and updated properties. If `x` is not provided,
leave it as None, fronteds should handle it.

NOTE: Studio uses this method.
The only thing studio FE handles is filling `x` and `y`.
`x/y_label` should be filled here.

Datapoints are not stripped according to config, because users
might be utilizing other fields in their custom plots.
generated datapoints and updated properties. `x`, `y` values and labels
are inferred and always provided.
"""
self._infer_x_y()

datapoints = self._find_datapoints()
properties = {**self.properties, **self.inferred_properties}

Expand Down
1 change: 1 addition & 0 deletions tests/unit/render/test_vega_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_finding_lists(dictionary, expected_result):
assert list(result) == expected_result


@pytest.mark.studio
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[F] Marking that Studio relies on this behaviour. The test is

def test_convert(
    input_data,
    properties,
    expected_datapoints,
    expected_properties,
):
    converter = VegaConverter("f", input_data, properties)
    datapoints, resolved_properties = converter.flat_datapoints("r")
    assert datapoints == expected_datapoints
    assert resolved_properties == expected_properties

@pytest.mark.parametrize(
"input_data,properties,expected_datapoints,expected_properties",
[
Expand Down