Skip to content

Joblib

JoblibParallelBackend(config)

Bases: BaseParallelBackend

Class used to wrap joblib to make it transparent to algorithms.

It shouldn't be initialized directly. You should instead call init_parallel_backend().

PARAMETER DESCRIPTION
config

instance of ParallelConfig with cluster address, number of cpus, etc.

TYPE: ParallelConfig

Source code in src/pydvl/parallel/backends/joblib.py
def __init__(self, config: ParallelConfig):
    self.config = {
        "logging_level": config.logging_level,
        "n_jobs": config.n_cpus_local,
    }

wrap(fun, **kwargs)

Wraps a function as a joblib delayed.

PARAMETER DESCRIPTION
fun

the function to wrap

TYPE: Callable

RETURNS DESCRIPTION
Callable

The delayed function.

Source code in src/pydvl/parallel/backends/joblib.py
def wrap(self, fun: Callable, **kwargs) -> Callable:
    """Wraps a function as a joblib delayed.

    Args:
        fun: the function to wrap

    Returns:
        The delayed function.
    """
    return delayed(fun)  # type: ignore