Update calculation instance

Updates the modifiable configuration of a compute instance in the current workspace. Serverless instances do not deploy workers immediately due to configuration updates; workers are activated based on subsequent workload demand.

PUT https://moi.matrixorigin.cn/newmoi/compute-resources/{resource_id}

Preparation before calling

First query the computing instance details and confirm the instance to be updated. Prepare a personal access token with access to the target workspace, the target workspace ID, and the compute instance ID.

The example below uses:

  • $AI_STUDIO_API_KEY: The actual personal access token, passed through the X-API-Key Header.

  • $WORKSPACE_ID: Target workspace ID, passed through X-Workspace-ID Header.

  • $RESOURCE_ID: Compute instance ID to update.

Request example

curl -X PUT "https://moi.matrixorigin.cn/newmoi/compute-resources/$RESOURCE_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "description": "updated",
    "max_replicas": 3,
    "auto_suspend_minutes": 30
  }'

Path parameters

Parameter

Type

Required

Description

resource_id

string

Yes

Compute instance ID.

Request body

Submit only the fields you want to modify.

Field

Type

Required

Description

name

string

No

Instance name.

description

string

No

Example description.

kind

string

No

Compatibility tip.

spec_id

string

No

Compute spec ID.

cpu

integer

No

CPU configuration.

memory_gib

integer

No

Memory GiB configuration.

gpu

integer

No

GPU configuration.

min_replicas

integer

No

Only accepts 0.

max_replicas

integer

No

The upper limit of copies, must be greater than 0.

auto_suspend_minutes

integer

No

Automatic pause waiting time.

worker_images

object[]

No

Worker image selection. Submitting this field must replace the original configuration with the complete list, overwriting all currently active worker_type.

worker_images[].worker_type

string

Conditionally required

Worker type. Required when submitting worker_images.

worker_images[].kind

string

No

Compatible alias; should be consistent with worker_type when passed in.

worker_images[].image_id

string

Conditionally required

Image ID. Required when submitting worker_images.

worker_images[].platform

string

Conditionally required

Image runtime platform. Required when submitting worker_images.

go_worker_image_id

string

No

Compatible Go Worker image ID.

python_worker_image_id

string

No

Compatible Python Worker image ID.

platform

string

No

Compatible operating platform.

In this document, [] after a type means an array; for example, object[] is an array of objects. In field paths, [] means each item in an array; for example, worker_images[].worker_type is the worker_type field of each item in worker_images.

Successful response

When successful, 200 is returned, and data is the updated instance object. The worker will not be deployed immediately after saving successfully.

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": "cr-001",
    "name": "data-processing",
    "description": "updated",
    "spec_id": "task-standard-small",
    "status": "IDLE",
    "status_message": "",
    "min_replicas": 0,
    "max_replicas": 3,
    "current_replicas": 0
  }
}

The response fields are as follows.

Field

Type

Description

code

string

OK on success.

msg

string

OK on success.

data.id

string

Compute instance ID.

data.workspace_id

string

ID of the workspace to which it belongs.

data.name

string

Compute instance name.

data.description

string

Example description; returned when there is a value.

data.spec_id

string

Current computing specification ID.

data.kind

string

Instance type.

data.cpu

integer

CPU configuration value.

data.memory_gib

integer

Configuration value expressed in GiB of memory.

data.gpu

integer

GPU configuration value.

data.cpu_milli

integer

CPU configuration value in millicores.

data.memory_mib

integer

Configuration value expressed in MiB of memory.

data.gpu_count

integer

Number of GPUs.

data.gpu_memory_mib

integer

MiB of video memory for a single GPU.

data.gpu_cores

integer

Number of GPU cores.

data.min_replicas

integer

Serverless instances are fixed to 0.

data.max_replicas

integer

Maximum number of copies.

data.desired_replicas

integer

Number of target copies.

data.current_replicas

integer

The current number of copies.

data.go_worker_image_id

string

Go Worker image ID; returned if there is a value.

data.python_worker_image_id

string

Python Worker image ID; returned if there is a value.

data.worker_images

object[]

Worker image selection; returned when there is a value.

data.worker_images[].worker_type

string

Worker type.

data.worker_images[].image_id

string

Image ID.

data.worker_images[].platform

string

Running platform.

data.platform

string

Instance running platform; returned if there is a value.

data.auto_suspend_minutes

integer

Automatic pause waiting time.

data.is_default

boolean

Whether it is the default computing instance of the workspace.

data.status

string

The updated current life cycle status.

data.status_message

string

Supplementary status information; returned if there is a value.

data.scale_reason

string

The scaling reason provided by the server; returned if there is a value.

data.last_activation_at

string

Last activation time; returned if there is a value.

data.last_active_at

string

Last active time; returned if there is a value.

data.created_by

string

Creator ID; returned if there is a value.

data.created_at

string

Creation time; returned if there is a value.

data.updated_at

string

Last updated time; returned if there is a value.

Error response

{
  "code": "UPDATE_FAILED",
  "msg": "服务器内部错误",
  "data": null
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

INVALID_PARAMS

The request body cannot be parsed or the field combination is invalid.

Check field types, specifications and copy ranges.

401

Missing or invalid access credentials.

Check API Key and Workspace Header.

403

ErrForbidden

The current identity does not have instance update permission.

Requesting permission to compute_resource.update.

404

NOT_FOUND

The instance does not exist or does not belong to the current workspace.

Check resource_id and workspace.

409

COMPUTE_RESOURCE_NAME_EXISTS

The new name conflicts with an existing instance in the workspace.

Modify name and try again.

500

UPDATE_FAILED

The server failed to update the instance.

Try again later.

Follow-up operations

Query calculation instance details or Query Worker runtime to confirm the change progress.

Last updated on