44 KiB
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}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
service_id |
Yes |
String |
Service ID |
Request Body
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
description |
No |
String |
Service description, which contains a maximum of 100 characters. If this parameter is not set, the service description is not updated. |
status |
No |
String |
Service status. The value can be running or stopped. If this parameter is not set, the service status is not changed. status and config cannot be modified at the same time. If both parameters exist, modify only the status parameter. |
config |
No |
config array corresponding to infer_type |
Service configuration. If this parameter is not set, the service is not updated. The model service is modified and the update_time parameter is returned only for requests with config updated. |
schedule |
No |
schedule array |
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. For details, see Table 5. |
additional_properties |
No |
Map<String, Object> |
Additional service attribute, which facilitates service management |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
model_id |
Yes |
String |
Model ID |
weight |
Yes |
Integer |
Traffic weight allocated to a model. This parameter is mandatory only when infer_type is set to real-time. The sum of the weights must be 100. |
specification |
Yes |
String |
Resource specifications. Select specifications based on service requirements. |
custom_spec |
No |
Object |
Custom specifications. Set this parameter when you use a dedicated resource pool. For details, see Table 6. |
instance_count |
Yes |
Integer |
Number of instances for deploying a model. The value must be greater than 0. |
envs |
No |
Map<String, String> |
(Optional) Environment variable key-value pair required for running a model. By default, this parameter is left blank. To ensure data security, do not enter sensitive information, such as plaintext passwords, in environment variables. |
cluster_id |
No |
string |
ID of a dedicated resource pool. By default, this parameter is left blank, indicating that no dedicated resource pool is used. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
model_id |
Yes |
String |
Model ID |
specification |
Yes |
String |
Resource flavor. |
instance_count |
Yes |
Integer |
Number of instances for deploying a model. |
envs |
No |
Map<String, String> |
(Optional) Environment variable key-value pair required for running a model. By default, this parameter is left blank. To ensure data security, do not enter sensitive information, such as plaintext passwords, in environment variables. |
src_type |
No |
String |
Data source type. This parameter can be set to 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 a specific manifest file path. You can specify multiple data paths in the manifest file. |
src_path |
Yes |
String |
OBS path of the input data of a batch job |
dest_path |
Yes |
String |
OBS path of the output data of a batch job |
req_uri |
Yes |
String |
Inference API called in a batch job, which is a REST API in the model image. Select an API URI from the model config.json file for inference. If a ModelArts built-in inference image is used, the value of this parameter is /. |
mapping_type |
Yes |
String |
Mapping type of the input data. The value can be file or csv.
|
mapping_rule |
No |
Map |
Mapping between input parameters and CSV data. This parameter is mandatory only when mapping_type is set to csv. Mapping rule: The mapping rule comes from the input parameter (input_params) in the model configuration file config.json. When type is set to string, number, integer, or boolean, you are required to configure the index parameter. For details, see . The index must be a positive integer starting from 0. If the index value does not comply with the rule, this parameter will be ignored in the request. After the mapping rule is configured, the CSV data must be separated by commas (,). |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
type |
Yes |
String |
Scheduling type. Only the value stop is supported. |
time_unit |
Yes |
String |
Scheduling time unit. Possible values are DAYS, HOURS, and MINUTES. |
duration |
Yes |
Integer |
Value that maps to the time unit. For example, if the task stops after two hours, set time_unit to HOURS and duration to 2. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
cpu |
Yes |
Float |
Number of required CPUs |
memory |
Yes |
Integer |
Required memory capacity, in MB |
gpu_p4 |
No |
Float |
Number of GPUs, which can be decimals. This parameter is optional. By default, it is not used. |
Response Body
None
Samples
The following shows how to update a real-time service.
- Sample request
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 }] }
- Sample response
{}
Status Code
For details about the status code, see Table 1.
Error Codes
See Error Codes.