Custom Mlflow Models

class kedro_mlflow.mlflow.kedro_pipeline_model.KedroPipelineModel(pipeline_ml: kedro_mlflow.pipeline.pipeline_ml.PipelineML, catalog: kedro.io.data_catalog.DataCatalog, runner: Optional[kedro.runner.runner.AbstractRunner] = None, copy_mode: Optional[Union[Dict[str, str], str]] = None)

Bases: mlflow.pyfunc.model.PythonModel

__init__(pipeline_ml: kedro_mlflow.pipeline.pipeline_ml.PipelineML, catalog: kedro.io.data_catalog.DataCatalog, runner: Optional[kedro.runner.runner.AbstractRunner] = None, copy_mode: Optional[Union[Dict[str, str], str]] = None)

[summary]

Parameters
  • pipeline_ml (PipelineML) – A PipelineML object to

  • Model (store as a Mlflow) –

  • 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
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_pyfunc(), 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.