更新算法
功能介绍
更新算法。
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
URI
PUT /v2/{project_id}/algorithms/{algorithm_id}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
用户项目ID。获取方法请参见获取项目ID和名称。 |
algorithm_id |
是 |
String |
算法ID。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
metadata |
否 |
AlgorithmMetadata object |
算法的元数据,描述算法基本信息。 |
job_config |
否 |
AlgorithmJobConfig object |
算法配置信息,如启动文件等。 |
resource_requirements |
否 |
Array of ResourceRequirement objects |
算法资源约束。可不设置。设置后,在算法使用于训练作业时,控制台会过滤可用的公共资源池。 |
advanced_config |
否 |
AlgorithmAdvancedConfig object |
算法高级策略:
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
id |
否 |
Integer |
算法uuid,创建算法时无需填写。 |
name |
是 |
String |
算法名称。限制为1-64位只含数字、字母、下划线和中划线的名称。 |
description |
否 |
String |
对算法的描述,默认为“NULL”,字符串的长度限制为[0, 256]。 |
workspace_id |
否 |
String |
指定算法所处的工作空间,默认值为“0”。“0” 为默认的工作空间。 |
ai_project |
否 |
String |
指定算法所属的ai项目,默认值为"default-ai-project"。ai项目已下线,无需关注。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
code_dir |
否 |
String |
算法的代码目录。如:“/usr/app/”。应与boot_file一同出现。 |
boot_file |
否 |
String |
算法的代码启动文件,需要在代码目录下。如:“/usr/app/boot.py”。应与code_dir一同出现。 |
command |
否 |
String |
自定义镜像算法的容器启动命令。 |
parameters |
否 |
Array of Parameters objects |
算法的运行参数。 |
inputs |
否 |
Array of AlgorithmCreateInput objects |
算法的数据输入。 |
outputs |
否 |
Array of AlgorithmCreateOutput objects |
算法的数据输出。 |
engine |
否 |
AlgorithmCreateEngine object |
算法的引擎。 |
parameters_customization |
否 |
Boolean |
算法是否允许创建训练作业时自定义超参。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
否 |
String |
参数名称。 |
value |
否 |
String |
参数值。 |
description |
否 |
String |
参数描述信息。 |
constraint |
否 |
ParametersConstraint object |
参数属性。 |
i18n_description |
否 |
I18nDescription object |
国际化描述。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
type |
否 |
String |
参数种类。 |
editable |
否 |
Boolean |
是否可编辑。 |
required |
否 |
Boolean |
是否必须。 |
sensitive |
否 |
Boolean |
是否敏感。该功能暂未实现。 |
valid_type |
否 |
String |
有效种类。 |
valid_range |
否 |
Array of strings |
有效范围。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
否 |
String |
数据输入通道名称。 |
description |
否 |
String |
数据输入通道描述信息。 |
remote_constraints |
否 |
Array of RemoteConstraint objects |
数据输入约束。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
data_type |
否 |
String |
数据输入类型,支持数据存储位置(OBS)、ModelArts数据集两种方式。 |
attributes |
否 |
Array of Map<String,String> objects |
数据输入为数据集时的相关属性。枚举值:
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
engine_id |
否 |
String |
算法选择的引擎规格ID。 |
engine_name |
否 |
String |
算法选择的引擎版本名称。若填入engine_id则无需填写。 |
engine_version |
否 |
String |
算法选择的引擎版本名称。若填入engine_id则无需填写。 |
image_url |
否 |
String |
算法选择的自定义镜像地址。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
key |
否 |
String |
资源约束,可选键值如:
|
values |
否 |
Array of strings |
资源约束键对应值。 |
operator |
否 |
String |
键与值关系,当前只支持in。例如flavor_type in [CPU,GPU]。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
skip_search_params |
否 |
String |
需要排除的超参组合。 |
reward_attrs |
否 |
Array of RewardAttrs objects |
搜索指标列表。 |
search_params |
否 |
Array of SearchParams objects |
搜索参数。 |
algo_configs |
否 |
Array of AlgoConfigs objects |
搜索算法配置。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
否 |
String |
指标名称。 |
mode |
否 |
String |
搜索方向。 - max指定时表示指标值越大越好; - min指定时表示指标值越小越好。 |
regex |
否 |
String |
指标正则表达式。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
否 |
String |
超参名称。 |
param_type |
否 |
String |
参数类型。 - continuous:指定时表示这个超参是连续类型的。连续类型的超参在算法使用于训练作业时,控制台显示为输入框。 - discrete:指定时表示这个超参是离散类型的。离散类型的超参在算法使用于训练作业时,控制台显示为下拉选择框架。 |
lower_bound |
否 |
String |
超参下界。 |
upper_bound |
否 |
String |
超参上界。 |
discrete_points_num |
否 |
String |
连续型超参离散化取值个数。 |
discrete_values |
否 |
Array of strings |
离散型超参的取值列表。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
name |
否 |
String |
搜索算法名称。 |
params |
否 |
Array of AutoSearchAlgoConfigParameter objects |
搜索算法参数。 |
响应参数
状态码:201
参数 |
参数类型 |
描述 |
---|---|---|
metadata |
metadata object |
算法的元数据,描述算法基本信息。 |
job_config |
job_config object |
算法配置信息,如启动文件等。 |
resource_requirements |
Array of resource_requirements objects |
算法资源约束,可不设置。设置后,在算法使用于训练作业时,控制台会过滤可用的公共资源池。 |
advanced_config |
advanced_config object |
算法高级策略:
|
参数 |
参数类型 |
描述 |
---|---|---|
id |
Integer |
算法uuid,创建算法时无需填写。 |
name |
String |
算法名称。限制为1-64位只含数字、字母、下划线和中划线的名称。 |
description |
String |
对算法的描述,默认为“NULL”,字符串的长度限制为[0, 256]。 |
workspace_id |
String |
指定算法所处的工作空间,默认值为“0”。“0” 为默认的工作空间。 |
ai_project |
String |
指定算法所属的ai项目,默认值为"default-ai-project"。ai项目已下线,无需关注。 |
user_name |
String |
用户名称。 |
domain_id |
String |
用户的domainID。 |
source |
String |
算法来源类型。 |
api_version |
String |
算法api版本,标识新旧版。 |
is_valid |
String |
算法可用性。 |
state |
String |
算法状态。 |
tags |
Array of Map<String,String> objects |
算法标签。 |
attr_list |
Array of strings |
算法属性列表。 |
version_num |
Integer |
算法版本数量,默认为0。 |
size |
Integer |
算法大小。 |
create_time |
Long |
算法创建时间戳。 |
update_time |
Long |
算法更新时间戳。 |
参数 |
参数类型 |
描述 |
---|---|---|
code_dir |
String |
算法的代码目录。如:“/usr/app/”。应与boot_file一同出现。 |
boot_file |
String |
算法的代码启动文件,需要在代码目录下。如:“/usr/app/boot.py”。应与code_dir一同出现。 |
command |
String |
自定义镜像算法的容器启动命令。 |
parameters |
Array of Parameter objects |
算法的运行参数。 |
inputs |
Array of inputs objects |
算法的数据输入。 |
outputs |
Array of outputs objects |
算法的数据输出。 |
engine |
engine object |
算法的引擎。 |
code_tree |
Array of code_tree objects |
算法的目录结构树。 |
parameters_customization |
Boolean |
算法是否允许创建训练作业时自定义超参。 |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
参数名称。 |
value |
String |
参数值。 |
description |
String |
参数描述信息。 |
constraint |
constraint object |
参数属性。 |
i18n_description |
i18n_description object |
国际化描述。 |
参数 |
参数类型 |
描述 |
---|---|---|
type |
String |
参数种类。 |
editable |
Boolean |
是否可编辑。 |
required |
Boolean |
是否必须。 |
sensitive |
Boolean |
是否敏感。该功能暂未实现。 |
valid_type |
String |
有效种类。 |
valid_range |
Array of strings |
有效范围。 |
参数 |
参数类型 |
描述 |
---|---|---|
language |
String |
国际语种,可选值如下:
|
description |
String |
国际化语种的描述信息。 |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
数据输入通道名称。 |
description |
String |
数据输入通道描述信息。 |
remote_constraints |
Array of remote_constraints objects |
数据输入约束。 |
参数 |
参数类型 |
描述 |
---|---|---|
data_type |
String |
数据输入类型,包括数据存储位置、数据集两种方式。 |
attributes |
Array of Map<String,String> objects |
数据输入为数据集时的相关属性。枚举值:
|
参数 |
参数类型 |
描述 |
---|---|---|
engine_id |
String |
算法选择的引擎规格ID。 |
engine_name |
String |
算法选择的引擎版本名称。若填入engine_id则无需填写。 |
engine_version |
String |
算法选择的引擎版本名称。若填入engine_id则无需填写。 |
image_url |
String |
算法选择的自定义镜像地址。 |
参数 |
参数类型 |
描述 |
---|---|---|
key |
String |
资源约束,可选值如下:
|
value |
Array of strings |
资源约束键对应值。 |
operator |
String |
键与值关系,当前只支持in。例如flavor_type in [CPU,GPU]。 |
参数 |
参数类型 |
描述 |
---|---|---|
skip_search_params |
String |
需要排除的超参组合。 |
reward_attrs |
Array of reward_attrs objects |
搜索指标列表。 |
search_params |
Array of search_params objects |
搜索参数。 |
algo_configs |
Array of algo_configs objects |
搜索算法配置。 |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
指标名称。 |
mode |
String |
搜索方向。
|
regex |
String |
指标正则表达式。 |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
超参名称。 |
param_type |
String |
参数类型。
|
lower_bound |
String |
超参下界。 |
upper_bound |
String |
超参上界。 |
discrete_points_num |
String |
连续型超参离散化取值个数。 |
discrete_values |
String |
离散型超参的取值列表。 |
参数 |
参数类型 |
描述 |
---|---|---|
name |
String |
搜索算法名称。 |
params |
Array of AutoSearchAlgoConfigParameter objects |
搜索算法参数。 |
请求示例
如下以修改uuid为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"
}
}
}
响应示例
状态码: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" : { }
}
状态码
状态码 |
描述 |
---|---|
201 |
ok |
错误码
请参见错误码。