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

Feature Request: Add functionality to pass split types like train, test in DatasetDict.map #7240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions src/datasets/dataset_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ def map(
function: Optional[Callable] = None,
with_indices: bool = False,
with_rank: bool = False,
with_split: bool = False,
input_columns: Optional[Union[str, List[str]]] = None,
batched: bool = False,
batch_size: Optional[int] = 1000,
Expand All @@ -795,7 +796,7 @@ def map(
writer_batch_size: Optional[int] = 1000,
features: Optional[Features] = None,
disable_nullable: bool = False,
fn_kwargs: Optional[dict] = None,
fn_kwargs: dict = {},
num_proc: Optional[int] = None,
desc: Optional[str] = None,
) -> "DatasetDict":
Expand Down Expand Up @@ -882,6 +883,7 @@ def map(
self._check_values_type()
if cache_file_names is None:
cache_file_names = {k: None for k in self}

return DatasetDict(
{
k: dataset.map(
Expand All @@ -899,7 +901,7 @@ def map(
writer_batch_size=writer_batch_size,
features=features,
disable_nullable=disable_nullable,
fn_kwargs=fn_kwargs,
fn_kwargs={**fn_kwargs, "split": k} if with_split else fn_kwargs,
num_proc=num_proc,
desc=desc,
)
Expand Down