Check for "/" in feature names (#660)
This commit is contained in:
@@ -304,6 +304,13 @@ class LeRobotDatasetMetadata:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# TODO(aliberts, rcadene): implement sanity check for features
|
# TODO(aliberts, rcadene): implement sanity check for features
|
||||||
|
|
||||||
|
# check if none of the features contains a "/" in their names,
|
||||||
|
# as this would break the dict flattening in the stats computation, which uses '/' as separator
|
||||||
|
for key in features:
|
||||||
|
if "/" in key:
|
||||||
|
raise ValueError(f"Feature names should not contain '/'. Found '/' in feature '{key}'.")
|
||||||
|
|
||||||
features = {**features, **DEFAULT_FEATURES}
|
features = {**features, **DEFAULT_FEATURES}
|
||||||
|
|
||||||
obj.tasks, obj.stats, obj.episodes = {}, {}, []
|
obj.tasks, obj.stats, obj.episodes = {}, {}, []
|
||||||
|
|||||||
@@ -414,3 +414,20 @@ def test_create_branch():
|
|||||||
|
|
||||||
# Clean
|
# Clean
|
||||||
api.delete_repo(repo_id, repo_type=repo_type)
|
api.delete_repo(repo_id, repo_type=repo_type)
|
||||||
|
|
||||||
|
|
||||||
|
def test_dataset_feature_with_forward_slash_raises_error():
|
||||||
|
# make sure dir does not exist
|
||||||
|
from lerobot.common.datasets.lerobot_dataset import LEROBOT_HOME
|
||||||
|
|
||||||
|
dataset_dir = LEROBOT_HOME / "lerobot/test/with/slash"
|
||||||
|
# make sure does not exist
|
||||||
|
if dataset_dir.exists():
|
||||||
|
dataset_dir.rmdir()
|
||||||
|
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
LeRobotDataset.create(
|
||||||
|
repo_id="lerobot/test/with/slash",
|
||||||
|
fps=30,
|
||||||
|
features={"a/b": {"dtype": "float32", "shape": 2, "names": None}},
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user