Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page
Help Center/ ModelArts/ SDK Reference/ Service Management/ Updating Service Configurations

Updating Service Configurations

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

You can use the API to update the configurations of a service object.

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: Update the configurations of a service based on the service object created in Deploying a Real-Time Service.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    from modelarts.session import Session
    from modelarts.model import Predictor
    from modelarts.config.model_config import ServiceConfig
    
    session = Session()
    predictor_instance = Predictor(session, service_id="your_service_id")
    configs = [ServiceConfig(weight="100", instance_count=1, specification="modelarts.vm.cpu.2u",model_id="your_model_id")]
    service_config = predictor_instance.update_service_config(description="description",
                                                                  status="running",
                                                                  configs=configs) 
    
  • Method 2: Update the configurations of a service based on the service object returned in Obtaining Service Objects.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    from modelarts.session import Session
    from modelarts.model import Predictor
    from modelarts.config.model_config import ServiceConfig
    
    session = Session()
    predictor_object_list = Predictor.get_service_object_list(session)
    predictor_instance = predictor_object_list[0]                  
    configs = [ServiceConfig(weight="100", instance_count=1, specification="modelarts.vm.cpu.2u",model_id="your_model_id")]
    predictor_config = predictor_instance.update_service_config(description="description",
                                                                    status="running",
                                                                    configs=configs) 
    

Parameters

Table 1 Parameters for deploying predictor

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 configs cannot be modified at the same time. If both parameters exist, modify only the status parameter.

configs

No

predictor configs and transformer configs

Service configurations. If this parameter is not set, the service is not updated. For details about how to generate configs, see Deploying a Real-Time Service.

NOTE:

The restrictions on updating service configurations are as follows:

  • The specified status cannot be the same as the current service status.
  • If the service status is deploying, stopping, or deleting, status cannot be set to running or configs is not allowed to configure.
  • If the service status is waiting, status cannot be set to running.
  • If the service status is concerning, status cannot be set to running.
Table 2 configs parameters of predictor

Parameter

Mandatory

Type

Description

model_id

Yes

String

Model ID. You can obtain the value by calling the API described in Obtaining Models or from the ModelArts management console.

weight

Yes

Integer

Weight of traffic allocated to a model. This parameter is mandatory only when infer_type is set to real-time. The sum of multiple weights must be equal to 100. If multiple model versions are configured in a real-time service and different traffic weights are set, ModelArts continuously accesses the prediction API of the service and forwards prediction requests to the model instances of the corresponding versions based on the weights.

specification

Yes

String

Resource flavor. Currently, modelarts.vm.cpu.2u, modelarts.vm.gpu.p4 (you must apply for it), and modelarts.vm.ai1.a310 (you must apply for it) are available. To use a flavor that requires permission, submit a service ticket on HUAWEI CLOUD and ModelArts O&M engineers will grant you the permission.

instance_count

Yes

Integer

Number of instances deployed in a model. The maximum number of instances is 5. To use more instances, submit a service ticket.

envs

No

Map<String, String>

(Optional) Environment variable key-value pair required for running a model. By default, this parameter is left blank.

Table 3 configs parameters of transformer

Parameter

Mandatory

Type

Description

model_id

Yes

String

Model ID. You can obtain the value by calling the API described in Obtaining Models or from the ModelArts management console.

specification

Yes

String

Resource flavor. Currently, modelarts.vm.cpu.2u and modelarts.vm.gpu.p4 are available.

instance_count

Yes

Integer

Number of instances deployed in a model. The maximum number of instances is 5. To use more instances, submit a service ticket.

envs

No

Map<String, String>

(Optional) Environment variable key-value pair required for running a model. By default, this parameter is left blank.

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 batch tasks. You must select an API URL from the config.json file of the model for inference.

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 a 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. The mapping rule is similar to the definition of the input parameters in the config.json file. You only need to configure the index parameters under each parameter of the string, number, integer, or boolean type, and the value of this parameter to the values of the index parameters in the CSV file to send an inference request. Use commas (,) to separate multiple pieces of CSV data. The values of the index parameters start from 0. If the value of the index parameter is -1, ignore this parameter.

Table 4 update_service_config response parameters

Parameter

Mandatory

Type

Description

error_code

Yes

String

Error code when the API call fails.

This parameter is not included when the API call succeeds.

error_msg

Yes

String

Error message when the API call fails.

This parameter is not included when the API call succeeds.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback