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
PythonModelContextthat can be used bypredict()when evaluating inputs. When loading an MLflow model withload_model(), this method is called as soon as thePythonModelis constructed.The same
PythonModelContextwill 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
PythonModelContextinstance containing artifacts that the model can use to perform inference.
- predict(context, model_input, params=None)
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
PythonModelContextinstance 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.
Tip
Since MLflow 2.20.0, context parameter can be removed from predict function signature if it’s not used. def predict(self, model_input, params=None) is valid.
- exception kedro_mlflow.mlflow.kedro_pipeline_model.KedroPipelineModelError
Bases:
ExceptionError raised when the KedroPipelineModel construction fails