Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions src/datasets/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,8 +1330,12 @@ def __init__(
increase_load_count(name, resource_type="dataset")

def get_module(self) -> DatasetModule:
exported_parquet_files = _datasets_server.get_exported_parquet_files(dataset=self.name, revision=self.revision)
exported_dataset_infos = _datasets_server.get_exported_dataset_infos(dataset=self.name, revision=self.revision)
exported_parquet_files = _datasets_server.get_exported_parquet_files(
dataset=self.name, revision=self.revision, token=self.download_config.token
)
exported_dataset_infos = _datasets_server.get_exported_dataset_infos(
dataset=self.name, revision=self.revision, token=self.download_config.token
)
hfh_dataset_info = HfApi(config.HF_ENDPOINT).dataset_info(
self.name,
revision="refs/convert/parquet",
Expand Down
12 changes: 7 additions & 5 deletions src/datasets/utils/_datasets_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List
from typing import Any, Dict, List, Optional, Union

from .. import config
from ..exceptions import DatasetsError
Expand All @@ -22,7 +22,7 @@ class DatasetsServerError(DatasetsError):
"""


def get_exported_parquet_files(dataset: str, revision: str) -> List[Dict[str, Any]]:
def get_exported_parquet_files(dataset: str, revision: str, token: Optional[Union[str, bool]]) -> List[Dict[str, Any]]:
"""
Get the dataset exported parquet files
Docs: https://huggingface.co/docs/datasets-server/parquet
Expand All @@ -32,7 +32,7 @@ def get_exported_parquet_files(dataset: str, revision: str) -> List[Dict[str, An
parquet_data_files_response = http_get(
url=datasets_server_parquet_url + dataset,
temp_file=None,
headers=get_authentication_headers_for_url(config.HF_ENDPOINT + f"datasets/{dataset}"),
headers=get_authentication_headers_for_url(config.HF_ENDPOINT + f"datasets/{dataset}", token=token),
timeout=100.0,
max_retries=3,
)
Expand All @@ -58,7 +58,9 @@ def get_exported_parquet_files(dataset: str, revision: str) -> List[Dict[str, An
raise DatasetsServerError("No exported Parquet files available.")


def get_exported_dataset_infos(dataset: str, revision: str) -> Dict[str, Dict[str, Any]]:
def get_exported_dataset_infos(
dataset: str, revision: str, token: Optional[Union[str, bool]]
) -> Dict[str, Dict[str, Any]]:
"""
Get the dataset information, can be useful to get e.g. the dataset features.
Docs: https://huggingface.co/docs/datasets-server/info
Expand All @@ -68,7 +70,7 @@ def get_exported_dataset_infos(dataset: str, revision: str) -> Dict[str, Dict[st
info_response = http_get(
url=datasets_server_info_url + dataset,
temp_file=None,
headers=get_authentication_headers_for_url(config.HF_ENDPOINT + f"datasets/{dataset}"),
headers=get_authentication_headers_for_url(config.HF_ENDPOINT + f"datasets/{dataset}", token=token),
timeout=100.0,
max_retries=3,
)
Expand Down