omnipy.components.general.tasks
General tasks for splitting, importing, and converting datasets.
| FUNCTION | DESCRIPTION |
|---|---|
convert_dataset |
Convert a dataset into another dataset class. |
import_directory |
Import files from a directory into a dataset keyed by filename stem. |
split_dataset |
Split a dataset into two datasets based on selected data-file names. |
convert_dataset
convert_dataset(dataset: Dataset, dataset_cls: type[_DatasetT], **kwargs: object) -> _DatasetT
Convert a dataset into another dataset class.
| PARAMETER | DESCRIPTION |
|---|---|
dataset
|
Source dataset to convert.
TYPE:
|
dataset_cls
|
Target dataset class.
TYPE:
|
**kwargs
|
Extra keyword arguments forwarded to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_DatasetT
|
A dataset instance of type |
Source code in src/omnipy/components/general/tasks.py
import_directory
import_directory(
directory: str | Path,
exclude_prefixes: tuple[str, ...] = (".", "_"),
include_suffixes: tuple[str, ...] = (),
dataset_cls: type[_DatasetT] = Dataset[Model[str]],
open_func: Callable[[str], IOBase] = open,
) -> _DatasetT
Import files from a directory into a dataset keyed by filename stem.
| PARAMETER | DESCRIPTION |
|---|---|
directory
|
Directory to scan for files.
TYPE:
|
exclude_prefixes
|
Filename prefixes to skip.
TYPE:
|
include_suffixes
|
Optional filename suffixes to include.
TYPE:
|
dataset_cls
|
Dataset type to instantiate for the imported content. |
open_func
|
Callable used to open each matching file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_DatasetT
|
A dataset containing one item per imported file. |
Source code in src/omnipy/components/general/tasks.py
split_dataset
split_dataset(
dataset: Dataset[Model[object]], datafile_names_for_b: list[str]
) -> tuple[Dataset[Model[object]], Dataset[Model[object]]]
Split a dataset into two datasets based on selected data-file names.
| PARAMETER | DESCRIPTION |
|---|---|
dataset
|
Dataset to split. |
datafile_names_for_b
|
Names that should be placed in the second output dataset.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Dataset[Model[object]], Dataset[Model[object]]]
|
A tuple containing the remaining items first and the selected items second. |