Undeploy a model

To undeploy a model from memory, use the undeploy operation.

For information about user access for this API, see Model access control considerations.

Path and HTTP methods

  1. POST /_plugins/_ml/models/<model_id>/_undeploy

Example request: Undeploying a model from all ML nodes

  1. POST /_plugins/_ml/models/MGqJhYMBbbh0ushjm8p_/_undeploy

copy

Example request: Undeploying specific models from specific nodes

  1. POST /_plugins/_ml/models/_undeploy
  2. {
  3. "node_ids": ["sv7-3CbwQW-4PiIsDOfLxQ"],
  4. "model_ids": ["KDo2ZYQB-v9VEDwdjkZ4"]
  5. }

copy

Example request: Undeploying specific models from all nodes

  1. {
  2. "model_ids": ["KDo2ZYQB-v9VEDwdjkZ4"]
  3. }

copy

Example response

  1. {
  2. "sv7-3CbwQW-4PiIsDOfLxQ" : {
  3. "stats" : {
  4. "KDo2ZYQB-v9VEDwdjkZ4" : "UNDEPLOYED"
  5. }
  6. }
  7. }

Automatically undeploy a model based on TTL

Starting with OpenSearch 2.14, models can be automatically undeployed from memory based on the predefined time-to-live (TTL) when the model was last accessed or used. To define a TTL that automatically undeploys a model, include the following ModelDeploySetting in your machine learning (ML) model. Note that model TTLs are checked periodically by a syn_up cron job, so the maximum time that a model lives in memory could be TTL + the sync_up_job_ interval. The default cron job interval is 10 seconds. To update the cron job internally, use the following cluster setting:

  1. PUT /_cluster/settings
  2. {
  3. "persistent": {
  4. "plugins.ml_commons.sync_up_job_interval_in_seconds": 10
  5. }
  6. }

Example request: Creating a model with a TTL

  1. POST /_plugins/_ml/models/_register
  2. {
  3. "name": "Sample Model Name",
  4. "function_name": "remote",
  5. "description": "test model",
  6. "connector_id": "-g1nOo8BOaAC5MIJ3_4R",
  7. "deploy_setting": {"model_ttl_minutes": 100}
  8. }

Example request: Updating a model with a TTL when the model is undeployed

  1. PUT /_plugins/_ml/models/COj7K48BZzNMh1sWedLK
  2. {
  3. "deploy_setting": {"model_ttl_minutes" : 100}
  4. }