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

Add timeout to dataset_info #373

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/huggingface_hub/hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,11 @@ def list_datasets(
return [DatasetInfo(**x) for x in d]

def model_info(
self, repo_id: str, revision: Optional[str] = None, token: Optional[str] = None
self,
repo_id: str,
revision: Optional[str] = None,
token: Optional[str] = None,
timeout: Optional[float] = None,
) -> ModelInfo:
"""
Get info on one specific model on huggingface.co
Expand All @@ -509,7 +513,7 @@ def model_info(
headers = (
{"authorization": "Bearer {}".format(token)} if token is not None else None
)
r = requests.get(path, headers=headers)
r = requests.get(path, headers=headers, timeout=timeout)
r.raise_for_status()
d = r.json()
return ModelInfo(**d)
Expand All @@ -532,7 +536,11 @@ def list_repos_objs(
return [RepoObj(**x) for x in d]

def dataset_info(
self, repo_id: str, revision: Optional[str] = None, token: Optional[str] = None
self,
repo_id: str,
revision: Optional[str] = None,
token: Optional[str] = None,
timeout: Optional[float] = None,
) -> DatasetInfo:
"""
Get info on one specific dataset on huggingface.co
Expand All @@ -550,7 +558,7 @@ def dataset_info(
{"authorization": "Bearer {}".format(token)} if token is not None else None
)
params = {"full": "true"}
r = requests.get(path, headers=headers, params=params)
r = requests.get(path, headers=headers, params=params, timeout=timeout)
r.raise_for_status()
d = r.json()
return DatasetInfo(**d)
Expand Down