创建算法
功能介绍
创建算法。
URI
POST /v2/{project_id}/sim/pm/algorithms
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
项目ID,获取方法请参见获取项目ID |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
Content-Type |
是 |
String |
内容类型。填application/json |
|
X-Auth-Token |
是 |
String |
用户Token,通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值) |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
name |
是 |
String |
算法名称,最大长度64位,支持中文,字母,数字及下划线命名 |
|
description |
否 |
String |
算法描述,最大长度255位,支持中文,字母,数字及下划线命名 |
|
category |
是 |
String |
算法类型
|
|
run |
是 |
表4 object |
运行信息 |
|
image_repo_id |
是 |
Integer |
镜像ID |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
command |
是 |
String |
运行命令,最大长度255位,必须是ASCII码组成的字符串,不能包含\@#$%^&*<>,不支持中文字符 |
|
keyword |
否 |
String |
算法关键字,最大长度256位,必须是ASCII码组成的字符串,不能包含\@#$%^&*<>,不支持中文字符 |
|
pkg_log_dir |
否 |
String |
日志打包目录,需绝对路径 |
|
cpu |
是 |
Double |
cpu配额,值需在cpu quota的范围内 |
|
memory |
是 |
Integer |
内存配额,单位MB,值需在memory quota的范围内 |
|
gpu |
是 |
Integer |
gpu配额,值需在gpu quota的范围内 |
响应参数
状态码:201
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
url |
String |
算法镜像的资源地址 |
|
id |
Integer |
算法镜像ID |
|
created_at |
TimeStamp |
创建时间 |
|
updated_at |
TimeStamp |
更新时间 |
|
run |
表6 object |
运行信息 |
|
name |
String |
算法名称 |
|
description |
String |
算法描述 |
|
category |
String |
算法类型
|
|
image_repo_id |
Integer |
镜像ID |
请求示例
创建算法
POST https://{endpoint}/v2/{project_id}/sim/pm/algorithms
{
"category" : "image",
"name" : "algorithm-xx",
"description" : "add-new-algorithm",
"run" : {
"command" : "custom define cmd xxx",
"keyword" : "custom define keyword xx",
"cpu" : 2,
"memory" : 1024,
"gpu" : 0,
"pkg_log_dir" : "/srv/log"
},
"image_repo_id" : 262463
}
响应示例
状态码:201
{
"url" : "/v2/54d37c8f25af42xxxxxxxxe9772687bf/sim/pm/algorithms/62/",
"id" : 62,
"created_at" : 1746579828.060311,
"updated_at" : 1746579838.060311,
"description" : {
"content" : "customer algorithm"
},
"name" : "algorithm-xx",
"category" : "image",
"image_repo_id" : 262463,
"run" : {
"command" : "ustom define cmd xxx",
"pkg_log_dir" : "/srv/log",
"keyword" : "custom define keyword xx",
"cpu" : 2.0,
"memory" : 1024,
"gpu" : 0
}
}
状态码
|
状态码 |
描述 |
|---|---|
|
201 |
创建成功 |
错误码
请参见错误码。