Updated on 2025-08-20 GMT+08:00

Modifying an Algorithm

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

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

Constraints: The value can contain 1 to 64 characters. Letters, digits, and hyphens (-) are allowed.

Range: N/A

Default Value: N/A

algorithm_id

Yes

String

Definition: Algorithm ID

Constraints: N/A

Range: N/A

Default Value: N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

metadata

No

AlgorithmMetadata object

Definition: Algorithm metadata, which describes basic algorithm information.

Constraints: N/A

job_config

No

AlgorithmJobConfig object

Definition: Algorithm configuration, such as the boot file.

Constraints: N/A

resource_requirements

No

Array of ResourceRequirement objects

Definition: 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.

Constraints: N/A

advanced_config

No

AlgorithmAdvancedConfig object

Definition: Advanced algorithm policy.

  • auto_search

Constraints: N/A

Table 3 AlgorithmMetadata

Parameter

Mandatory

Type

Description

id

No

Integer

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

Constraints: N/A

Range: N/A

Default Value: N/A

name

Yes

String

Definition: Algorithm name.

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

Range: N/A

Default Value: N/A

description

No

String

Definition: Algorithm description.

Constraints: The value must contain 0 to 256 characters.

Range: N/A

Default Value: NULL

workspace_id

No

String

Definition: Workspace where a specified algorithm is located.

Constraints: N/A

Range: N/A

Default Value: 0, which is the default workspace.

ai_project

No

String

Definition: AI project to which a specified algorithm belongs. The AI project has been brought offline. Ignore it.

Constraints: N/A

Range: N/A

Default Value: default-ai-project

Table 4 AlgorithmJobConfig

Parameter

Mandatory

Type

Description

code_dir

No

String

Definition: Algorithm code directory, for example, /usr/app/.

Constraints: This parameter must be used with boot_file.

Range: N/A

Default Value: N/A

boot_file

No

String

Definition: Code boot file of the algorithm, which must be stored in the code directory, for example, /usr/app/boot.py.

Constraints: This parameter must be used with code_dir.

Range: N/A

Default Value: N/A

command

No

String

Definition: Container boot command of a custom image algorithm.

Constraints: N/A

Range: N/A

Default Value: N/A

parameters

No

Array of Parameters objects

Definition: Running parameters of an algorithm.

Constraints: N/A

inputs

No

Array of AlgorithmCreateInput objects

Definition: Data input of an algorithm.

Constraints: N/A

outputs

No

Array of AlgorithmCreateOutput objects

Definition: Data output of an algorithm.

Constraints: N/A

engine

No

AlgorithmCreateEngine object

Definition: Algorithm engine.

Constraints: N/A

parameters_customization

No

Boolean

Definition: Specifies whether the algorithm allows hyperparameter customization during training job creation.

Constraints: N/A

Range:

  • true: allowed

  • false: not allowed

Default Value: N/A

Table 5 Parameters

Parameter

Mandatory

Type

Description

name

No

String

Definition: Parameter name.

Constraints: N/A

Range: N/A

Default Value: N/A

value

No

String

Definition: Parameter value.

Constraints: N/A

Range: N/A

Default Value: N/A

description

No

String

Definition: Parameter description.

Constraints: N/A

Range: N/A

Default Value: N/A

constraint

No

ParametersConstraint object

Definition: Parameter attribute.

Constraints: N/A

i18n_description

No

I18nDescription object

Definition: Internationalization description.

Constraints: N/A

Table 6 ParametersConstraint

Parameter

Mandatory

Type

Description

type

No

String

Definition: Parameter type.

Constraints: N/A

Range: N/A

Default Value: N/A

editable

No

Boolean

Definition: Whether the parameter can be edited.

Constraints: N/A

Range:

  • true: editable

  • false: Not uneditable

Default Value: N/A

required

No

Boolean

Definition: Whether the parameter is mandatory.

Constraints: N/A

Range:

  • true: mandatory

  • false: optional

Default Value: N/A

sensitive

No

Boolean

