Querying the Service List¶
You can use the API to obtain the service list of a user.
Sample Code¶
In the ModelArts notebook instance, you do not need to enter authentication parameters for session authentication. For details about session authentication of other development environments, see Session Authentication.
Scenario 1: Query all services of a user.
from modelarts.session import Session from modelarts.model import Predictor session = Session() predictor_list = Predictor.get_service_list(session)
Scenario 2: Query a service based on the search criteria.
from modelarts.session import Session from modelarts.model import Predictor session = Session() predictor_list = Predictor.get_service_list(session, service_name="digit", order="asc", offset="0", infer_type="real-time")
Parameter Description¶
Parameter | Mandatory | Type | Description |
---|---|---|---|
session | Yes | Object | Session object. For details about the initialization method, see Session Authentication. |
service_id | No | String | Service ID. By default, the service ID is not filtered. |
service_name | No | String | Service name. By default, the service name is not filtered. |
infer_type | No | String | Inference mode. The value can be real-time or batch. By default, this parameter is left blank. |
offset | No | Integer | Start page of the paging list. Default value: 0 |
limit | No | Integer | Maximum number of records returned on each page. Default value: 1000 |
service_status | No | String | Service status. By default, the service status is not filtered. The service list can be queried based on the service status. Possible values are as follows:
|
sort_by | No | String | Sorting mode. The value can be publish_at or service_name. Default value: publish_at |
order | No | String | Sorting order. The value can be asc or desc, indicating the ascending or descending order. Default value: desc |
model_id | No | String | Model ID. By default, the model ID is not filtered. |
Parameter | Type | Description |
---|---|---|
total_count | Integer | Total number of services that meet the search criteria when no paging is implemented |
count | Integer | Number of services in the query result. If offset and limit are not set, the values of count and total are the same. |
services | service array | Collection of the queried services |
Parameter | Type | Description |
---|---|---|
service_id | String | Service ID |
service_name | String | Service name |
description | String | Service description |
tenant | String | Tenant to whom a service belongs |
project | String | Project to which a service belongs |
owner | String | User to whom a service belongs |
publish_at | Number | Latest service publishing time, in milliseconds calculated from 1970.1.1 0:0:0 UTC |
infer_type | String | Inference mode. The value can be real-time or batch. |
status | String | Service status. The value can be running, deploying, concerning, failed, stopped, or finished. |
progress | Integer | Deployment progress. This parameter is returned when status is deploying. |
invocation_times | Number | Total number of service calls |
failed_times | Number | Number of failed service calls |
is_shared | Boolean | Whether a service is subscribed |
shared_count | Number | Number of subscriptions |