Skip to content

Runner Function

omnirec.util.run.run_omnirec(datasets: RecSysDataSet[T] | Iterable[RecSysDataSet[T]], plan: ExperimentPlan, evaluator: Evaluator, checkpoint_dir: PathLike | str = DEFAULT_CHECKPOINT_DIR, tmp_dir: Optional[PathLike | str] = None, slurm_script: Optional[PathLike | str] = None)

Run the OmniRec framework with the specified datasets, experiment plan, and evaluator.

Parameters:

Name Type Description Default
datasets RecSysDataSet[T] | Iterable[RecSysDataSet[T]]

The dataset(s) to use for the experiment.

required
plan ExperimentPlan

The experiment plan to follow.

required
evaluator Evaluator

The evaluator to use for the experiment.

required
checkpoint_dir PathLike | str

Directory for persistent experiment progress, predictions, and results. Use the same directory when resuming a run. Defaults to "./checkpoints".

DEFAULT_CHECKPOINT_DIR
tmp_dir Optional[PathLike | str]

Directory for intermediate files. If None, a temporary directory is created and cleaned up automatically. A supplied directory is not automatically cleaned up. Defaults to None.

None
slurm_script Optional[PathLike | str]

Path to a SLURM script used to schedule experiments on an HPC cluster. If not provided, the experiments are run locally in normal mode.

None
Source code in src\omnirec\util\run.py
def run_omnirec(
    datasets: RecSysDataSet[T] | Iterable[RecSysDataSet[T]],
    plan: ExperimentPlan,
    evaluator: Evaluator,  # TODO: Make optional
    checkpoint_dir: PathLike | str = DEFAULT_CHECKPOINT_DIR,
    tmp_dir: Optional[PathLike | str] = None,
    slurm_script: Optional[PathLike | str] = None,
):
    """Run the OmniRec framework with the specified datasets, experiment plan, and evaluator.

    Args:
        datasets (RecSysDataSet[T] | Iterable[RecSysDataSet[T]]): The dataset(s) to use for the experiment.
        plan (ExperimentPlan): The experiment plan to follow.
        evaluator (Evaluator): The evaluator to use for the experiment.
        checkpoint_dir (PathLike | str, optional): Directory for persistent experiment
            progress, predictions, and results. Use the same directory when resuming
            a run. Defaults to "./checkpoints".
        tmp_dir (Optional[PathLike | str], optional): Directory for intermediate files.
            If None, a temporary directory is created and cleaned up automatically.
            A supplied directory is not automatically cleaned up. Defaults to None.
        slurm_script (Optional[PathLike | str]): Path to a SLURM script used to schedule experiments
            on an HPC cluster. If not provided, the experiments are run locally in normal mode.
    """
    if slurm_script is not None:
        # TODO:
        raise NotImplementedError()

    c = Coordinator(checkpoint_dir, tmp_dir)
    c.run(datasets, plan, evaluator)

    for table in evaluator.get_tables():
        console = Console()
        console.print(table)