submitJob

Syntax

submitJob(jobId, jobDesc, jobDef, args...)

Arguments

jobId is a string indicating the job ID.

jobDesc is a string indicating job description.

jobDef is a local function that defines the job. Please note that it is not the function name, and therefore it should not be quoted.

args... is the arguments of the function. If the function has no arguments, it is unspecified.

Details

Submit a batch job to the local node and return the job ID for future reference. To submit a batch job to a remote node, please use submitJob together with rpc or remoteRun. For details please refer to the section of BatchJobManagement.

Examples

The following script submits a job to the local node:

def jobDemo(n){
    s = 0
    for (x in 1 : n) {
        s += sum(sin rand(1.0, 100000000)-0.5)
        print("iteration " + x + " " + s)
    }
    return s
};

submitJob("jobDemo1","job demo", jobDemo, 100);
// output
jobDemo1

getJobStatus("jobDemo1");
node userID jobId jobDesc priority parallelism receivedTime startTime endTime errorMsg
local8848 guest jobDemo1 job demo 0 1 2020.09.13T13:40:10.138 2020.09.13T13:40:10.139

endTime is empty. This means the job is still running. After the job finishes, endTime will have a value.

getJobStatus("jobDemo1");
node userID jobId jobDesc priority parallelism receivedTime startTime endTime errorMsg
local8848 guest jobDemo1 job demo 0 1 2020.09.13T13:40:10.138 2020.09.13T13:40:10.139 2020.09.13T13:41:43.644
getJobMessage("jobDemo1");

// output
2020-09-13 13:40:10.139269 Start the job [jobDemo1]: job demo
2020-09-13 13:40:11.159543 iteration 1 3914.672836
2020-09-13 13:40:12.118014 iteration 2 4263.240185
2020-09-13 13:40:13.069435 iteration 3 4006.833021
......
2020-09-13 13:41:41.769256 iteration 97 -1897.963368
2020-09-13 13:41:42.706748 iteration 98 -2455.003061
2020-09-13 13:41:43.640253 iteration 99 924.915703
2020-09-13 13:41:43.640253 The job is done.

getJobReturn("jobDemo1");
// output
924.915703

submitJob("jobDemo2",, jobDemo, 10);
// output
jobDemo2

getRecentJobs();
node userID jobId jobDesc priority parallelism receivedTime startTime endTime ErrorMsg
local8848 guest jobDemo1 job demo 0 1 2020.09.13T13:40:10.138 2020.09.13T13:40:10.139 2020.09.13T13:41:43.644
local8848 guest jobDemo2 jobDemo 0 1 2020.09.13T13:58:20.552 2020.09.13T13:58:20.554 2020.09.13T13:58:29.584

The following script submits a job to a remote node:

With function rpc ("DFS_NODE2" is located in the same cluster as the local node):

def jobDemo(n){
    s = 0
    for (x in 1 : n) {
        s += sum(sin rand(1.0, 100000000)-0.5)
        print("iteration " + x + " " + s)
    }
    return s
}

rpc("DFS_NODE2", submitJob, "jobDemo3", "job demo", jobDemo, 10);
// output
Output: jobDemo3


rpc("DFS_NODE2", getJobReturn, "jobDemo3");
// output
Output: -3426.577521

use function remoteRun or remoteRunWithCompression. For example:

conn = xdb("DFS_NODE2")
conn.remoteRun(submitJob, "jobDemo4", "job demo", jobDemo, 10);
// output
Output: jobDemo4

conn.remoteRun(getJobReturn, "jobDemo4");
// output
Output: 4238.832005