Register Model

opensearch_py_ml.ml_commons.MLCommonClient.register_model(self, model_path: str, model_config_path: str, model_group_id: str = '', isVerbose: bool = False, deploy_model: bool = True, wait_until_deployed: bool = True) str

This method registers the model in the opensearch cluster using ml-common plugin’s api. First, this method creates a model id to store model metadata and then breaks the model zip file into multiple chunks and then upload chunks into opensearch cluster

Parameters:
  • model_path (string) – path of the zip file of the model

  • model_config_path (string) –

    filepath of the model metadata. A json file of model metadata is expected Model metadata format example: {

    ”name”: “all-MiniLM-L6-v2”, “version”: 1, “model_format”: “TORCH_SCRIPT”, “model_config”: {

    ”model_type”: “bert”, “embedding_dimension”: 384, “framework_type”: “sentence_transformers”,

    },

    }

    refer to: https://opensearch.org/docs/latest/ml-commons-plugin/model-serving-framework/#upload-model-to-opensearch

  • model_group_id (string) – Model group id

  • isVerbose (boolean) – if isVerbose is true method will print more messages. default False

  • deploy_model (bool) – Whether to deploy the model using uploaded model chunks

  • wait_until_deployed (bool) – If deploy_model is true, whether to wait until the model is deployed

Returns:

returns the model_id so that we can use this for further operation.

Return type:

string