From b416f287f29227b7d0575b99e8f4728395bbed29 Mon Sep 17 00:00:00 2001 From: Pepijn Date: Tue, 5 May 2026 18:12:40 +0200 Subject: [PATCH] fix(datasets): raise readable error when repo has no version tags ``RevisionNotFoundError`` inherits from ``huggingface_hub.HfHubHTTPError`` which made ``response`` a required keyword-only argument on recent versions. Constructing it with just a message string blew up with ``TypeError: HfHubHTTPError.__init__() missing 1 required keyword-only argument: 'response'`` instead of surfacing the actual problem (the dataset/checkpoint repo doesn't exist on the Hub yet). Pass ``response=None`` explicitly. Fall back to the bare-message form for older ``huggingface_hub`` versions that don't accept the kwarg. Also clarify the message to call out the most common cause: typing a hub repo id that hasn't been pushed yet (instead of just "needs a version tag"). Co-Authored-By: Claude Opus 4.7 (1M context) --- src/lerobot/datasets/utils.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/lerobot/datasets/utils.py b/src/lerobot/datasets/utils.py index 922a2d3ce..8cbf89fa8 100644 --- a/src/lerobot/datasets/utils.py +++ b/src/lerobot/datasets/utils.py @@ -237,17 +237,25 @@ def get_safe_version(repo_id: str, version: str | packaging.version.Version) -> hub_versions = get_repo_versions(repo_id) if not hub_versions: - raise RevisionNotFoundError( - f"""Your dataset must be tagged with a codebase version. - Assuming _version_ is the codebase_version value in the info.json, you can run this: - ```python - from huggingface_hub import HfApi - - hub_api = HfApi() - hub_api.create_tag("{repo_id}", tag="_version_", repo_type="dataset") - ``` - """ + msg = ( + f"Repo {repo_id!r} has no codebase-version tags. " + f"Either the dataset doesn't exist on the Hub yet, or it was " + f"pushed without a version tag. To tag an existing dataset:\n" + f"```python\n" + f"from huggingface_hub import HfApi\n" + f"HfApi().create_tag({repo_id!r}, tag='_version_', repo_type='dataset')\n" + f"```" ) + # ``RevisionNotFoundError`` extends ``HfHubHTTPError`` which on + # newer ``huggingface_hub`` versions makes ``response`` a required + # keyword arg. Pass ``response=None`` explicitly so this raises + # with a clean message instead of an upstream + # ``TypeError: __init__() missing 1 required keyword-only argument: 'response'``. + try: + raise RevisionNotFoundError(msg, response=None) + except TypeError: + # Older ``huggingface_hub`` (no ``response`` kwarg). + raise RevisionNotFoundError(msg) # noqa: B904 if target_version in hub_versions: return f"v{target_version}"