Commands

Contains a few more sophisticated commands that are usually accessed directly inside configs.

dpipe.commands.populate(path: Union[Path, str], func: Callable, *args, **kwargs)[source]

Call func with args and kwargs if path doesn’t exist.

Examples

>>> populate('metrics.json', save_metrics, targets, predictions)
# if `metrics.json` doesn't exist, the following call will be performed:
>>> save_metrics(targets, predictions)
Raises

FileNotFoundError – if after calling func the path still doesn’t exist.:

dpipe.commands.lock_dir(folder: Union[Path, str] = '.', lock: str = '.lock')[source]

Lock the given folder by generating a special lock file - lock.

Raises

FileExistsError – if lock already exists, i.e. the folder is already locked.:

dpipe.commands.transform(input_path, output_path, transform_fn)[source]
dpipe.commands.load_from_folder(path: ~typing.Union[~pathlib.Path, str], loader=<function load>, ext='.npy')[source]

Yields (id, object) pairs loaded from path.

dpipe.commands.map_ids_to_disk(func: ~typing.Callable[str, object], ids: ~typing.Iterable[str], output_path: str, exist_ok: bool = False, save: ~typing.Callable = <function save>, ext: str = '.npy')[source]

Apply func to each id from ids and save each output to output_path using save. If exist_ok is True the existing files will be ignored, otherwise an exception is raised.

dpipe.commands.predict(ids, output_path, load_x, predict_fn, exist_ok=False, save: ~typing.Callable = <function save>, ext='.npy')[source]
dpipe.commands.evaluate_aggregated_metrics(load_y_true, metrics: dict, predictions_path, results_path, exist_ok=False, loader: ~typing.Callable = <function load>, ext='.npy')[source]
dpipe.commands.evaluate_individual_metrics(load_y_true, metrics: dict, predictions_path, results_path, exist_ok=False, loader: ~typing.Callable = <function load>, ext='.npy')[source]