批量预测(用户资源池)API
更新时间:2023-12-15
批量预测API
本文将介绍批量预测(用户资源池)的API,您如果是初次使用相关产品,可以参考相关指南。
鉴权机制
在使用API前,您需要完成鉴权操作,可以参考鉴权认证机制中的介绍。
接口详细介绍
平台开放了5个API供用户调用:
- 批量预测-创建
- 批量预测-停止
- 批量预测-删除
- 批量预测-作业列表
- 批量预测-作业详情
【批量预测-创建】
接口:https://aip.baidubce.com/rpc/2.0/easydl/pro/predict/create
method: post
请求参数:
| 参数 | 是否必选 | 类型 | 可选值 | 说明 |
|---|---|---|---|---|
| name | 是 | string | - | 作业名称,1-50个字符,不能有表情字符 |
| description | 是 | string | - | 作业描述, 1-500个字符,不能有表情字符 |
| train_config | 是 | map | 训练配置项 | |
| + env_type | 是 | string | CCR:百度CCR镜像环境;OUTERIMAGE:外部镜像;CUSTOM:自定义镜像 | 训练环境类型 |
| + env_image_id | 否 | string | - | 自定义镜像的ID,自定义镜像下必选 |
| + model_path | 是 | string | - | 模型文件输入路径 |
| + model_path_source | 是 | Int | 1:BOS路径;2:PFS路径 | 模型文件输入路径类型 |
| + code_path | 是 | string | - | 启动代码路径,可在自定义镜像中定义训练代码,通过启动命令来使用镜像中的训练代码 |
| + code_path_source | 是 | Int | 1:BOS路径;2:PFS路径 | 启动代码路径类型 |
| + start_cmd | 否 | string | - | 启动命令 |
| + image | 否 | string | - | 镜像,百度CCR镜像下必选,eg:/ns-project/paddle |
| + tag | 否 | string | - | tag,百度CCR镜像下必选 |
| + repository_id | 否 | string | - | BML平台绑定的仓库的ID,外部镜像下必选 |
| dataset_config | 是 | map | 数据集配置项 | |
| + input_file | 否 | string | - | 输入文件路径,可在自定义镜像中定义 |
| + input_file_source | 否 | tring | 1:BOS路径;2:PFS路径 | 输入文件路径类型 |
| + output_file | 否 | string | - | 输出文件路径 |
| + output_file_source | 否 | string | 1:BOS路径;2:PFS路径 | 输出文件路径类型 |
| resource_config | 是 | map | 资源池配置项 | |
| + node_count | 是 | int | - | 节点数 |
| + resource_name | 是 | string | 租户资源池请填写在BML平台注册的资源池名称 | 资源池名称 |
| + gpu_type | 否 | string | NVIDIA_深度学习开发卡, NVIDIA_Tesla_V100-32G, NVIDIA_Tesla_V100-16G, NVIDIA_Tesla_P40, NVIDIA_Tesla_P4, NVIDIA_Tesla_K40, NVIDIA_Tesla_A100, NVIDIA_Tesla_A10, NVIDIA_Tesla_A30 | 加速卡名称 |
| + gpu_num | 否 | int | - | 加速卡数量,单位张 |
| + cpu_num | 否 | int | - | cpu数量,单位核 |
| + memory | 否 | int | - | 内存,单位G |
| prjId | 是 | string | - | 项目ID |
返回:
| 参数 | 类型 | 说明 |
|---|---|---|
| result | int | 作业ID |
| log_id | int | 日志ID |
【批量预测-停止】
接口:https://aip.baidubce.com/rpc/2.0/easydl/pro/predict/stop
method: post
参数:
| 参数 | 是否必选 | 类型 | 参数位置 | 可选值 | 说明 |
|---|---|---|---|---|---|
| id | 是 | int | RequestBody | - | 作业ID |
| prjId | 是 | string | RequestBody | - | 项目ID |
返回:
| 参数 | 类型 | 说明 |
|---|---|---|
| log_id | int | 日志ID |
| result | bool | 是否停止成功 |
【批量预测-删除】
接口:https://aip.baidubce.com/rpc/2.0/easydl/pro/predict/delete
method: post
参数:
| 参数 | 是否必选 | 类型 | 参数位置 | 可选值 | 说明 |
|---|---|---|---|---|---|
| id | 是 | int | RequestBody | - | 作业ID |
| prjId | 是 | string | RequestBody | - | 项目ID |
返回:
| 参数 | 类型 | 说明 |
|---|---|---|
| log_id | int | 日志ID |
| result | bool | 是否删除成功 |
【批量预测-作业列表】
接口:https://aip.baidubce.com/rpc/2.0/easydl/pro/predict/list
method: post
参数:
| 参数 | 是否必选 | 类型 | 参数位置 | 可选值 | 说明 |
|---|---|---|---|---|---|
| start | 是 | int | RequestBody | - | 分页offset值,缺损值为1 |
| num | 是 | int | RequestBody | - | 分页limit值,缺损值为20 |
| prjId | 是 | string | RequestBody | - | 项目ID |
返回:
| 参数 | 类型 | 说明 |
|---|---|---|
| total | int | - |
| id | int | 作业ID |
| name | string | 作业名称 |
| status | string | 训练状态:UNTRAIN(编辑中未训练的), SUCCESSED(训练完成), RUNNING(训练中),STOPPED(训练终止),FAILED(训练失败) |
| resource_info | map | 资源池信息 |
| +name | string | 资源池名称,为空表示资源池已删除 |
| + poolId | string | 资源池ID |
| create_time | int | 创建时间 |
| log_id | int | 日志ID |
【批量预测-作业详情】
接口:https://aip.baidubce.com/rpc/2.0/easydl/pro/predict/detail
method: post
参数:
| 参数 | 是否必选 | 类型 | 参数位置 | 可选值 | 说明 |
|---|---|---|---|---|---|
| id | 是 | int | RequestBody | - | 作业ID |
| prjId | 是 | string | RequestBody | - | 项目ID |
返回:
| 参数 | 类型 | 说明 |
|---|---|---|
| id | int | - |
| name | string | 作业名称 |
| description | string | 作业描述 |
| status | string | 训练状态:UNTRAIN(编辑中未训练的), SUCCESSED(训练完成), RUNNING(训练中),STOPPED(训练终止),FAILED(训练失败) |
| create_time | int | 创建时间 |
| train_config | map | 训练配置 |
| + code_path | string | 启动代码路径 |
| + start_cmd | string | 启动命令 |
| + env_type | string | 训练配置项:训练环境类型。CCR:百度CCR镜像环境;OUTERIMAGE:外部镜像;CUSTOM:自定义镜像 |
| + env_image | string | 训练配置项:镜像、tag |
| + env_image_id | string | 训练配置项:镜像id |
| + distribute_strategy | string | 训练配置项:分布式策略,默认返回PaddleFleet |
| + repository_id | string | 训练配置项:镜像对应在BML平台绑定的仓库的ID |
| resource_config | map | 资源池配置项 |
| + node_count | int | 节点数 |
| + resource_type | string | 资源池类型:USER |
| + resource_name | string | 资源池名称 |
| + gpu_type | string | 加速卡 |
| + gpu_num | int | 加速卡数量,单位张 |
| + cpu_num | string | cpu数量,单位核 |
| + memory | int | 内存,单位G |
| dataset_config | map | 数据集配置项 |
| + input_path | string | 输入文件地址 |
| + output_path | string | 输出文件地址 |
| log_id | int | 日志ID |
错误码说明
| 错误码 | 错误信息 |
|---|---|
| 406000 | internal server error |
| 406001 | param[%s] invalid |
| 406008 | [%s] quota exceeded |
| 406012 | job does not exist |
| 406013 | job stop failed |
| 406014 | job can not delete |
| 406015 | job name cannot be empty |
| 406016 | the job name is too long |
| 406017 | job description cannot be empty |
| 406018 | job description is too long |
| 406019 | code file address error |
| 406020 | startup command error |
| 406021 | output path error |
| 406022 | training dataset address error |
| 406023 | test dataset address error |
| 406024 | illegal language version |
| 406025 | illegal language version |
| 406026 | job name already exists |
| 406027 | job status exception |
| 406028 | resource type error |
| 406029 | there is no remaining free quota, please activate payment or recharge |
| 406030 | missing image parameters |
| 406031 | missing tag parameters |
| 406032 | missing distributed strategy parameter |
| 406033 | image registry is incorrect |
| 406034 | training environment error |
| 406035 | the %s quantity has reached the upper limit |
| 406036 | the emoji character is not supported |
| 406037 | no operation permission |
| 406038 | parameter too long |
| 406039 | resource pool does not exist |
| 406040 | node over limit |
| 406041 | cpu over limit |
| 406042 | memory over limit |
| 406043 | gpu over limit |
| 406044 | repository image invalid |
| 406045 | pool do not support the service |
| 406046 | predict name already exists |
| 407047 | predict not exist |
| 406048 | task not exist |
| 406049 | stop failed |
