快速入门

调用流程说明

需要首先调用认证API接口,获取token访问凭证,在后续API调用时都需要携带此token

提交作业

  1. 调用获取访问凭证接口,获取用户可访问区域token,后续API调用均需要携带此token
  2. 调用获取授权区域接口,获取可访问区域url信息,用于后续文件上传、作业提交、文件下载等
  3. 调用上传文件接口,上传本地文件到云端服务器
  4. 调用查询集群信息接口,获取该集群调度器ID,用户后续提交作业需使用
  5. 调用查询用户可访问队列接口,查询用户的可访问队列,用于后续提交作业
  6. 调用提交作业接口,进行作业提交
  7. 调用查询实时作业详情接口,可以查看作业详情信息
  8. 调用下载文件/文件夹接口,下载作业输出结果文件

创建容器

  1. 调用获取访问凭证接口,获取用户可访问区域token,后续API调用均需要携带此token
  2. 调用获取授权区域接口,获取容器服务的url地址
  3. 调用查询节点资源限额接口,获取用户节点资源配置
  4. 调用创建容器实例接口,创建容器实例
  5. 调用批量执行脚本接口,根据容器实例ID批量执行脚本
  6. 调用查询容器实例详情接口,可以查看容器实例详情信息
  7. 调用批量删除容器接口,可以删除已经创建的容器

提交作业指导示例

我们将通过API提交一个基本的作业,首先请确保您已经获取了token并获取各授权区域地址,替换本入门中的token

获取访问凭证

通过API获取用户认证token,后续API接口使用都需要依赖此token

curl --location --request POST 'https://api01.xxx.com:65102/ac/openapi/v2/tokens' \
--header 'Content-Type: application/json' \
--header 'user: test' \
--header 'password: test' \
--header 'orgid: 6048ce7ba15c2af2e8cec12991ec13cf'
{
    "code":"0",
    "msg":"success",
    "data":[
        {
            "clusterId":"11112",
            "clusterName":"OpenAPI计算中心",
            "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODY5NjY2MzU4MzEiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.SyyeU67QPWsYjf20DwGYR2UmvvfPX9G9qVoVcZSL"
        },
        {
            "clusterId":"0",
            "clusterName":"ac",
            "token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjcmVhdG9yIjoiYWMiLCJyb2xlIjoiMSIsImV4cGlyZVRpbWUiOiIxNjg2OTY2NjM1ODMyIiwiY2x1c3RlcklkIjoiMCIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.jXfTNDpBKceHCML--xOFb5YYWPy9xFx5kCJ2Yf9T"
        }
    ]
}

获取授权区域

获取用户授权区域地址:hpcUrls为作业API调用使用url;efileUrls为文件API调用使用url;aiUrls为容器API调用使用url

curl --location 'https://api01.xxx.com:65102/ac/openapi/v2/center' \
--header 'Content-Type: application/json' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODc0MDA0MDU4OTciLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.zvq5E3ZGfJH4hYcxnMrYusfCoageP92nIUBKhmagLso'
{
    "code":"0",
    "msg":"success",
    "data":{
        "id":11112,
        "name":"OpenAPI计算中心",
        "description":"对外OpenAPI中心",
        "clusterUserInfo": {
          "userName": "test",
          "homePath": "/public/home/test"
        },
        "ingressUrls":[
            {
                "enable":"true",
                "isManagerNode":"true",
                "version":"5.2.7",
                "url":"https://api01.xxx.com:65106"
            }
        ],
        "efileUrls":[
            {
                "nodeName":"h04r3n07",
                "enable":"true",
                "fastTransEnable":"true",
                "udpPort":"65104",
                "version":"2.7.0",
                "url":"https://api01.xxx.com:65103/efile"
            }
        ],
        "eshellUrls":[
            {
                "enable":"true",
                "version":"2.4.3",
                "url":"https://api01.xxx.com:65106"
            }
        ],
        "hpcUrls":[
            {
                "enable":"true",
                "isManagerNode":"true",
                "version":"5.3.0",
                "url":"https://api01.xxx.com:65106"
            }
        ],
        "aiUrls":[
            {
                "enable":"true",
                "version":"2.4.3",
                "url":"https://api01.xxx.com:65106"
            }
        ],
        "eshellSshHosts":[
            {
                "enable":"true",
                "url":"h04r3n07:22"
            }
        ],
        "clusterUserInfo":{
            "userName":"test",
            "homePath":"/public/home/test"
        }
    }
}

上传文件

上传本地文件到平台,如果文件过大,可以参考分片上传的API

curl --location 'https://api01.xxx.com:65103/efile/openapi/v2/file/upload' \
--header 'Content-Type: application/json' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODc0MDA0MDU4OTciLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.zvq5E3ZGfJH4hYcxnMrYusfCoageP92nIUBKhmagLso' \
--header 'Cookie: SESSION=YWJhNzMyOTUtNmQ4Mi00NjlmLWI4ZTctZDg5ZGYwYzU2ZGEx' \
--form 'cover="cover"' \
--form 'file=@"/Users/Downloads/test/test.txt"' \
--form 'path="/public/home/test/BASE"'
{
    "code":"0",
    "data":null,
    "msg":"success"
}

查询集群信息

获取集群的调度器id,提交作业使用

curl --location 'https://api01.xxx.com:65106/hpc/openapi/v2/cluster' \
--header 'Content-Type: application/json' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODc0MDA0MDU4OTciLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.zvq5E3ZGfJH4hYcxnMrYusfCoageP92nIUBKhmagLso'
{
    "code":"0",
    "msg":"success",
    "data":[
        {
            "JobManagerAddr":"10.8.150.45",
            "JobManagerType":"SLURM",
            "id":1638523853,
            "text":"Cluster",
            "JobManagerPort":"9091"
        }
    ]
}

查询用户可访问队列

查询用户可访问队列,提交作业使用

curl --location 'https://api01.xxx.com:65106/hpc/openapi/v2/queuenames/users/test?strJobManagerID=1638523853' \
--header 'Content-Type: application/json' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODc0MDEyNzc2NzQiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.Y6SexsPn0gsAR8nflKRO7Rd4jVFtXHY-qvYnKa6MArg'
{
    "code": "0",
    "msg": "success",
    "data": [
        {
            "queFreeNcpus": "32",
            "queNodes": "1",
            "queNcpus": "32",
            "queMaxNgpus": "-1",
            "queMaxPPN": "32",
            "queChargeRate": "1.0",
            "queMaxNcpus": "-1",
            "aclHosts": "h04r3n07",
            "queMaxNdcus": "-1",
            "queueName": "debug",
            "queMaxNmlus": "-1",
            "queFreeNodes": "1",
            "queMaxNodect": "-1",
            "queMaxGpuPN": "0",
            "id": "debug",
            "text": "debug",
            "queMaxWalltime": "-1",
            "queMaxDcuPN": "4"
        },
        {
            "queFreeNcpus": "64",
            "queNodes": "2",
            "queNcpus": "64",
            "queMaxNgpus": "-1",
            "queMaxPPN": "32",
            "queChargeRate": "1.0",
            "queMaxNcpus": "-1",
            "aclHosts": "h04r3n07,h04r3n19",
            "queMaxNdcus": "-1",
            "queueName": "debug2",
            "queMaxNmlus": "-1",
            "queFreeNodes": "2",
            "queMaxNodect": "-1",
            "queMaxGpuPN": "0",
            "id": "debug2",
            "text": "debug2",
            "queMaxWalltime": "-1",
            "queMaxDcuPN": "4"
        }
    ]
}

提交作业

传入作业参数,进行作业提交,作业提交成功后会返回作业ID,通过作业ID可以查询作业的详细信息

curl --location 'https://api01.xxx.com:65106//hpc/openapi/v2/apptemplates/BASIC/BASE/job' \
--header 'Content-Type: application/json' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODc0MDEyNzc2NzQiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.Y6SexsPn0gsAR8nflKRO7Rd4jVFtXHY-qvYnKa6MArg' \
--data '{
    "strJobManagerID":"1638523853",
    "mapAppJobInfo":{
        "GAP_SUBMIT_TYPE":"sched",
        "GAP_JOB_NAME":"test_0615_000001",
        "GAP_PPN":"1",
        "GAP_NODE_TYPE":"",
        "GAP_NNODE":"1",
        "GAP_WALL_TIME":"72:00:00",
        "GAP_WORK_DIR":"/public/home/test/BASE/test_0615_000001",
        "GAP_SCHED_FILE":"/public/home/test/BASE/test/job_BASE.slurm",
        "GAP_MULTI_SUB":"",
        "GAP_STD_OUT_FILE":"/public/home/test/BASE/test_0615_000001/std.out.%j",
        "GAP_STD_ERR_FILE":"/public/home/test/BASE/test_0615_000001/std.err.%j",
        "GAP_JOB_MEM":"",
        "GAP_NGPU":"",
        "GAP_NDCU":"",
        "GAP_QUEUE":"debug",
        "GAP_CLUSTER_ID":"11112",
        "GAP_GUI":0,
        "advance":false
    }
}'
{
    "code": "0",
    "msg": "success",
    "data": "36082"
}

查看实时作业详情

根据作业ID可以查询作业的详细信息

curl --location 'https://api01.xxx.com:65106/hpc/openapi/v2/jobs/36089' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODc0MDEyNzc2NzQiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.Y6SexsPn0gsAR8nflKRO7Rd4jVFtXHY-qvYnKa6MArg'
{
    "code": "0",
    "msg": "success",
    "data": {
        "jobId": "36082",
        "jobName": "STDIN_0910_094758",
        "jobStatus": "statR",
        "queue": "debug",
        "user": "test",
        "jobSubmitTime": "2023-06-15 17:55:56",
        "jobStartTime": "2023-06-15 17:55:56",
        "jobEndTime": null,
        "exitCode": null,
        "nodeUsed": "h04r3n07",
        "procNumUsed": 1,
        "gpuNumUsed": 0,
        "dcuNumUsed": null,
        "memUsed": "3826M",
        "cpuTimeUsed": null,
        "jobRunTime": "00:02:49",
        "walltimeReq": "1-00:00:00",
        "nodeNumReq": 1,
        "procNumReq": 1,
        "gpuNumReq": 0,
        "dcuNumReq": null,
        "workDir": "/public/home/test/BASE/test_0615_000001",
        "errorPath": "/public/home/test/BASE/test_0615_000001/std.err.36082",
        "outputPath": "/public/home/test/BASE/test_0615_000001/std.out.36082",
        "priority": "1000",
        "account": null,
        "appType": "BASE",
        "scale": null,
        "jobVncSessionInfo": null,
        "jobInitAttr": {
            "Account": "test",
            "DelayBoot": "00:00:00",
            "ExitCode": "0:0",
            "MinCPUsNode": "1 MinMemoryCPU=3826M",
            "Licenses": "(null)",
            "TRES": "cpu=1,mem=3826M,node=1,billing=1",
            "NtasksPerN:B:S:C": "0:0:*:*",
            "Network": "(null)",
            "JobState": "RUNNING",
            "Requeue": "1",
            "CoreSpec": "*",
            "ExcNodeList": "(null)",
            "Contiguous": "0",
            "SuspendTime": "None",
            "Priority": "1000",
            "Restarts": "0",
            "Deadline": "N/A",
            "NodeList": "h04r3n07",
            "StartTime": "2023-06-15T17:55:56",
            "Dependency": "(null)",
            "ReqB:S:C:T": "0:0:*:*",
            "SubmitTime": "2023-06-15T17:55:56",
            "BatchFlag": "1",
            "SecsPreSuspend": "0 LastSchedEval=2023-06-15T17:55:56",
            "WorkDir": "/public/home/test/BASE/test_0615_000001",
            "NumCPUs": "1",
            "NumNodes": "1",
            "TimeMin": "N/A",
            "RunTime": "00:02:49",
            "EndTime": "2023-06-16T17:55:56",
            "JobName": "STDIN_0910_094758",
            "Reason": "None",
            "StdIn": "/dev/null",
            "StdErr": "/public/home/test/BASE/test_0615_000001/std.err.36082",
            "AllocNode:Sid": "h04r3n07:5264",
            "OverSubscribe": "OK",
            "MCS_label": "N/A",
            "Nice": "0",
            "Features": "(null)",
            "JobId": "36082",
            "TimeLimit": "1-00:00:00",
            "EligibleTime": "2023-06-15T17:55:56",
            "Partition": "debug",
            "Socks/Node": "*",
            "Comment": "BASE",
            "ReqNodeList": "(null)",
            "MinTmpDiskNode": "0",
            "NumTasks": "1",
            "GroupId": "test(2000)",
            "Reboot": "0",
            "QOS": "user_test",
            "CommandExist": "true",
            "Command": "/public/home/test/BASE/test_0615_000001/job_BASE.slurm",
            "UserId": "test(2000)",
            "BatchHost": "h04r3n07",
            "StdOut": "/public/home/test/BASE/test_0615_000001/std.out.36082",
            "AccrueTime": "2023-06-15T17:55:56",
            "CPUs/Task": "1",
            "Power": ""
        },
        "jobmanagerId": "1638523853",
        "jobmanagerName": "Cluster",
        "jobmanagerType": "SLURM",
        "restarts": "0",
        "aveVMSize": "221140K",
        "aveRSS": "1808K|"
    }
}

下载作业结果文件

根据作业输出目录,可以下载作业的输出文件

curl --location 'https://api01.xxx.com:65103/efile/openapi/v2/file/download?path=%2Fpublic%2Fhome%2Ftest%2FBASE%2Fluan.pdf' \
--header 'Content-Type: application/json' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb21wdXRlVXNlciI6InNsdXJtdGVzdCIsImFjY291bnRTdGF0dXMiOiJUcmlhbCIsImNyZWF0b3IiOiJhYyIsInJvbGUiOiIxIiwiZXhwaXJlVGltZSI6IjE2ODU2MDAyMjU2MTUiLCJjbHVzdGVySWQiOiIxMTExMiIsImludm9rZXIiOiI2MDQ4Y2U3YmExNWMyYWYyZThjZWMxMjk5MWVjMTNjZiIsInVzZXIiOiJzbHVybXRlc3QiLCJ1c2VySWQiOiIxMTY1NTA0ODU0MSJ9.iLCKJ8PnDDK0_SA2NPYm1WozUG8D5ojwFqFhwaJCDc8' \
--header 'Cookie: SESSION=YWJhNzMyOTUtNmQ4Mi00NjlmLWI4ZTctZDg5ZGYwYzU2ZGEx'

results matching ""

    No results matching ""