Definition: Whether the parameter is sensitive. This function is unavailable currently.

Constraints: N/A

Range:

  • true: sensitive

  • false: insensitive

Default Value: N/A

valid_type

No

String

Definition: Valid type.

Constraints: N/A

Range: N/A

Default Value: N/A

valid_range

No

Array of strings

Definition: Valid range.

Constraints: N/A

Table 7 I18nDescription

Parameter

Mandatory

Type

Description

language

No

String

Definition: Internationalization language.

Constraints: N/A

Range: N/A

Default Value: N/A

description

No

String

Definition: Description.

Constraints: N/A

Range: N/A

Default Value: N/A

Table 8 AlgorithmCreateInput

Parameter

Mandatory

Type

Description

name

No

String

Definition: Name of the data input channel.

Constraints: N/A

Range: N/A

Default Value: N/A

description

No

String

Definition: Description of the data input channel.

Constraints: N/A

Range: N/A

Default Value: N/A

remote_constraints

No

Array of RemoteConstraint objects

Definition: Data input constraint.

Constraints: N/A

Table 9 RemoteConstraint

Parameter

Mandatory

Type

Description

data_type

No

String

Definition: Data input type, including OBS and ModelArts.

Constraints: N/A

Range: N/A

Default Value: N/A

attributes

No

Array of Map<String,String> objects

Definition: Attributes when the data input type is a dataset. Range:

  • data_format: data format

  • data_segmentation: data segmentation method

  • dataset_type: data labeling type

Constraints: N/A

Table 10 AlgorithmCreateOutput

Parameter

Mandatory

Type

Description

name

Yes

String

Definition: Name of the data output channel.

Constraints: N/A

Range: N/A

Default Value: N/A

description

No

String

Definition: Description of the data output channel.

Constraints: N/A

Range: N/A

Default Value: N/A

Table 11 AlgorithmCreateEngine

Parameter

Mandatory

Type

Description

engine_id

No

String

Definition: Engine ID selected for an algorithm.

Constraints: N/A

Range: N/A

Default Value: N/A

engine_name

No

String

Definition: Engine version name selected for an algorithm.

Constraints: If engine_id is specified, leave this parameter blank.

Range: N/A

Default Value: N/A

engine_version

No

String

Definition: Engine version name selected for an algorithm.

Constraints: If engine_id is specified, leave this parameter blank.

Range: N/A

Default Value: N/A

image_url

No

String

Definition: Custom image URL selected for an algorithm.

Constraints: N/A

Range: N/A

Default Value: N/A

Table 12 ResourceRequirement

Parameter

Mandatory

Type

Description

key

No

String

Definition: Resource constraints.

Constraints: N/A

Range:

  • 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).

Default Value: N/A

values

No

Array of strings

Definition: Value of the resource constraint key.

Constraints: N/A

operator

No

String

Definition: Key-value relationship.

Constraints: Only the in operation is supported. For example, flavor_type in [CPU,GPU].

Range: N/A

Default Value: N/A

Table 13 AlgorithmAdvancedConfig

Parameter

Mandatory

Type

Description

auto_search

No

AutoSearch object

Definition: Hyperparameter search policy.

Constraints: N/A

Table 14 AutoSearch

Parameter

Mandatory

Type

Description

skip_search_params

No

String

Definition: Hyperparameter parameters that need to be skipped.

Constraints: N/A

Range: N/A

Default Value: N/A

reward_attrs

No

Array of RewardAttrs objects

Definition: Search metrics.

Constraints: N/A

search_params

No

Array of SearchParams objects

Definition: Search parameters.

Constraints: N/A

algo_configs

No

Array of AlgoConfigs objects

Definition: Search algorithm configurations.

Constraints: N/A

Table 15 RewardAttrs

Parameter

Mandatory

Type

Description

name

No

String

Definition: Metric name.

Constraints: N/A

Range: N/A

Default Value: N/A

mode

No

String

Definition: Search mode.

Constraints: N/A

