caikit.core.model_management.local_job_base

The LocalJobBase is the base class for running training and prediction jobs using either local threads or subprocesses.

model_management:
<job type>:
<job executor name>:

type: LOCAL config:

# How long to retain results retention_duration: <null or str>

Attributes

log

error

Classes

LocalJobBase

LocalJobBase is the base class for running background jobs on a local

Module Contents

caikit.core.model_management.local_job_base.log[source]
caikit.core.model_management.local_job_base.error
class caikit.core.model_management.local_job_base.LocalJobBase(config: aconfig.Config, instance_name: str)[source]

Bases: caikit.core.model_management.job_base.JobBase

LocalJobBase is the base class for running background jobs on a local machine and does not depend on any datastore or backend. Any result is cleared after the defined retention_duration

class LocalJobFuture(future_name: str, module_class: Type[caikit.core.modules.ModuleBase], save_path: str | caikit.interfaces.common.data_model.stream_sources.S3Path | None, save_with_id: bool, future_id: str | None, args: Iterable[Any], kwargs: Dict[str, Any], model_name: str | None = None, use_subprocess: bool = False, extra_path_args: List[str] | None = None, subprocess_start_method: str | None = 'fork')[source]

Bases: caikit.core.model_management.job_base.JobFutureBase

A local job future manages running a job in a thread and tracking its status

_module_class
_completion_time = None
_submission_time
_save_path
_use_subprocess = False
_subprocess_start_method = 'fork'
property save_path: str | None

If created with a save path, the future must expose it, including any injected background id

property completion_time: datetime.datetime | None
abstract run()[source]

Abstract method for starting the job. Needs to be implemented by the trainers and predictors

get_info() caikit.core.model_management.job_base.JobInfo[source]

The local job checks the info by the current thread status

cancel()[source]

Terminate the given job

wait()[source]

Block until the job reaches a terminal state

_delete_result()[source]

Helper function to clear out the result when purging

_make_background_info(status: caikit.core.data_model.JobStatus, errors: List[Exception] | None = None) caikit.core.model_management.job_base.JobInfo[source]
classmethod _save_path_with_id(save_path: str | None, save_with_id: bool, future_id: str, model_name: str | None, extra_path_args: List[str] | None) str | None[source]

If asked to save_with_id, child classes should use this shared utility to construct the final save path

_timedelta_expr
_instance_name
_retention_duration
_futures: Dict[str, LocalJobBase.__init__.self]
_futures_lock
get_local_future(job_id: str) LocalJobFuture[source]

Look up the model future for the given id

_purge_old_futures()[source]

If a retention duration is configured, purge any futures that are older than the policy