caikit.core.model_management.local_model_trainer
The LocalModelTrainer uses a local thread to launch and manage each training job
- model_management:
- trainers:
- <predictor name>:
type: LOCAL config:
# ! Inherits config from LocalJobBase # Whether to train in a subprocess or different thread use_subprocess: <bool: False> # Type of subprocess to use if use_subprocess=True subprocess_start_method: <string: spawn>
Attributes
Classes
LocalJobBase is the base class for running background jobs on a local |
|
This class wraps up a model to make it safe to pass to a spawned |
Module Contents
- caikit.core.model_management.local_model_trainer.error
- class caikit.core.model_management.local_model_trainer.LocalModelTrainer(config: aconfig.Config, instance_name: str)[source]
Bases:
caikit.core.model_management.local_job_base.LocalJobBase,caikit.core.model_management.model_trainer_base.ModelTrainerBaseLocalJobBase 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
- __doc__ = Multiline-String
Show Value
""" The LocalModelTrainer uses a local thread to launch and manage each training job model_management: trainers: <predictor name>: type: LOCAL config: # ! Inherits config from LocalJobBase # Whether to train in a subprocess or different thread use_subprocess: <bool: False> # Type of subprocess to use if use_subprocess=True subprocess_start_method: <string: spawn> """
- class LocalModelTrainFuture(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.local_job_base.LocalJobBase.LocalJobFuture,caikit.core.model_management.model_trainer_base.ModelTrainerFutureBaseLocalModelTrainFuture takes a module class and training request and runs it in a thread or subprocess
- load() caikit.core.modules.ModuleBase[source]
Wait for the training to complete, then return the resulting model or raise any errors that happened during training.
- LocalModelFuture
- name = 'LOCAL'
This is the name of this constructible type that will be used by the factory to identify this class
- _use_subprocess
- _subprocess_start_method
- train(module_class: Type[caikit.core.modules.ModuleBase], *args, save_path: str | None = None, save_with_id: bool = False, external_training_id: str | None = None, model_name: str | None = None, **kwargs) LocalModelFuture[source]
Start training the given module and return a future to the trained model instance
- class caikit.core.model_management.local_model_trainer._SpawnProcessModelWrapper(model: caikit.core.modules.ModuleBase)[source]
Bases:
caikit.core.modules.ModuleBaseThis class wraps up a model to make it safe to pass to a spawned subprocess. It will not be efficient, but it will be safe!
- _model
- __getattr__(name)[source]
Forward attributes that are not found on the base class to the model
- NOTE: This does _not_ forward base class attributes since those are
resolved before __getattr__ is called.
- save(*args, **kwargs)[source]
Directly forward save to the model so that it is not called by the base class
- run(*args, **kwargs)[source]
Directly forward run to the model so that it is not called by the base class