modelarts-umn/api-ref/source/service_management/updating_service_configurations.rst
proposalbot 0184ffbc66 Changes to ma_api from docs/doc-exports#27
Reviewed-by: Jiang, Beibei <beibei.jiang@t-systems.com>
Co-authored-by: proposalbot <proposalbot@otc-service.com>
Co-committed-by: proposalbot <proposalbot@otc-service.com>
2022-08-22 15:13:12 +00:00

28 KiB

original_name

modelarts_03_0086.html

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 <modelarts_03_0086__en-us_topic_0130045990_table10624434011> describes the required parameters.

Table 1 Parameters
Parameter Mandatory Type Description
project_id Yes String Project ID. For details about how to obtain the project ID, see Obtaining a Project ID <modelarts_03_0147>.
service_id Yes String Service ID

Request Body

Table 2 <modelarts_03_0086__en-us_topic_0130045990_table188019141442> describes the request parameters.

Table 2 Parameters
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.

  • If infer_type is set to real-time, see Table 3 <modelarts_03_0086__en-us_topic_0130045990_table6841887256>.
  • If infer_type is set to batch, see Table 4 <modelarts_03_0086__en-us_topic_0130045990_table6420928063>.
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 <modelarts_03_0086__en-us_topic_0130045990_table1892915349285>.
additional_properties No Map<String, Object> Additional service attribute, which facilitates service management
Table 3 config parameters of real-time
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 <modelarts_03_0082__en-us_topic_0129882788_table134334512416>.
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.
Table 4 config parameters of batch
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.

  • If you select file, each inference request corresponds to a file in the input data path. When this mode is used, req_uri of this model can have only one input parameter and the type of this parameter is file.
  • If you select csv, each inference request corresponds to a row of data in the CSV file. When this mode is used, the files in the input data path can only be in CSV format and mapping_rule must be configured to map the index of each parameter in the inference request body to the CSV file.
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 (,).

Table 5 schedule parameters
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.
Table 6 custom_spec parameters
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 <modelarts_03_0094__en-us_topic_0132773864_table1450010510213>.

Error Codes

See Error Codes <modelarts_03_0095>.