Updated on 2024-03-21 GMT+08:00

Delete a Service

You can delete a service in either of the following ways:

Sample Code

In ModelArts notebook, you do not need to enter authentication parameters for session authentication. For details about session authentication of other development environments, see Session Authentication.

  • Method 1: Delete a service based on the service object created in Deploying a Real-Time Service.
    1
    2
    3
    4
    5
    6
    from modelarts.session import Session
    from modelarts.model import Predictor
    
    session = Session()
    predictor_instance = Predictor(session, service_id="your_service_id")
    predictor_instance.delete_service()
    
  • Method 2: Delete a service based on the service object returned in Obtaining Service Objects.
    1
    2
    3
    4
    5
    6
    7
    from modelarts.session import Session
    from modelarts.model import Predictor
    
    session = Session()
    predictor_object_list = Predictor.get_service_object_list(session)
    predictor_instance = predictor_object_list[0]                
    predictor_instance.delete_service()