forked from docs/modelarts
![otcbot[bot]](/assets/img/avatar_default.png)
Changes to ma_api from doc-exports#1 This is an automatically created Pull Request for changes to ma_api in opentelekomcloud-docs/doc-exports#1. Please do not edit it manually, since update to the original PR will overwrite local changes. Original patch file, as well as complete rst archive, can be found in the artifacts of the opentelekomcloud-docs/doc-exports#1 Reviewed-by: Vineet Pruthi <None>
162 lines
26 KiB
ReStructuredText
162 lines
26 KiB
ReStructuredText
:original_name: modelarts_03_0086.html
|
|
|
|
.. _modelarts_03_0086:
|
|
|
|
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}
|
|
|
|
:ref:`Table 1 <modelarts_03_0086__en-us_topic_0130045990_table10624434011>` describes the required parameters.
|
|
|
|
.. _modelarts_03_0086__en-us_topic_0130045990_table10624434011:
|
|
|
|
.. table:: **Table 1** Parameters
|
|
|
|
+------------+-----------+--------+-----------------------------------------------------------------------------------------------------------------------------+
|
|
| Parameter | Mandatory | Type | Description |
|
|
+============+===========+========+=============================================================================================================================+
|
|
| project_id | Yes | String | Project ID. For details about how to obtain the project ID, see :ref:`Obtaining a Project ID and Name <modelarts_03_0147>`. |
|
|
+------------+-----------+--------+-----------------------------------------------------------------------------------------------------------------------------+
|
|
| service_id | Yes | String | Service ID |
|
|
+------------+-----------+--------+-----------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Request Body
|
|
------------
|
|
|
|
:ref:`Table 2 <modelarts_03_0086__en-us_topic_0130045990_table188019141442>` describes the request parameters.
|
|
|
|
.. _modelarts_03_0086__en-us_topic_0130045990_table188019141442:
|
|
|
|
.. table:: **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. |
|
|
+-----------------------+-----------+--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| 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 :ref:`Table 5 <modelarts_03_0086__en-us_topic_0130045990_table1892915349285>`. |
|
|
+-----------------------+-----------+--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| additional_properties | No | Map<String, Object> | Additional service attribute, which facilitates service management |
|
|
+-----------------------+-----------+--------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. table:: **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 | **custom_spec** structure | Custom specifications. Set this parameter when you use a dedicated resource pool. For details, see :ref:`Table 6 <modelarts_03_0082__en-us_topic_0129882788_table134334512416>`. |
|
|
+-----------------+-----------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| instance_count | Yes | Integer | Number of instances deployed in 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:: **Table 4** **config** parameters of **batch**
|
|
|
|
+-----------------+-----------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| Parameter | Mandatory | Type | Description |
|
|
+=================+=================+=====================+===========================================================================================================================================================================================================================================================================================================================================+
|
|
| model_id | Yes | String | Model ID |
|
|
+-----------------+-----------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| specification | Yes | String | Resource flavor. Available options: **modelarts.vm.cpu.2u** and **modelarts.vm.gpu.p4** |
|
|
+-----------------+-----------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| instance_count | Yes | Integer | Number of instances deployed in 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 task, 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** needs to 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 need to configure the index parameter. For details, see . |
|
|
| | | | |
|
|
| | | | The index must be a positive integer starting from 0. If the value of index does not comply with the rule, this parameter is ignored in the request. After the mapping rule is configured, the corresponding CSV data must be separated by commas (,). |
|
|
+-----------------+-----------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. _modelarts_03_0086__en-us_topic_0130045990_table1892915349285:
|
|
|
|
.. table:: **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**. |
|
|
+-----------+-----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Response Body
|
|
-------------
|
|
|
|
None
|
|
|
|
Samples
|
|
-------
|
|
|
|
The following shows how to update a real-time service.
|
|
|
|
- Sample request
|
|
|
|
.. code-block:: text
|
|
|
|
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
|
|
|
|
.. code-block::
|
|
|
|
{}
|
|
|
|
Status Code
|
|
-----------
|
|
|
|
For details about the status code, see :ref:`Table 1 <modelarts_03_0094__en-us_topic_0132773864_table1450010510213>`.
|