Custom Mlflow Models
- class kedro_mlflow.mlflow.kedro_pipeline_model.KedroPipelineModel(pipeline: Pipeline, catalog: DataCatalog, input_name: str, runner: AbstractRunner | None = None, copy_mode: Dict[str, str] | str | None = 'assign')
Bases:
PythonModel
- __init__(pipeline: Pipeline, catalog: DataCatalog, input_name: str, runner: AbstractRunner | None = None, copy_mode: Dict[str, str] | str | None = 'assign')
[summary]
- Parameters:
pipeline (Pipeline) – A Kedro Pipeline object to
objects. (store as a Mlflow Model. Also works with kedro_mlflow PipelineML)
catalog (The copy_mode of each DataSet of the) – The DataCatalog associated
PipelineMl (to the)
runner (Optional[AbstractRunner], optional) – The kedro
if (AbstractRunner to use. Defaults to SequentialRunner)
None.
copy_mode (Optional[Union[Dict[str,str], str]])
catalog
memory. (when reconstructing the DataCatalog in)
"assign". (The default is)
either (You can pass) –
None to use Kedro default mode for each dataset
a single string (“deepcopy”, “copy” and “assign”)
to apply to all datasets - a dictionary with (dataset name, copy_mode) key/values pairs. The associated mode must be a valid kedro mode (“deepcopy”, “copy” and “assign”) for each. Defaults to None.
- property copy_mode
- extract_pipeline_artifacts(parameters_saving_folder: Path | None = None)
- load_context(context)
Loads artifacts from the specified
PythonModelContext
that can be used bypredict()
when evaluating inputs. When loading an MLflow model withload_model()
, this method is called as soon as thePythonModel
is constructed.The same
PythonModelContext
will also be available during calls topredict()
, but it may be more efficient to override this method and load artifacts from the context at model load time.- Parameters:
context – A
PythonModelContext
instance containing artifacts that the model can use to perform inference.
- predict(context, model_input)
Evaluates a pyfunc-compatible input and produces a pyfunc-compatible output. For more information about the pyfunc input/output API, see the pyfunc-inference-api.
- Parameters:
context – A
PythonModelContext
instance containing artifacts that the model can use to perform inference.model_input – A pyfunc-compatible input for the model to evaluate.
params –
Additional parameters to pass to the model for inference.
Note
Experimental: This parameter may change or be removed in a future release without warning.
- exception kedro_mlflow.mlflow.kedro_pipeline_model.KedroPipelineModelError
Bases:
Exception
Error raised when the KedroPipelineModel construction fails