From 4b4d03778cb9354e38886621027a94bed2cd67d8 Mon Sep 17 00:00:00 2001 From: "Derek T. Jones" Date: Thu, 19 Feb 2026 10:50:12 -0800 Subject: [PATCH] 'data' key not required; can be any friendly name. Previous testing incorrectly assumed that in a data request, the data source name had to be called 'data' if there weren't multiple sources. This is not true. Corrected both test and logic. --- src/hyrax/config_schemas/data_request.py | 5 ++--- tests/hyrax/test_data_request_config.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/hyrax/config_schemas/data_request.py b/src/hyrax/config_schemas/data_request.py index db124f41..3eee88f1 100644 --- a/src/hyrax/config_schemas/data_request.py +++ b/src/hyrax/config_schemas/data_request.py @@ -180,10 +180,9 @@ def as_dict(self, *, exclude_unset: bool = False) -> dict[str, Any]: if value is not None: # Handle both single config and dict of configs if isinstance(value, dict): - # Dict of configs - wrap each in {"data": ...} + # Dict of configs - keys are already friendly names output[name] = { - key: {"data": cfg.as_dict(exclude_unset=exclude_unset)} - for key, cfg in value.items() + key: cfg.as_dict(exclude_unset=exclude_unset) for key, cfg in value.items() } else: # Single config - wrap in {"data": ...} diff --git a/tests/hyrax/test_data_request_config.py b/tests/hyrax/test_data_request_config.py index 6f4761de..af216719 100644 --- a/tests/hyrax/test_data_request_config.py +++ b/tests/hyrax/test_data_request_config.py @@ -410,6 +410,6 @@ def test_as_dict_with_dict_configs(): assert "train" in as_dict assert "data_0" in as_dict["train"] assert "data_1" in as_dict["train"] - assert as_dict["train"]["data_0"]["data"]["dataset_class"] == "HyraxRandomDataset" - assert as_dict["train"]["data_0"]["data"]["primary_id_field"] == "id" - assert as_dict["train"]["data_1"]["data"]["dataset_class"] == "HyraxCifarDataset" + assert as_dict["train"]["data_0"]["dataset_class"] == "HyraxRandomDataset" + assert as_dict["train"]["data_0"]["primary_id_field"] == "id" + assert as_dict["train"]["data_1"]["dataset_class"] == "HyraxCifarDataset"