Custom Mlflow Models

class kedro_mlflow.mlflow.kedro_pipeline_model.KedroPipelineModel(pipeline: Pipeline, catalog: DataCatalog, input_name: str, runner: Optional[AbstractRunner] = None, copy_mode: Optional[Union[Dict[str, str], str]] = None)

Bases: PythonModel

__init__(pipeline: Pipeline, catalog: DataCatalog, input_name: str, runner: Optional[AbstractRunner] = None, copy_mode: Optional[Union[Dict[str, str], str]] = None)

[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) –

  • 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 dictionnary 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: Optional[Path] = None)
load_context(context)

Loads artifacts from the specified PythonModelContext that can be used by predict() when evaluating inputs. When loading an MLflow model with load_model(), this method is called as soon as the PythonModel is constructed.

The same PythonModelContext will also be available during calls to predict(), 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.

exception kedro_mlflow.mlflow.kedro_pipeline_model.KedroPipelineModelError

Bases: Exception

Error raised when the KedroPipelineModel construction fails