Upload Model

opensearch_py_ml.ml_commons.MLCommonClient.upload_model(self, model_path: str, model_config_path: str, isVerbose: bool = False, load_model: bool = True, wait_until_loaded: 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

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

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

  • wait_until_loaded (bool) – If load_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

Deprecated since version 2.7.0: Since OpenSearch 2.7.0, you can use register_model instead