mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-24 04:59:47 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -237,17 +237,25 @@ def get_safe_version(repo_id: str, version: str | packaging.version.Version) ->
|
|||||||
hub_versions = get_repo_versions(repo_id)
|
hub_versions = get_repo_versions(repo_id)
|
||||||
|
|
||||||
if not hub_versions:
|
if not hub_versions:
|
||||||
raise RevisionNotFoundError(
|
msg = (
|
||||||
f"""Your dataset must be tagged with a codebase version.
|
f"Repo {repo_id!r} has no codebase-version tags. "
|
||||||
Assuming _version_ is the codebase_version value in the info.json, you can run this:
|
f"Either the dataset doesn't exist on the Hub yet, or it was "
|
||||||
```python
|
f"pushed without a version tag. To tag an existing dataset:\n"
|
||||||
from huggingface_hub import HfApi
|
f"```python\n"
|
||||||
|
f"from huggingface_hub import HfApi\n"
|
||||||
hub_api = HfApi()
|
f"HfApi().create_tag({repo_id!r}, tag='_version_', repo_type='dataset')\n"
|
||||||
hub_api.create_tag("{repo_id}", tag="_version_", repo_type="dataset")
|
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:
|
if target_version in hub_versions:
|
||||||
return f"v{target_version}"
|
return f"v{target_version}"
|
||||||
|
|||||||
Reference in New Issue
Block a user