创建任务
创建单机、分布式训练任务。
POST
https://api.alayanew.com/api/serverless-train/v1/task
Authorizations
Authorizations:StringHeaderRequired
用户可通过已获取Serverless API Key做验证,例如:plain Credential=[YOUR_AK],Signature=[YOUR_SK]。
Body
application/json
name:StringRequired
任务名称,例如:my-debug。
type:StringRequired
任务类型为task,默认值为task。
templateId:String
模板ID。
extensions:Map<String,String>
用于传入客户自定义extensions用作后续任务查询。
config:Object
Response
状态码:application/json
200
code:Int
code是一种常见的返回值形式,表示查询操作的执行结果。
0
非0
0是成功标识,表示操作成功完成。
data:Object
data.id:String
任务ID。
msg:String
code返回值为-1时,返回异常信息。
cURL
Python
JavaScript
Go
Java
curl -X POST 'https://api.alayanew.com/api/serverless-train/v1/task'
-H 'Authorization: plain Credential=YOUR_AK,Signature=YOUR_SK'
-H 'Content-Type: application/json'
-d '{
"name": "my-debug",
"type": "task",
"templateId": "5df0ef3c-252a-44c8-aba3-a87e23615c76",
"config": {
"cmd": ["bash", "-c", "python3 main.py"],
"resource": {
"cpu": 2,
"mem": 8,
"gpu": {
"count": 1,
"gpuType": "nvidia.com/gpu-tesla-p4"
},
"epheneralStorage": 32
},
"image": "registry.hd-01.alayanew.com/aladdin/python:3.13",
"vksId": "vc3jedd7crnd",
"namespace": "default"
}
}'
200
400
401
403
404
500
{
"code": 0,
"data": {
"id": "6ef0ef3c-252a-44c8-aba3-a87e23615c76"
}
}
提示
-
如果同时提供了
templateId
和config
对象,系统将基于templateId
指定的模板创建任务,并使用config
对象中的参数对模板内容进行覆盖和更新。 -
如果仅提供了
templateId
而未提供config
对象,系统将直接使用templateId
对应的模板创建任务。