Creates a model service in Elastic Algorithm Service (EAS).
Operation description
**Before you call this operation, make sure that you are familiar with the billing of Elastic Algorithm Service (EAS).
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
eas:CreateService | create | *Service acs:eas:{#regionId}:{#accountId}:service/* |
| none |
Request syntax
POST /api/v2/services HTTP/1.1
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
body | string | No | The request body. For more information about the key request parameters, see Table 1. Request body parameters and Table 2. Metadata parameters. For more information about all related parameters, see Parameters of model services. | Service deployment by using an image: { "name": "foo", "metadata": { "instance": 2, "memory": 7000, "cpu": 4 }, "containers": [ { "image": "****", "script": "**** --listen=0.0.0.0 --server_port=8000 --headless", "port": 8000 } ], "storage": [ { "oss": { "path": "oss://examplebuket/data111/", "readOnly": false }, "properties": { "resource_type": "model" }, "mount_path": "/data" } ] } AI-Web application deployment by using an image: { "name": "foo", "metadata": { "instance": 1, "memory": 7000, "cpu": 4, "enable_webservice": true }, "containers": [ { "image": "****", "script": "**** --listen=0.0.0.0 --server_port=8000 --headless", "port": 8000 } ], "storage": [ { "oss": { "path": "oss://examplebucket/data111/", "readOnly": false }, "properties": { "resource_type": "model" }, "mount_path": "/data" } ] } Service deployment by using models and processors: { "metadata": { "instance": 1, "memory": 7000, "cpu": 4 }, "name": "foo", "model_config": {}, "processor_type": "python", "processor_path": "oss://****", "processor_entry": "a.py", "model_path": "oss://****" } |
Develop | string | No | Specifies whether to enter development mode. Valid values:
| true |
Labels | object | No | The custom label. | |
string | No | The label. | {"key":"value"} | |
WorkspaceId | string | No | The workspace ID. | 123456 |
Table 1. Request body parameters
Parameter | Type | Required | Description |
---|---|---|---|
name | String | Yes | The service name, which must be unique in a region. |
token | String | No | The token for authentication. If you do not specify a token and generate_token is set to true, the token is automatically generated. |
model_path | String | No | The path of the model file. You can specify an HTTP address or an Object Storage Service (OSS) path. If you specify an HTTP address, the HTTP address must be publicly accessible. If you specify an OSS path, the path can be a directory or file name. If you specify a .tar.gz , .tar.bz2 , or .zip file, the system automatically decompresses the file. |
role_arn | string | No | If you set model_path or processor_path to an OSS address, you need to specify the role_arn parameter to access OSS and the Role_ARN parameter to obtain the role_arn. |
oss_endpoint | String | No | The endpoint of the OSS bucket. If you set model_path or processor_path to an OSS path, you must specify this parameter. |
model_entry | String | No | The primary file of the model. Any file can be specified as the primary file of the model. If no file is specified, the file specified by model_path is used as the primary file of the model. The path of the primary file is delivered to the Load() function in the processor. |
processor_path | String | Yes | The path of the processor file. You can specify a local file or an HTTP address. If you specify a .tar.gz , .tar.bz2 , or .zip file, the system automatically decompresses the file. |
processor_entry | String | No | If you set processor_type to C, C++, or Python, this parameter is required. The main file of the processor. The main file contains the implementations of the Load() and Process() functions that are required for prediction. |
processor_mainclass | String | No | If you set processor_type to Java, this parameter is required. The main class in the JAR package of the processor. |
processor_type | String | Yes | The language that is used to implement the processor. Valid values: C, C++, Java, and Python. |
metadata | Dict | No | The metadata of the service. For more information, see Table 2. |
cloud | Dict | No | The map key. This parameter is required only if you specify an instance type to deploy the service. You must specify this parameter in the following format: "cloud":{"computing":{"instance_type": "ecs.gxxxxxx.large"}} . |
containers | List | No | The method of container deployment that is implemented by using custom images. If the container that is deployed by using the processor cannot meet your requirements, you can deploy the container by using custom images. For more information, see Deploy a model service by using a custom image. |
Description The model_path parameter and the processor_path parameter specify the sources of the model input and the processor input. You can set the paths to HTTP addresses or OSS paths. When you use the test command to debug the model on your on-premises machine, you can set the parameters to local files and directories.
- If you use an HTTP address, you must compress the relevant files into .tar.gz, .tar.bz2, or .zip files. Then, you can upload the files to OSS to generate an HTTP address.
- If you use an OSS path, you can enter a directory or file name as the path.
Table 2. Metadata parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
instance | Int | No | The number of workers that are required to start the service. | 1 |
cpu | Int | No | The number of CPUs that are required by each worker. | 1 |
gpu | Int | No | The number of GPUs that are required by each worker. | 0 |
memory | Int | No | The memory size that is required by each worker. Unit: MB. | 1000 |
resource | String | No | The resource group to which the service belongs. | eas-r-aaabbbccc |
rpc.worker_threads | Int | No | The number of threads that are used to concurrently process requests in each instance. | 5 |
rpc.max_queue_size | Int | No | The maximum size of a queue for processing requests. If the queue is full, new requests are dropped and an HTTP 450 status code is returned. | 64 |
rpc.keepalive | Int | No | The timeout period of the request. Unit: milliseconds. | 5000 |
rpc.rate_limit | Int | No | The queries per second (QPS) value that triggers request throttling for a single instance. If the QPS is exceeded, new requests are dropped and an HTTP 429 status code is returned. | 0 |
release | Bool | No | Specifies whether to create a service for canary release. Valid values: true and false. If you set this parameter to true, you must create a service for canary release. | false |
Response parameters
Examples
Sample success responses
JSON
format
{
"RequestId": "40325405-579C-4D82****",
"ServiceId": "eas-m-aaxxxddf",
"ServiceName": "yourname",
"Status": "Creating",
"Region": "cn-shanghai",
"InternetEndpoint": "http://pai-eas.vpc.cn-shanghai.****",
"IntranetEndpoint": "http://pai-eas.cn-shanghai.****"
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2023-09-01 | The request parameters of the API has changed | View Change Details |
2023-01-04 | The request parameters of the API has changed | View Change Details |