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
26 changes: 26 additions & 0 deletions tests/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,32 @@ def test_runset_query_parameter():
assert reconstructed_empty_search.query == ""


@pytest.mark.parametrize(
("key", "expected_groupby"),
[
(
Key(section="config", name="algo_backbone.value"),
"config.algo_backbone.value",
),
(Key(section="summary", name="loss"), "summary.loss"),
(Key(section="summary", name="eval.loss"), "summary.eval.loss"),
(Key(section="run", name="group"), "run.Group"),
(Key(section="run", name="custom.metric"), "run.custom.metric"),
],
)
def test_runset_groupby_round_trip_preserves_section(key, expected_groupby):
"""Loading and saving a runset must not reinterpret a grouping key's section."""
from wandb_workspaces.reports.v2 import internal

original = internal.Runset(grouping=[key])

runset = wr.Runset._from_model(original)
assert runset.groupby == [expected_groupby]

round_tripped = runset._to_model()
assert round_tripped.grouping == original.grouping


def test_metric_to_backend_groupby():
"""Test the _metric_to_backend_groupby function with various input formats"""

Expand Down
6 changes: 5 additions & 1 deletion wandb_workspaces/reports/v2/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,11 @@ def _from_model(cls, model: internal.Runset):
name=model.name,
query=model.search.query if model.search else "",
filters=filter_string,
groupby=[expr.to_frontend_name(k.name) for k in model.grouping],
# Keep the section explicit so dotted key names are not mistaken for
# "section.name" when groupby strings are parsed again on save.
groupby=[
f"{k.section}.{expr.to_frontend_name(k.name)}" for k in model.grouping
],
order=[OrderBy._from_model(s) for s in model.sort.keys],
run_settings=run_settings,
pinned_columns=pinned_columns,
Expand Down
Loading