fix: reupload dataset card

If a dataset has been modified (e.g. episodes added, removed, or
a new dataset has been re-created under the same name) then the
dataset card should also be reuploaded to match the metadata.

Closes issue: #849
This commit is contained in:
Ben Sprenger 2025-03-19 15:17:54 +01:00
parent 712d5dae4f
commit 6d0e058186
1 changed files with 4 additions and 6 deletions

View File

@ -27,7 +27,6 @@ import torch
import torch.utils
from datasets import concatenate_datasets, load_dataset
from huggingface_hub import HfApi, snapshot_download
from huggingface_hub.constants import REPOCARD_NAME
from huggingface_hub.errors import RevisionNotFoundError
from lerobot.common.constants import HF_LEROBOT_HOME
@ -560,11 +559,10 @@ class LeRobotDataset(torch.utils.data.Dataset):
else:
hub_api.upload_folder(**upload_kwargs)
if not hub_api.file_exists(self.repo_id, REPOCARD_NAME, repo_type="dataset", revision=branch):
card = create_lerobot_dataset_card(
tags=tags, dataset_info=self.meta.info, license=license, **card_kwargs
)
card.push_to_hub(repo_id=self.repo_id, repo_type="dataset", revision=branch)
card = create_lerobot_dataset_card(
tags=tags, dataset_info=self.meta.info, license=license, **card_kwargs
)
card.push_to_hub(repo_id=self.repo_id, repo_type="dataset", revision=branch)
if tag_version:
with contextlib.suppress(RevisionNotFoundError):