-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ConnectionError for gated datasets and unauthenticated users (#7110)
* Test load_dataset raises DatasetNotFoundError for unauthenticated user * Raise DatasetNotFoundError for gated and unauthenticated * Rename function
- Loading branch information
1 parent
fb8ae4d
commit 90b1d94
Showing
4 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
from functools import partial | ||
|
||
from huggingface_hub import hf_hub_url | ||
from huggingface_hub.utils import get_session, hf_raise_for_status | ||
|
||
|
||
hf_dataset_url = partial(hf_hub_url, repo_type="dataset") | ||
|
||
|
||
def check_auth(hf_api, repo_id, token=None): | ||
headers = hf_api._build_hf_headers(token=token) | ||
path = f"{hf_api.endpoint}/api/datasets/{repo_id}/auth-check" | ||
r = get_session().get(path, headers=headers) | ||
hf_raise_for_status(r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters