From 841aae1b3892244698852e629192b94e8ac383a1 Mon Sep 17 00:00:00 2001 From: Eugene Mironov Date: Fri, 20 Dec 2024 00:41:25 +0700 Subject: [PATCH 1/3] Fix broken create_lerobot_dataset_card after migration to the dataset 2 --- lerobot/common/datasets/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lerobot/common/datasets/utils.py b/lerobot/common/datasets/utils.py index af5b03cc0..1b561e4ff 100644 --- a/lerobot/common/datasets/utils.py +++ b/lerobot/common/datasets/utils.py @@ -477,7 +477,6 @@ def create_lerobot_dataset_card( Note: If specified, license must be one of https://huggingface.co/docs/hub/repositories-licenses. """ card_tags = ["LeRobot"] - card_template_path = importlib.resources.path("lerobot.common.datasets", "card_template.md") if tags: card_tags += tags @@ -497,8 +496,10 @@ def create_lerobot_dataset_card( ], ) + card_template = (importlib.resources.files("lerobot.common.datasets") / "card_template.md").read_text() + return DatasetCard.from_template( card_data=card_data, - template_path=str(card_template_path), + template_str=card_template, **kwargs, ) From e0f3453be3c2772989c969716654ad805e408e1f Mon Sep 17 00:00:00 2001 From: Eugene Mironov Date: Fri, 20 Dec 2024 00:54:35 +0700 Subject: [PATCH 2/3] Add tests for fixed method --- tests/lerobot/common/datasets/test_utils.py | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/lerobot/common/datasets/test_utils.py diff --git a/tests/lerobot/common/datasets/test_utils.py b/tests/lerobot/common/datasets/test_utils.py new file mode 100644 index 000000000..b2d8319c0 --- /dev/null +++ b/tests/lerobot/common/datasets/test_utils.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +# Copyright 2024 The HuggingFace Inc. team. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest +from huggingface_hub import DatasetCard +from lerobot.common.datasets.utils import create_lerobot_dataset_card + +def test_default_parameters(): + card = create_lerobot_dataset_card() + assert isinstance(card, DatasetCard) + assert card.data.tags == ["LeRobot"] + assert card.data.task_categories == ["robotics"] + assert card.data.configs == [ + { + "config_name": "default", + "data_files": "data/*/*.parquet", + } + ] + +def test_with_tags(): + tags = ["tag1", "tag2"] + card = create_lerobot_dataset_card(tags=tags) + assert card.data.tags == ["LeRobot", "tag1", "tag2"] From ce6a59f31d3a3d9f9acf27cf7cfbdeb2873c1ffe Mon Sep 17 00:00:00 2001 From: Eugene Mironov Date: Mon, 23 Dec 2024 18:33:39 +0700 Subject: [PATCH 3/3] Fix linter --- tests/lerobot/common/datasets/test_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/lerobot/common/datasets/test_utils.py b/tests/lerobot/common/datasets/test_utils.py index b2d8319c0..f484e1aef 100644 --- a/tests/lerobot/common/datasets/test_utils.py +++ b/tests/lerobot/common/datasets/test_utils.py @@ -14,10 +14,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest from huggingface_hub import DatasetCard + from lerobot.common.datasets.utils import create_lerobot_dataset_card + def test_default_parameters(): card = create_lerobot_dataset_card() assert isinstance(card, DatasetCard) @@ -30,6 +31,7 @@ def test_default_parameters(): } ] + def test_with_tags(): tags = ["tag1", "tag2"] card = create_lerobot_dataset_card(tags=tags)