From 615894d3fbfa3289ee019467f4ca590923fe9869 Mon Sep 17 00:00:00 2001 From: Simon Alibert Date: Thu, 24 Oct 2024 11:37:44 +0200 Subject: [PATCH] Add test_same_attributes_defined --- tests/test_datasets.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/test_datasets.py b/tests/test_datasets.py index 1316df78..56b25d6d 100644 --- a/tests/test_datasets.py +++ b/tests/test_datasets.py @@ -42,7 +42,27 @@ from lerobot.common.datasets.utils import ( unflatten_dict, ) from lerobot.common.utils.utils import init_hydra_config, seeded_context -from tests.utils import DEFAULT_CONFIG_PATH, DEVICE +from tests.utils import DEFAULT_CONFIG_PATH, DEVICE, make_robot + +TEST_REPO_ID = "aliberts/koch_tutorial" + + +def test_same_attributes_defined(): + # TODO(aliberts): test with keys, shapes, names etc. provided instead of robot + robot = make_robot("koch", mock=True) + + # Instantiate both ways + dataset_init = LeRobotDataset(repo_id=TEST_REPO_ID) + dataset_create = LeRobotDataset.create(repo_id=TEST_REPO_ID, fps=30, robot=robot) + + # Access the '_hub_version' cached_property in both instances to force its creation + _ = dataset_init._hub_version + _ = dataset_create._hub_version + + init_attr = set(vars(dataset_init).keys()) + create_attr = set(vars(dataset_create).keys()) + + assert init_attr == create_attr, "Attribute sets do not match between __init__ and .create()" @pytest.mark.parametrize(