Skip to content

dataset

load_task_from_disk(path)

Loads a task from disk.

Parameters:

Name Type Description Default
path Path

The path to the task.

required

Returns:

Name Type Description
Task Task

The task.

Source code in src/distilabel/utils/dataset.py
def load_task_from_disk(path: Path) -> "Task":
    """Loads a task from disk.

    Args:
        path: The path to the task.

    Returns:
        Task: The task.
    """
    task_path = path / "task.pkl"
    if not task_path.exists():
        raise FileNotFoundError(f"The task file does not exist: {task_path}")
    with open(task_path, "rb") as f:
        task = pickle.loads(f.read())
    return task

save_task_to_disk(path, task)

Saves a task to disk.

Parameters:

Name Type Description Default
path Path

The path to the task.

required
task Task

The task.

required
Source code in src/distilabel/utils/dataset.py
def save_task_to_disk(path: Path, task: "Task") -> None:
    """Saves a task to disk.

    Args:
        path: The path to the task.
        task: The task.
    """
    task_path = path / TASK_FILE_NAME
    with open(task_path, "wb") as f:
        f.write(pickle.dumps(task))