Range:

  • max: A larger metric value is preferred.

  • min: A smaller metric value is preferred.

Default Value: N/A

regex

No

String

Definition: Regular expression of a metric.

Constraints: N/A

Range: N/A

Default Value: N/A

Table 16 SearchParams

Parameter

Mandatory

Type

Description

name

No

String

Definition: Hyperparameter name.

Constraints: N/A

Range: N/A

Default Value: N/A

param_type

No

String

Definition: Parameter type.

Constraints: N/A

Range:

  • 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.

Default Value: N/A

lower_bound

No

String

Definition: Lower bound of the hyperparameter.

Constraints: N/A

Range: N/A

Default Value: N/A

upper_bound

No

String

Definition: Upper bound of the hyperparameter.

Constraints: N/A

Range: N/A

Default Value: N/A

discrete_points_num

No

String

Definition: Number of discrete points of a hyperparameter with continuous values.

Constraints: N/A

Range: N/A

Default Value: N/A

discrete_values

No

Array of strings

Definition: Discrete hyperparameter values.

Constraints: N/A

Table 17 AlgoConfigs

Parameter

Mandatory

Type

Description

name

No

String

Definition: Search algorithm name.

Constraints: N/A

Range: N/A

Default Value: N/A

params

No

Array of AutoSearchAlgoConfigParameter objects

Definition: Search algorithm parameters.

Constraints: N/A

Table 18 AutoSearchAlgoConfigParameter

Parameter

Mandatory

Type

Description

key

No

String

Definition: Parameter key.

Constraints: N/A

Range: N/A

Default Value: N/A

value

No

String

Definition: Parameter value.

Constraints: N/A

Range: N/A

Default Value: N/A

type

No

String

Definition: parameter type.

Constraints: N/A

Range: N/A

Default Value: N/A

Response Parameters

Status code: 201

Table 19 Response body parameters

Parameter

Type

Description

metadata

metadata object

Definition: Algorithm metadata, which describes basic algorithm information.

job_config

job_config object

Definition: Algorithm configuration, such as the boot file.

resource_requirements

Array of resource_requirements objects

Definition: 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

advanced_config object

Definition: Advanced algorithm policy.

  • auto_search

Table 20 metadata

Parameter

Type

Description

id

Integer

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

Range: N/A

name

String

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

Range: N/A

description

String

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

Range: N/A

workspace_id

String

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

Range: N/A

ai_project

String

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

Range: N/A

user_name

String

  • Definition: Username.

Range: N/A

domain_id

String

Definition: Domain ID of a user.

Range: N/A

source

String

Definition: Algorithm source type.

Range: N/A

api_version

String

Definition: Algorithm API version, which shows whether it is new or old.

Range: N/A

is_valid

String

Definition: Algorithm availability.

Range: N/A

state

String

Definition: Algorithm status.

Range: N/A

tags

Array of Map<String,String> objects

Definition: Algorithm tag.

attr_list

Array of strings

Definition: Algorithm attributes.

version_num

Integer

Definition: Number of algorithm versions. The default value is 0.

Range: N/A

size

Integer

Definition: Algorithm size.

Range: N/A

create_time

Long

Definition: Algorithm creation timestamp.

Range: N/A

update_time

Long

Definition: Algorithm update timestamp.

Range: N/A

Table 21 job_config

Parameter

Type

Description

code_dir

String

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

Range: N/A

boot_file

String

Definition: 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.

Range: N/A

command

String

Definition: Container boot command of a custom image algorithm.

Range: N/A

parameters

Array of ParameterResp objects

Definition: Running parameters of an algorithm.

inputs

Array of inputs objects

Definition: Data input of an algorithm.

outputs

Array of outputs objects

Definition: Data output of an algorithm.

engine

engine object

Definition: Algorithm engine.

code_tree

Array of code_tree objects

Definition: Algorithm directory tree.

parameters_customization

Boolean

Definition: Specifies whether the algorithm allows hyperparameter customization during training job creation.

Range:

  • true: allowed

  • false: not allowed

Table 22 ParameterResp

