Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise DisabledRepoError if repo is disabled #1965

Merged
merged 1 commit into from
Jan 11, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jan 11, 2024

After discussion with @severo. Repositories can be disabled, in which case they won't we accessible to anyone anymore. This PR adds a custom DisabledRepoError exception when trying to access such a repo.

>>> from huggingface_hub import dataset_info
>>> dataset_info("laion/laion-art")
(...)
huggingface_hub.utils._errors.DisabledRepoError: 403 Client Error. (Request ID: Root=1-659fc3fa-3031673e0f92c71a2260dbe2;bc6f4dfb-b30a-4862-af0a-5cfe827610d8)
Cannot access repository for url https://huggingface.co/api/datasets/laion/laion-art.
Access to this resource is disabled.

Note: if user is not authenticated -no token sent-, a HTTP 401 is returned by the server as if the repo doesn't exist at all => translates to a RepoNotFound error.

@Wauplin Wauplin requested a review from severo January 11, 2024 10:39
Copy link
Collaborator

@severo severo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Wauplin
Copy link
Contributor Author

Wauplin commented Jan 11, 2024

Thanks for the quick review!

@Wauplin Wauplin merged commit b79882a into main Jan 11, 2024
16 checks passed
@Wauplin Wauplin deleted the custom-error-for-disabled-repo branch January 11, 2024 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants