作业

提交作业

1.接口说明

接口路径:/hpc/openapi/v2/apptemplates/{apptype}/{appname}/job

请求方式:POST

请求数据类型:application/json

接口描述:提交普通作业,成功后返回作业ID

备注:接口方法的{apptype}为BASIC,{appname}为BASE;输入参数的GAP_APPNAME支持填写该作业的英文应用名称

2.请求消息

请求参数:

Headers:

名称 类型 必填 描述 示例
tokenstring接口凭证eyJhbGciOiJIUzI1N...

参数:

名称 类型 必填 描述 示例
apptypestring应用类型BASIC
appnamestring应用名称BASE
strJobManagerIDLong调度器ID1638523853
mapAppJobInfoobject作业对象
GAP_CMD_FILEstring命令行内容(如需换行,请使用\n)sleep 500
GAP_NNODEstring节点个数(当指定该参数时,GAP_NODE_STRING必须为"")1
GAP_NODE_STRINGstring指定节点(当指定该参数时,GAP_NNODE必须为"")
GAP_SUBMIT_TYPEstringcmd(命令行模式)cmd
GAP_JOB_NAMEstring作业名称STDIN_0910_094758
GAP_WORK_DIRstring工作路径/public/home/test/BASE/STDIN_1210_114429
GAP_QUEUEstring队列名称debug
GAP_NPROCstring总核心数(GAP_NPROC和GAP_PPN选其一填写)
GAP_PPNstringCPU核心/节点(GAP_NPROC和GAP_PPN选其一填写)1
GAP_NGPUstringGPU卡数/节点
GAP_NDCUstringDCU卡数/节点
GAP_JOB_MEMstring每个节点内存值,单位为MB/GB
GAP_WALL_TIMEstring最大运行时长(HH:MM:ss)24:00:00
GAP_EXCLUSIVEstring是否独占节点,1为独占,空为非独占
GAP_APPNAMEstringBASE(基础应用),支持填写具体的应用英文名称BASE
GAP_MULTI_SUBstring作业组长度,建议为小于等于50的正整数
GAP_STD_OUT_FILEstring工作路径/std.out.%j/public/home/test/BASE/STDIN_1210_114429/std.out.%j
GAP_STD_ERR_FILEstring工作路径/std.err.%j/public/home/test/BASE/STDIN_1210_114429/std.err.%j

3.请求示例

cURL请求示例

curl --location 'https://api01.xxx.com:65106/hpc/openapi/v2/apptemplates/BASIC/BASE/job' \
--header 'Content-Type: application/json' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODYwMzY3NjA5NTQiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.f7nvKA2DqTsXjqF90zblMhwx0zKPpITY0uuSG2ouKG0' \
--data '{
    "strJobManagerID":"1638523853",
    "mapAppJobInfo":{
        "GAP_CMD_FILE":"sleep 500",
        "GAP_NNODE":"1",
        "GAP_NODE_STRING":"",
        "GAP_SUBMIT_TYPE":"cmd",
        "GAP_JOB_NAME":"STDIN_0910_094758",
        "GAP_WORK_DIR":"/public/home/test/BASE/STDIN_0531_134514",
        "GAP_QUEUE":"debug2",
        "GAP_NPROC":"1",
        "GAP_PPN":"",
        "GAP_NGPU":"",
        "GAP_NDCU":"",
        "GAP_WALL_TIME":"24:00:00",
        "GAP_EXCLUSIVE":"",
        "GAP_APPNAME":"BASE",
        "GAP_MULTI_SUB":"",
        "GAP_STD_OUT_FILE":"/public/home/test/BASE/STDIN_0531_134514/std.out.%j",
        "GAP_STD_ERR_FILE":"/public/home/test/BASE/STDIN_0531_134514/std.err.%j"
        }
}'

Java请求示例

import okhttp3.*;

public class SubmitJobDemo {

    public static final String URL = "https://api01.xxx.com:65106/hpc/openapi/v2/apptemplates/BASIC/BASE/job";
    public static final String TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODY5MDg1MDkyMzEiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.U7pZKgO_K6NuRwOWPxblDfgRpGeVxS-BYieOdLhGDK4";


    public static void main(String[] args) throws Exception {
        OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
        MediaType mediaType = MediaType.parse("application/json");
        RequestBody body = RequestBody.create(mediaType, "{\n    \"strJobManagerID\":\"1638523853\",\n    \"mapAppJobInfo\":{\n        \"GAP_CMD_FILE\":\"sleep 500\",\n        \"GAP_NNODE\":\"1\",\n        \"GAP_NODE_STRING\":\"\",\n        \"GAP_SUBMIT_TYPE\":\"cmd\",\n        \"GAP_JOB_NAME\":\"STDIN_0910_094758\",\n        \"GAP_WORK_DIR\":\"/public/home/test/BASE/STDIN_0531_134514\",\n        \"GAP_QUEUE\":\"debug2\",\n        \"GAP_NPROC\":\"1\",\n        \"GAP_PPN\":\"\",\n        \"GAP_NGPU\":\"\",\n        \"GAP_NDCU\":\"\",\n        \"GAP_WALL_TIME\":\"24:00:00\",\n        \"GAP_EXCLUSIVE\":\"\",\n        \"GAP_APPNAME\":\"BASE\",\n        \"GAP_MULTI_SUB\":\"\",\n        \"GAP_STD_OUT_FILE\":\"/public/home/test/BASE/STDIN_0531_134514/std.out.%j\",\n        \"GAP_STD_ERR_FILE\":\"/public/home/test/BASE/STDIN_0531_134514/std.err.%j\"\n        }\n}");
        Request request = new Request.Builder()
                .url(URL)
                .method("POST", body)
                .addHeader("Content-Type", "application/json")
                .addHeader("token", TOKEN)
                .build();
        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}

Python请求示例

import requests
import json

url = "https://api01.xxx.com:65106/hpc/openapi/v2/apptemplates/BASIC/BASE/job"

payload = json.dumps({
  "strJobManagerID": "1638523853",
  "mapAppJobInfo": {
    "GAP_CMD_FILE": "sleep 500",
    "GAP_NNODE": "1",
    "GAP_NODE_STRING": "",
    "GAP_SUBMIT_TYPE": "cmd",
    "GAP_JOB_NAME": "STDIN_0910_094758",
    "GAP_WORK_DIR": "/public/home/test/BASE/STDIN_0531_134514",
    "GAP_QUEUE": "debug2",
    "GAP_NPROC": "1",
    "GAP_PPN": "",
    "GAP_NGPU": "",
    "GAP_NDCU": "",
    "GAP_WALL_TIME": "24:00:00",
    "GAP_EXCLUSIVE": "",
    "GAP_APPNAME": "BASE",
    "GAP_MULTI_SUB": "",
    "GAP_STD_OUT_FILE": "/public/home/test/BASE/STDIN_0531_134514/std.out.%j",
    "GAP_STD_ERR_FILE": "/public/home/test/BASE/STDIN_0531_134514/std.err.%j"
  }
})
headers = {
  'Content-Type': 'application/json',
  'token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODYwMzY3NjA5NTQiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.f7nvKA2DqTsXjqF90zblMhwx0zKPpITY0uuSG2ouKG0'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

4.响应消息

返回参数:

名称 类型 描述 示例
msgstring信息操作成功
codestring0:成功,1003:参数异常,601009:区域用户不存在,1030:权限不足,1001:其它异常0
dataobject作业号

返回示例:

{
    "code": "0", 
    "msg": "success", 
    "data": "148"
}

5.错误码

错误码 说明
0 成功
10001 内部错误
10003 参数不全
10004 参数无效
10007 用户已被冻结
10008 权限不足
10009 没有权限访问接口
10010 文件校验失败
10011 文件过大
10012 连接中断
10013 操作超时
815005 作业提交失败(调度系统没返回)
815007 作业提交失败(调度系统sbatch失败)

results matching ""

    No results matching ""