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
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
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
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
Huawei Cloud Astro Canvas
Huawei Cloud Astro Zero
CodeArts Governance
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 (CCI)
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
Cloud Transformation
Well-Architected Framework
Cloud Adoption Framework
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
Blockchain
Blockchain Service
Web3 Node Engine Service
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Modifying an Algorithm

Updated on 2025-03-14 GMT+08:00

Function

This API is used to modify an algorithm.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

PUT /v2/{project_id}/algorithms/{algorithm_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID and Name.

algorithm_id

Yes

String

Algorithm ID.

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

metadata

No

AlgorithmMetadata object

Algorithm metadata, which describes basic algorithm information.

job_config

No

AlgorithmJobConfig object

Algorithm configuration, such as the boot file.

resource_requirements

No

Array of ResourceRequirement objects

Algorithm resource constraints. This parameter is optional. After this parameter is set, the console filters available public resource pools when the algorithm is used in training jobs.

advanced_config

No

AlgorithmAdvancedConfig object

Advanced algorithm policy:

  • auto_search

Table 3 AlgorithmMetadata

Parameter

Mandatory

Type

Description

id

No

Integer

Algorithm UUID. You do not need to set this parameter when creating an algorithm.

name

Yes

String

Algorithm name. The value must contain 1 to 64 characters consisting of only digits, letters, underscores (_), and hyphens (-).

description

No

String

Algorithm description, which consists of 0 to 256 characters. The default value is NULL.

workspace_id

No

String

Workspace where a specified algorithm is located. The default value is 0, indicating the default workspace.

ai_project

No

String

AI project to which a specified algorithm belongs. The default value is default-ai-project. The AI project has been brought offline. Ignore it.

Table 4 AlgorithmJobConfig

Parameter

Mandatory

Type

Description

code_dir

No

String

Algorithm code directory, for example, /usr/app/. This parameter must be used together with boot_file.

boot_file

No

String

Code boot file of the algorithm, which must be stored in the code directory, for example, /usr/app/boot.py. This parameter must be used with code_dir.

command

No

String

Container boot command of a custom image algorithm.

parameters

No

Array of Parameters objects

Running parameter of an algorithm.

inputs

No

Array of AlgorithmCreateInput objects

Data input of an algorithm.

outputs

No

Array of AlgorithmCreateOutput objects

Data output of an algorithm.

engine

No

AlgorithmCreateEngine object

Algorithm engine.

parameters_customization

No

Boolean

Whether the algorithm allows hyperparameter customization during training job creation.

Table 5 Parameters

Parameter

Mandatory

Type

Description

name

No

String

Parameter name.

value

No

String

Parameter value.

description

No

String

Parameter description.

constraint

No

ParametersConstraint object

Parameter constraint.

i18n_description

No

I18nDescription object

Internationalization description.

Table 6 ParametersConstraint

Parameter

Mandatory

Type

Description

type

No

String

Parameter type.

editable

No

Boolean

Whether the parameter is editable.

required

No

Boolean

Whether the parameter is mandatory.

sensitive

No

Boolean

Whether the parameter is sensitive. This function is not implemented currently.

valid_type

No

String

Valid type.

valid_range

No

Array of strings

Valid range.

Table 7 I18nDescription

Parameter

Mandatory

Type

Description

language

No

String

Internationalization language.

description

No

String

Description.

Table 8 AlgorithmCreateInput

Parameter

Mandatory

Type

Description

name

No

String

Name of the data input channel.

description

No

String

Description of the data input channel.

remote_constraints

No

Array of RemoteConstraint objects

Data input constraint.

Table 9 RemoteConstraint

Parameter

Mandatory

Type

Description

data_type

No

String

Data input type. The data storage location (OBS) and ModelArts dataset are supported.

attributes

No

Array of Map<String,String> objects

Attributes when the data input type is a dataset. Enumerated values:

  • data_format: data format

  • data_segmentation: data segmentation

  • dataset_type: data labeling

Table 10 AlgorithmCreateOutput

Parameter

Mandatory

Type

Description

name

Yes

String

Name of the data output channel.

description

No

String

Description of the data output channel.

Table 11 AlgorithmCreateEngine

Parameter

Mandatory

Type

Description

engine_id

No

String

Engine ID selected for an algorithm.

engine_name

No

String

Engine version name selected for an algorithm. If engine_id is specified, leave this parameter blank.

engine_version

No

String

Engine version name selected for an algorithm. If engine_id is specified, leave this parameter blank.

image_url

No

String

Custom image URL selected for an algorithm.

Table 12 ResourceRequirement

Parameter

Mandatory

Type

Description

key

No

String

Resource constraint. The options are as follows:

  • flavor_type: flavor type, which can be CPU, Ascend, or GPU.

  • device_distributed_mode: whether to support multi-card training. The value can be multiple (supported) or singular (not supported).

  • host_distributed_mode: whether to support distributed training. The value can be multiple (supported) or singular (not supported).

values

No

Array of strings

Value of the resource constraint key.

operator

No

String

Relationship between keys and values. Currently, only in is supported. For example, flavor_type in [CPU,GPU].

Table 13 AlgorithmAdvancedConfig

Parameter

Mandatory

Type

Description

auto_search

No

AutoSearch object

Hyperparameter search policy.

Table 14 AutoSearch

Parameter

Mandatory

Type

Description

skip_search_params

No

String

Hyperparameter parameters that need to be skipped.

reward_attrs

No

Array of RewardAttrs objects

Search metrics.

search_params

No

Array of SearchParams objects

Search parameters.

algo_configs

No

Array of AlgoConfigs objects

Search algorithm configurations.

Table 15 RewardAttrs

Parameter

Mandatory

Type

Description

name

No

String

Metric name.

mode

No

String

Search mode. - If max is specified, the larger the metric value, the better. - If min is specified, the smaller the metric value, the better.

regex

No

String

Regular expression of a metric.

Table 16 SearchParams

Parameter

Mandatory

Type

Description

name

No

String

Hyperparameter name.

param_type

No

String

Parameter type. - continuous: The hyperparameter is of the continuous type. When an algorithm is used in a training job, continuous hyperparameters are displayed as text boxes on the console. - discrete: The hyperparameter is of the discrete type. When an algorithm is used in a training job, discrete hyperparameters are displayed as drop-down lists on the console.

lower_bound

No

String

Lower bound of the hyperparameter.

upper_bound

No

String

Upper bound of the hyperparameter.

discrete_points_num

No

String

Number of discrete points of a hyperparameter with continuous values.

discrete_values

No

Array of strings

Discrete hyperparameter values.

Table 17 AlgoConfigs

Parameter

Mandatory

Type

Description

name

No

String

Name of the search algorithm.

params

No

Array of AutoSearchAlgoConfigParameter objects

Search algorithm parameters.

Table 18 AutoSearchAlgoConfigParameter

Parameter

Mandatory

Type

Description

key

No

String

Parameter key.

value

No

String

Parameter value.

type

No

String

Parameter type.

Response Parameters

Status code: 201

Table 19 Response body parameters

Parameter

Type

Description

metadata

metadata object

Algorithm metadata, which describes basic algorithm information.

job_config

job_config object

Algorithm configuration, such as the boot file.

resource_requirements

Array of resource_requirements objects

Algorithm resource constraint. This parameter is optional. After this parameter is set, the console filters available public resource pools when the algorithm is used in training jobs.

advanced_config

advanced_config object

Advanced algorithm policy:

  • auto_search

Table 20 metadata

Parameter

Type

Description

id

Integer

Algorithm UUID. You do not need to set this parameter when creating an algorithm.

name

String

Algorithm name. The value must contain 1 to 64 characters consisting of only digits, letters, underscores (_), and hyphens (-).

description

String

Description of the algorithm. The value is a string of [0, 256] characters. The default value is NULL.

workspace_id

String

Workspace where a specified algorithm is located. The default value is 0. The value 0 indicates the default workspace.

ai_project

String

AI project to which a specified algorithm belongs. The default value is default-ai-project. The AI project has been brought offline. Ignore it.

user_name

String

Username.

domain_id

String

Domain ID of a user.

source

String

Algorithm source.

api_version

String

Algorithm API version, which identifies the old and new ones.

is_valid

String

Algorithm availability.

state

String

Algorithm state.

tags

Array of Map<String,String> objects

Algorithm tags.

attr_list

Array of strings

Algorithm attribute list.

version_num

Integer

Number of algorithm versions. The default value is 0.

size

Integer

Algorithm size.

create_time

Long

Timestamp when the algorithm is created.

update_time

Long

Timestamp when the algorithm is updated.

Table 21 job_config

Parameter

Type

Description

code_dir

String

Algorithm code directory, for example, /usr/app/. This parameter must be used together with boot_file.

boot_file

String

Code boot file of the algorithm, which must be stored in the code directory, for example, /usr/app/boot.py. This parameter must be used with code_dir.

command

String

Container startup command of a custom image algorithm.

parameters

Array of Parameter objects

Running parameter of an algorithm.

inputs

Array of inputs objects

Data input of an algorithm.

outputs

Array of outputs objects

Data output of an algorithm.

engine

engine object

Algorithm engine.

code_tree

Array of code_tree objects

Algorithm directory tree

parameters_customization

Boolean

Whether the algorithm allows hyperparameter customization during training job creation.

Table 22 Parameter

Parameter

Type

Description

name

String

Parameter name.

value

String

Parameter value.

description

String

Parameter description.

constraint

constraint object

Parameter constraint.

i18n_description

i18n_description object

Internationalization description.

Table 23 constraint

Parameter

Type

Description

type

String

Parameter type.

editable

Boolean

Whether the parameter is editable.

required

Boolean

Whether the parameter is mandatory.

sensitive

Boolean

Whether the parameter is sensitive This function is not implemented currently.

valid_type

String

Valid type.

valid_range

Array of strings

Valid range.

Table 24 i18n_description

Parameter

Type

Description

language

String

International language[. The options are as follows:

  • zh-cn (Chinese)

  • En-us] (tag:hc,hk)

description

String

Description of an international language.

Table 25 inputs

Parameter

Type

Description

name

String

Name of the data input channel.

description

String

Description of the data input channel.

remote_constraints

Array of remote_constraints objects

Data input constraint.

Table 26 remote_constraints

Parameter

Type

Description

data_type

String

Data input type, including the data storage location and dataset.

attributes

Array of Map<String,String> objects

Attributes when the data input type is a dataset. Enums:

  • data_format: data format

  • data_segmentation: data segmentation

  • dataset_type: data labeling

Table 27 outputs

Parameter

Type

Description

name

String

Name of the data output channel.

description

String

Description of the data output channel.

Table 28 engine

Parameter

Type

Description

engine_id

String

Engine ID selected for an algorithm.

engine_name

String

Engine version name selected for an algorithm. If engine_id is specified, leave this parameter blank.

engine_version

String

Engine version name selected for an algorithm. If engine_id is specified, leave this parameter blank.

image_url

String

Custom image URL selected by an algorithm.

Table 29 code_tree

Parameter

Type

Description

name

String

Name of the current directory in the algorithm directory tree.

children

Object

Subfiles and subdirectories in the current directory of the algorithm directory tree.

Table 30 resource_requirements

Parameter

Type

Description

key

String

Resource constraint. The options are as follows:

  • flavor_type: flavor type, which can be CPU, Ascend, or GPU.

  • device_distributed_mode: whether to support multi-card training. The value can be multiple (supported) or singular (not supported).

  • host_distributed_mode: whether to support distributed training. The value can be multiple (supported) or singular (not supported).

value

Array of strings

Value of the resource constraint key.

operator

String

Relationship between keys and values. Currently, only in is supported. For example, flavor_type in [CPU,GPU].

Table 31 advanced_config

Parameter

Type

Description

auto_search

auto_search object

Hyperparameter search policy.

Table 33 reward_attrs

Parameter

Type

Description

name

String

Metric name.

mode

String

Search mode.

  • max: A larger metric value is preferred.

  • min: A smaller metric value is preferred.

regex

String

Regular expression of a metric.

Table 34 search_params

Parameter

Type

Description

name

String

Hyperparameter name.

param_type

String

Parameter type.

  • continuous: The hyperparameter is of the continuous type. When an algorithm is used in a training job, continuous hyperparameters are displayed as text boxes on the console.

  • discrete: The hyperparameter is of the discrete type. When an algorithm is used in a training job, discrete hyperparameters are displayed as drop-down lists on the console.

lower_bound

String

Lower bound of the hyperparameter.

upper_bound

String

Upper bound of the hyperparameter.

discrete_points_num

String

Number of discrete points of a continuous hyperparameter.

discrete_values

String

List of discrete hyperparameter values.

Table 35 algo_configs

Parameter

Type

Description

name

String

Name of the search algorithm.

params

Array of AutoSearchAlgoConfigParameter objects

Search algorithm parameters.

Table 36 AutoSearchAlgoConfigParameter

Parameter

Type

Description

key

String

Parameter key.

value

String

Parameter value.

type

String

Parameter type.

Example Requests

The following shows how to modify the algorithm whose UUID is 2e5451fe-913f-4492-821a-2981031382f7.

PUT https://endpoint/v2/{project_id}/algorithms/2e5451fe-913f-4492-821a-2981031382f7

{
  "metadata" : {
    "name" : "TestModelArtsalgorithm",
    "description" : "This is a ModelArts algorithm modified"
  },
  "job_config" : {
    "code_dir" : "/algo-test/pytorch/work1/code/",
    "boot_file" : "/algo-test/pytorch/work1/code/test-pytorch.py",
    "parameters" : [ {
      "name" : "test-parameter",
      "value" : "10",
      "constraint" : {
        "type" : "String",
        "editable" : true,
        "required" : false,
        "sensitive" : false,
        "valid_type" : "None",
        "valid_range" : [ ]
      }
    } ],
    "parameters_customization" : true,
    "inputs" : [ {
      "name" : "data_url",
      "description" : "data source."
    } ],
    "outputs" : [ {
      "name" : "train_url",
      "description" : "model output."
    } ],
    "engine" : {
      "engine_name" : "PyTorch",
      "engine_version" : "PyTorch-1.3.0-python3.6"
    }
  }
}

Example Responses

Status code: 201

ok

{
  "metadata" : {
    "id" : "2e5451fe-913f-4492-821a-2981031382f7",
    "name" : "TestModelArtsalgorithm",
    "description" : "This is a ModelArts algorithm modified",
    "create_time" : 1636600721742,
    "workspace_id" : "0",
    "ai_project" : "default-ai-project",
    "user_name" : "",
    "domain_id" : "xxxxxxxxxxxxxxxxxxxxxxxxxx",
    "source" : "custom",
    "api_version" : "",
    "is_valid" : true,
    "state" : "",
    "size" : 4791,
    "tags" : null,
    "attr_list" : null,
    "version_num" : 0,
    "update_time" : 0
  },
  "job_config" : {
    "code_dir" : "/algo-test/pytorch/work1/code/",
    "boot_file" : "/algo-test/pytorch/work1/code/test-pytorch.py",
    "command" : "",
    "parameters" : [ {
      "name" : "test-parameter",
      "description" : "",
      "i18n_description" : null,
      "value" : "10",
      "constraint" : {
        "type" : "String",
        "editable" : true,
        "required" : false,
        "sensitive" : false,
        "valid_type" : "None",
        "valid_range" : [ ]
      }
    } ],
    "parameters_customization" : true,
    "inputs" : [ {
      "name" : "data_url",
      "description" : "name to translate"
    } ],
    "outputs" : [ {
      "name" : "train_url",
      "description" : "name to translate"
    } ],
    "engine" : {
      "engine_id" : "pytorch-cp36-1.3.0",
      "engine_name" : "PyTorch",
      "engine_version" : "PyTorch-1.3.0-python3.6"
    },
    "code_tree" : {
      "name" : "code/",
      "children" : [ {
        "name" : "test-pytorch.py"
      } ]
    }
  },
  "resource_requirements" : null,
  "advanced_config" : { }
}

Status Codes

Status Code

Description

201

ok

Error Codes

See Error Codes.

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