Help Center/ ModelArts/ API Reference/ Service Management/ Updating Service Configurations
Updated on 2024-06-13 GMT+08:00

Updating Service Configurations

Function

This API is used to update configurations of a model service. It can also be used to start or stop a service.

URI

PUT /v1/{project_id}/services/{service_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID and Name.

service_id

Yes

String

Service ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token. It can be obtained by calling the IAM API that is used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

schedule

No

Array of Schedule objects

Service scheduling configuration, which can be configured only for real-time services. By default, this parameter is not used. Services run for a long time.

description

No

String

Service description, which contains a maximum of 100 characters and cannot contain the following characters: <>=&"'. If this parameter is not set, no update is performed.

config

No

Array of ServiceConfig objects

Service configuration. If this parameter is not configured, the service is not updated.

status

No

String

Service status, which can be running or stopped. If this parameter is not configured, the service status is not changed. Either status or config can be modified. If both of them are used, modify status only.

additional_properties

No

Map<String,ServiceAdditionalProperties>

Additional service attribute, which facilitates service management

Table 4 Schedule

Parameter

Mandatory

Type

Description

duration

Yes

Integer

Value mapping a time unit. For example, if the task stops after two hours, set time_unit to HOURS and duration to 2.

time_unit

Yes

String

Scheduling time unit. Possible values are DAYS, HOURS, and MINUTES.

type

Yes

String

Scheduling type. Only the value stop is supported.

Table 5 ServiceConfig

Parameter

Mandatory

Type

Description

custom_spec

No

CustomSpec object

Custom resource specifications

envs

No

Map<String,String>

Common parameter. (Optional) Environment variable key-value pair required for running a model. By default, this parameter is left blank.

specification

Yes

String

Common parameters Resource specifications. You can obtain the specification list by querying the supported service deployment specifications. In the current version, modelarts.vm.cpu.2u/modelarts.vm.gpu.p4 (needs to be applied for), modelsarts.vm.ai1.a310 (needs to be applied for), and custom (supported only when deployed in a dedicated resource pool) are available. [Submit a service ticket.] (tag: hc, hk) ModelArts O&M engineers add permissions. If this parameter is set to custom, the custom_spec parameter must be specified.

weight

No

Integer

This parameter is mandatory for real-time. Weight of traffic allocated to a model. This parameter is mandatory only when infer_type is set to real-time. The sum of all weights must be equal to 100. If multiple model versions are configured with different traffic weights in a real-time service, ModelArts will continuously access the prediction API of the service and forward prediction requests to the model instances of the corresponding versions based on the weights.

deploy_timeout_in_seconds

No

Integer

Timeout interval for deploying a single model instance

model_id

Yes

String

Common parameters Model ID. You can obtain the value by calling the API for querying the AI application list.

src_path

No

String

Mandatory for batch services. OBS path to the input data of a batch job

req_uri

No

String

Mandatory for batch services. Inference API called in a batch task, which is the RESTful API exposed in the model image. You must select an API URL from the config.json file of the model for inference. If a built-in inference image of ModelArts is used, the API is displayed as /.

mapping_type

No

String

The batch service type is mandatory. Mapping type of the input data. The value can be file or csv.

  • If file is selected, each inference request corresponds to a file in the input data directory. When this mode is used, req_uri corresponding to the model can have only one input parameter and the parameter type is file.

  • If csv is selected, each inference request corresponds to a row of data in the CSV file. If this mode is used, the file name extension in the input data directory must be .csv, and the mapping_rule parameter must be configured to indicate the CSV index corresponding to each parameter in the inference request body.

cluster_id

No

String

Optional for real-time services. ID of a dedicated resource pool. This parameter is left blank by default, indicating that no dedicated resource pool is used. When using a dedicated resource pool to deploy services, ensure that the resource pool is running properly. After this parameter is configured, the network configuration of the cluster is used, and the vpc_id parameter does not take effect.

pool_name

No

String

Specifies the ID of the new dedicated resource pool. By default, this parameter is left blank, indicating that the dedicated resource pool is not used. This parameter corresponds to the ID of the new resource pool. When using dedicated resource pool to deploy services, ensure that the cluster status is normal. If pool_name in real-time config and pool_name in real-time config are configured at the same time, pool_name in real-time config is preferred.

nodes

No

Array of strings

Mandatory for edge services. Edge node ID array. The node ID is the edge node ID on IEF, which can be obtained after the edge node is created on IEF.

mapping_rule

No

Object

Optional for batch services. Mapping between input parameters and CSV data. This parameter is mandatory only when mapping_type is set to csv. The mapping rule is similar to the definition of the input parameters in the config.json file. You only need to configure the index parameters under each parameter of the string, number, integer, or boolean type, and specify the value of this parameter to the values of the index parameters in the CSV file to send an inference request. Use commas (,) to separate multiple pieces of CSV data. The values of the index parameters start from 0. If the value of the index parameter is -1, ignore this parameter. For details, see the sample of creating a batch service.

src_type

No

String

Mandatory for batch services. Data source type, which can be ManifestFile. By default, this parameter is left blank, indicating that only files in the src_path directory are read. If this parameter is set to ManifestFile, src_path must be set to a specific manifest path. Multiple data paths can be specified in the manifest file. For details, see the manifest inference specifications.

dest_path

No

String

Mandatory for batch services. OBS path to the output data of a batch job

instance_count

Yes

Integer

Common parameter. Number of instances deployed for a model. The maximum number of instances is 5. To use more instances, submit a service ticket.

additional_properties

No

Map<String,ModelAdditionalProperties>

Additional attributes for model deployment, facilitating service instance management

Table 6 CustomSpec

Parameter

Mandatory

Type

Description

gpu_p4

No

Float

Number of GPUs, which can be a decimal. The value cannot be smaller than 0, with the third decimal place is rounded off. This parameter is optional and is not used by default.

memory

Yes

Integer

Memory in MB, which must be an integer

cpu

Yes

Float

Number of CPU cores, which can be a decimal. The value cannot be smaller than 0.01, with the third decimal place is rounded off.

ascend_a310

No

Integer

Number of Ascend chips. This parameter is optional and is not used by default. Either this parameter or gpu_p4 is configured.

Table 7 ModelAdditionalProperties

Parameter

Mandatory

Type

Description

log_volume

No

Array of log_volume objects

Host directory mounting. This parameter takes effect only if a dedicated resource pool is used. If a public resource pool is used to deploy services, this parameter cannot be configured. Otherwise, an error will occur.

max_surge

No

Float

The value must be greater than 0. If this parameter is not set, the default value 1 is used. If the value is less than 1, it indicates the percentage of instances to be added during the rolling upgrade. If the value is greater than 1, it indicates the maximum number of instances to be added during the rolling upgrade.

max_unavailable

No

Float

The value must be greater than 0. If this parameter is not set, the default value 0 is used. If the value is less than 1, it indicates the percentage of instances that can be scaled in during the rolling upgrade. If the value is greater than 1, it indicates the number of instances that can be scaled in during the rolling upgrade.

termination_grace_period_seconds

No

Integer

Graceful stop time of a container

persistent_volumes

No

Array of persistent_volumes objects

Persistent Storage Mounting Configuration

Table 8 log_volume

Parameter

Mandatory

Type

Description

host_path

Yes

String

Log path to be mapped on the host

mount_path

Yes

String

Path to the logs in the container

Table 9 persistent_volumes

Parameter

Mandatory

Type

Description

name

No

String

Specifies the name of the storage volume.

mount_path

Yes

String

Mount path of the storage volume in the container.

Table 10 ServiceAdditionalProperties

Parameter

Mandatory

Type

Description

smn_notification

Yes

Map<String,SmnNotification>

SMN message notification structure, which is used to notify the user of the service status change

log_report_channels

No

Array of LogReportPipeline objects

Log channel group. If this parameter is not specified or the array length is 0, LTS log interconnection is disabled. This function cannot be modified after being enabled.

websocket_upgrade

No

Boolean

Whether the service interface is upgraded to WebSocket. During service deployment, the default value is false. During service configuration update, the default value is the value set last time.

  • false: Do not upgrade to WebSocket.

  • true: Upgrade to WebSocket. This parameter cannot be modified after WebSocket is enabled. WebSocket cannot be enabled together with Traffic Limit.

Table 11 SmnNotification

Parameter

Mandatory

Type

Description

topic_urn

Yes

String

URN of an SMN topic

events

Yes

Array of integers

Event ID. Options:

1: failed 3: running 7: concerning 11: pending

Table 12 LogReportPipeline

Parameter

Mandatory

Type

Description

type

Yes

String

Log channel type. Currently, LTS is supported.

configuration

No

LtsConfiguration object

LTS Log Configuration

Table 13 LtsConfiguration

Parameter

Mandatory

Type

Description

log_group_id

Yes

String

Specifies the LTS log group ID. The value contains 64 characters.

log_stream_id

Yes

String

LTS log stream ID. The value contains 64 characters.

Response Parameters

None

Example Requests

The following shows how to update a real-time service.

PUT https://{endpoint}/v1/{project_id}/services/{service_id}

{
  "description" : "",
  "status" : "running",
  "config" : [ {
    "model_id" : "xxxx",
    "weight" : "100",
    "specification" : "modelarts.vm.cpu.2u",
    "instance_count" : 1
  } ]
}

Example Responses

Status code: 200

Service updated.

{ }

Status Codes

Status Code

Description

200

Service updated.

Error Codes

See Error Codes.