Create Task
Create single-node or distributed training tasks.
POST
https://api.alayanew.com/api/serverless-train/v1/task
Authorizations
Authorizations:StringHeaderRequired
用户可通过已获取Open API Key做验证,例如:plain Credential=[YOUR_AK],Signature=[YOUR_SK]。
Body
application/json
name:StringRequired
Task name, e.g., my-debug.
type:StringRequired
Task type is 'task', default value is 'task'.
templateId:String
Template ID.
extensions:Map<String,String>
Used to pass custom customer extensions for subsequent task queries.
config:Object
Response
状态码:application/json
200
code:Int
code is a common return value form, representing the execution result of the query operation.
0
Non-zero
0 is the success identifier, indicating the operation completed successfully.
data:Object
data.id:String
Task ID.
msg:StringRequired
Returns exception information when the code return value is -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"
}
}
tip
-
如果同时提供了
templateId和config对象,系统将基于templateId指定的模板创建任务,并使用config对象中的参数对模板内容进行覆盖和更新。 -
如果仅提供了
templateId而未提供config对象,系统将直接使用templateId对应的模板创建任务。