kfp.local

The kfp.local module contains objects for running KFP components locally.

Functions:

init(runner[, pipeline_root, ...])

Initializes a local execution session.

Classes:

SubprocessRunner([use_venv])

Runner that indicates that local tasks should be run in a subprocess.

DockerRunner(**container_run_args)

Runner that indicates that local tasks should be run as a Docker container.

kfp.local.init(runner: SubprocessRunner | DockerRunner, pipeline_root: str = './local_outputs', workspace_root: str | None = None, raise_on_error: bool = True) None[source]

Initializes a local execution session.

Once called, components can be invoked locally outside of a pipeline definition.

Parameters
runner: SubprocessRunner | DockerRunner

The runner to use. Supported runners: kfp.local.SubprocessRunner and kfp.local.DockerRunner.

pipeline_root: str = './local_outputs'

Destination for task outputs.

workspace_root: str | None = None

Directory to use as workspace. If None, a temporary directory will be created.

raise_on_error: bool = True

If True, raises an exception when a local task execution fails. If False, fails gracefully and does not terminate the current program.

class kfp.local.SubprocessRunner(use_venv: bool = True)[source]

Bases: object

Runner that indicates that local tasks should be run in a subprocess.

Parameters
use_venv: bool = True

Whether to run the subprocess in a virtual environment. If True, dependencies will be installed in the virtual environment. If False, dependencies will be installed in the current environment. Using a virtual environment is recommended.

Attributes:

use_venv

use_venv : bool = True
class kfp.local.DockerRunner(**container_run_args)[source]

Bases: object

Runner that indicates that local tasks should be run as a Docker container.

Attributes:

DOCKER_CONTAINER_RUN_ARGS

DOCKER_CONTAINER_RUN_ARGS = {'auto_remove', 'blkio_weight', 'blkio_weight_device', 'cap_add', 'cap_drop', 'cgroup_parent', 'cgroupns', 'command', 'cpu_count', 'cpu_percent', 'cpu_period', 'cpu_quota', 'cpu_rt_period', 'cpu_rt_runtime', 'cpu_shares', 'cpuset_cpus', 'cpuset_mems', 'detach', 'device_cgroup_rules', 'device_read_bps', 'device_read_iops', 'device_requests', 'device_write_bps', 'device_write_iops', 'devices', 'dns', 'dns_opt', 'dns_search', 'domainname', 'entrypoint', 'environment', 'extra_hosts', 'group_add', 'healthcheck', 'hostname', 'image', 'init', 'init_path', 'ipc_mode', 'isolation', 'kernel_memory', 'labels', 'links', 'log_config', 'lxc_conf', 'mac_address', 'mem_limit', 'mem_reservation', 'mem_swappiness', 'memswap_limit', 'mounts', 'name', 'nano_cpus', 'network', 'network_disabled', 'network_mode', 'networking_config', 'oom_kill_disable', 'oom_score_adj', 'pid_mode', 'pids_limit', 'platform', 'ports', 'privileged', 'publish_all_ports', 'read_only', 'remove', 'restart_policy', 'runtime', 'security_opt', 'shm_size', 'stderr', 'stdin_open', 'stdout', 'stop_signal', 'storage_opt', 'stream', 'sysctls', 'tmpfs', 'tty', 'ulimits', 'use_config_proxy', 'user', 'userns_mode', 'uts_mode', 'version', 'volume_driver', 'volumes', 'working_dir'}