Skip to content

Commit 7a0de24

Browse files
committed
Add and improve docstrings for task templates
1 parent 3578dbd commit 7a0de24

4 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/datasets/arrow_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ def with_transform(
13861386
return dataset
13871387

13881388
def prepare_for_task(self, task: Union[str, TaskTemplate]) -> "Dataset":
1389-
"""Prepare a dataset for the given task.
1389+
"""Prepare a dataset for the given task by casting the dataset's :class:`Features` to standardized column names and types as detailed in :obj:`datasets.tasks`.
13901390
13911391
Casts :attr:`datasets.DatasetInfo.features` according to a task-specific schema.
13921392

src/datasets/dataset_dict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ def from_text(
793793
).read()
794794

795795
def prepare_for_task(self, task: Union[str, TaskTemplate]):
796-
"""Prepare a dataset for the given task.
796+
"""Prepare a dataset for the given task by casting the dataset's :class:`Features` to standardized column names and types as detailed in :obj:`datasets.tasks`.
797797
798798
Casts :attr:`datasets.DatasetInfo.features` according to a task-specific schema.
799799

src/datasets/load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ def load_dataset(
696696
You can specify a different version that the default "main" by using a commit sha or a git tag of the dataset repository.
697697
use_auth_token (``str`` or ``bool``, optional): Optional string or boolean to use as Bearer token for remote files on the Datasets Hub.
698698
If True, will get token from `"~/.huggingface"`.
699-
task (``str``): The task to prepare the dataset for during training and evaluation. Casts the dataset's :class:`Features` according to one of the schemas in `~tasks`.
699+
task (``str``): The task to prepare the dataset for during training and evaluation. Casts the dataset's :class:`Features` to standardized column names and types as detailed in :obj:`datasets.tasks`.
700700
**config_kwargs: Keyword arguments to be passed to the :class:`BuilderConfig` and used in the :class:`DatasetBuilder`.
701701
702702
Returns:

src/datasets/tasks/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
def task_template_from_dict(task_template_dict: dict) -> Optional[TaskTemplate]:
15+
"""Create one of the supported task templates in :obj:`datasets.tasks` from a dictionary."""
1516
task_name = task_template_dict.get("task")
1617
if task_name is None:
1718
return None

0 commit comments

Comments
 (0)