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

Table 1 Query parameters

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:

  • running: The service is running properly and is being billed.

  • deploying: The service is being deployed or scheduling resources are being deployed.

  • concerning: An alarm is generated, indicating that the backend instance is abnormal and may be billed. For example, in the case of multiple instances, some instances are normal, but some are not. A normal instance is billed but is in the concerning status.

  • failed: The service fails to be deployed. For details about the failure cause, see the event and log.

  • stopped: The service has been stopped.

  • finished: This status is displayed only for the batch service, indicating that the service running is completed.

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.

Table 2 get_service_list response parameters

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

Table 3 service parameters

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