Parameter

Type

Description

name

String

Definition: Parameter name.

Range: N/A

value

String

Definition: Parameter value.

Range: N/A

description

String

Definition: Parameter description.

Range: N/A

constraint

constraint object

Definition: Parameter attribute.

i18n_description

i18n_description object

Definition: Internationalization description.

Table 23 constraint

Parameter

Type

Description

type

String

Definition: Parameter type.

Range: N/A

editable

Boolean

Definition: Whether the parameter can be edited.

Range:

  • true: editable

  • false: Not uneditable

required

Boolean

Definition: Whether the parameter is mandatory.

Range:

  • true: mandatory

  • false: optional

sensitive

Boolean

Definition: Whether the parameter is sensitive. This function is unavailable currently.

Range:

  • true: sensitive

  • false: insensitive

valid_type

String

Definition: Valid type.

Range: N/A

valid_range

Array of strings

Definition: Valid range.

Table 24 i18n_description

Parameter

Type

Description

language

String

Definition: Internationalization language. The options are as follows:

  • zh-cn: Chinese

  • en-us: English

Range: N/A

description

String

Definition: Internationalization language description.

Range: N/A

Table 25 inputs

Parameter

Type

Description

name

String

Definition: Name of the data input channel.

Range: N/A

description

String

Definition: Description of the data input channel.

Range: N/A

remote_constraints

Array of remote_constraints objects

Definition: Data input constraint.

Table 26 remote_constraints

Parameter

Type

Description

data_type

String

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

Range: N/A

attributes

Array of Map<String,String> objects

Definition: Attributes when the data input type is a dataset. The value can be:

  • data_format: data format

  • data_segmentation: data segmentation method

  • dataset_type: data labeling type

Table 27 outputs

Parameter

Type

Description

name

String

Definition: Name of the data output channel.

Range: N/A

description

String

Definition: Description of the data output channel.

Range: N/A

Table 28 engine

Parameter

Type

Description

engine_id

String

Definition: Engine ID selected for an algorithm.

Range: N/A

engine_name

String

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

Range: N/A

engine_version

String

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

Range: N/A

image_url

String

Definition: Custom image URL selected for an algorithm.

Range: N/A

Table 29 code_tree

Parameter

Type

Description

name

String

Definition: Name of the current directory in the algorithm directory tree.

Range: N/A

children

Object

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

Table 30 resource_requirements

Parameter

Type

Description

key

String

Definition: Resource constraints.

Range:

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

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

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

value

Array of strings

Definition: Value of the resource constraint key.

operator

String

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

Range: N/A

Table 31 advanced_config

Parameter

Type

Description

auto_search

auto_search object

Definition: Hyperparameter search policy.

Table 33 reward_attrs

Parameter

Type

Description

name

String

Definition: Metric name.

Range: N/A

mode

String

Definition: Search mode.

Range:

  • max: A larger metric value is preferred.

  • min: A smaller metric value is preferred.

regex

String

Definition: Regular expression of a metric.

Range: N/A

Table 34 search_params

Parameter

Type

Description

name

String

Definition: Hyperparameter name.

Range: N/A

param_type

String

Definition: Parameter type.

Range:

  • 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

Definition: Lower bound of the hyperparameter.

Range: N/A

upper_bound

String

Definition: Upper bound of the hyperparameter.

Range: N/A

discrete_points_num

String

Definition: Number of discrete points of a hyperparameter with continuous values.

Range: N/A

discrete_values

String

Definition: Discrete hyperparameter values.

Range: N/A

Table 35 algo_configs

Parameter

Type

Description

name

String

Definition: Search algorithm name.

Range: N/A

params

Array of AutoSearchAlgoConfigParameterResp objects

Definition: Search algorithm parameters.

Table 36 AutoSearchAlgoConfigParameterResp

Parameter

Type

Description

key

String

Definition: Parameter key.

Range: N/A

value

String

Definition: Parameter value.

Range: N/A

type

String

Definition: Parameter type.

Range: N/A

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.