Skip to content

MPM SDK

This page provides information for using the Model Production Monitoring (MPM) Python SDK.

For more information on MPM, see Use MPM.

Install MPM SDK

To use the MPM SDK, downoad and install using:

pip install comet-mpm

Methods

CometMPM.__init__

Create the Comet MPM Event logger object.

Arguments

  • api_key: Optional[str] - The Comet API Key, must be passed to the constructor or configured (see Configuration section below).
  • workspace_name: Optional[str] - The Comet Workspace Name of the model, must be passed to the constructor or configured (see Configuration section below).
  • model_name: Optional[str] - The Comet Model Name of the model, must be passed to the constructor or configured (see Configuration section below).
  • model_version: Optional[str] - The Comet Model Name of the model, must be passed to the constructor or configured (see Configuration section below).
  • disabled: Optional[bool] - If set to True, CometMPM will not send anything to the backend.
  • asyncio: bool = False - Set to True if you are using an Asyncio-based framework like FastAPI.

 

CometMPM.log_event

Log a single event asynchronously to MPM. Events are identified by the mandatory prediction_id parameter. You can send multiple events with the same prediction_id, events will be merged on the backend side automatically.

Arguments

  • prediction_id: str - The unique prediction ID, could be provided by the framework, you or a random unique value could be provided like str(uuid4())
  • input_features: Optional[Dict[str, Any]] - If provided must be a flat Dictionary where the keys are the feature name and the value are native Python scalars, int, floats, booleans or strings. For example: {“age”: 42, “income”: 42894.89}
  • output_value: Optional[Any] - The prediction as a native Python scalar, int, float, boolean or string.
  • output_probability: Optional[Any] - If provided, must be a float between 0 and 100 indicating the confidence of the model in the prediction

 

CometMPM.connect

When using CometMPM in asyncio mode, this coroutine needs to be awaited at the server start.

 

CometMPM.join

When using CometMPM in asyncio mode, this coroutine needs to be awaited at the server stop.

Learn more

Jul. 11, 2022