Skip to content

Enable xet in push to hub #7552

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

Merged
merged 2 commits into from
May 6, 2025
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
13 changes: 8 additions & 5 deletions src/datasets/arrow_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5394,8 +5394,10 @@ def shards_with_embedded_external_files(shards: Iterator[Dataset]) -> Iterator[D
shard_path_in_repo = f"{data_dir}/{split}-{index:05d}-of-{num_shards:05d}.parquet"
buffer = BytesIO()
shard.to_parquet(buffer)
uploaded_size += buffer.tell()
shard_addition = CommitOperationAdd(path_in_repo=shard_path_in_repo, path_or_fileobj=buffer)
parquet_content = buffer.getvalue()
uploaded_size += len(parquet_content)
del buffer
shard_addition = CommitOperationAdd(path_in_repo=shard_path_in_repo, path_or_fileobj=parquet_content)
api.preupload_lfs_files(
repo_id=repo_id,
additions=[shard_addition],
Expand Down Expand Up @@ -5705,10 +5707,11 @@ def push_to_hub(
with open(dataset_infos_path, encoding="utf-8") as f:
dataset_infos: dict = json.load(f)
dataset_infos[config_name] = asdict(info_to_dump)
buffer = BytesIO()
buffer.write(json.dumps(dataset_infos, indent=4).encode("utf-8"))
additions.append(
CommitOperationAdd(path_in_repo=config.DATASETDICT_INFOS_FILENAME, path_or_fileobj=buffer)
CommitOperationAdd(
path_in_repo=config.DATASETDICT_INFOS_FILENAME,
path_or_fileobj=json.dumps(dataset_infos, indent=4).encode("utf-8"),
)
)
# push to README
DatasetInfosDict({config_name: info_to_dump}).to_dataset_card_data(dataset_card_data)
Expand Down
5 changes: 1 addition & 4 deletions src/datasets/dataset_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import re
from collections.abc import Sequence
from functools import partial
from io import BytesIO
from pathlib import Path
from typing import Callable, Optional, Union

Expand Down Expand Up @@ -1853,12 +1852,10 @@ def push_to_hub(
with open(dataset_infos_path, encoding="utf-8") as f:
dataset_infos: dict = json.load(f)
dataset_infos[config_name] = asdict(info_to_dump)
buffer = BytesIO()
buffer.write(json.dumps(dataset_infos, indent=4).encode("utf-8"))
additions.append(
CommitOperationAdd(
path_in_repo=config.DATASETDICT_INFOS_FILENAME,
path_or_fileobj=buffer,
path_or_fileobj=json.dumps(dataset_infos, indent=4).encode("utf-8"),
)
)
# push to README
Expand Down
Loading