示例#1
0
start = 30
end = 40

pathToInputFiles = batchJob.pathToInputFiles()

inputFile1relPath = pathToInputFiles+'inputFile1.txt ' 
inputFile2relPath = pathToInputFiles+'inputFile2.txt' 

for i in range(start, end):
    # create a unique jobname for every job
    jobname = batchJobName+"_"+ str(i)
    
    print 'Creating job: '+jobname
    
    # create the single job
    job = JobObject(si)
    job.setJobname(jobname)
    # better to set the application to use explicitely because in that case we don't need to use mds (faster)
    job.setApplication('UnixCommands')
    job.setCommandline('cat '+ inputFile1relPath + ' ' + inputFile2relPath)

    job.setWalltimeInSeconds(60)
    # adding the job to the multijob
    batchJob.addJob(job)

# only start the newly added jobs and wait for the restart to finish
batchJob.restart(False, False, True, True)


# don't forget to exit properly. this cleans up possible existing threads/executors
sys.exit()
示例#2
0
    jobname = multiJobName+"_"+ str(i)
    # create the single job
    job = JobObject(si)
    #job.setSubmissionLocation("")
    job.setJobname(jobname)
    # better to set the application to use explicitely because in that case we don't need to use mds (faster)
    job.setApplication("java")
    job.setCommandline("java -version")
    # setting the commandline. In this example we reference to both types of possible input files
    #job.setCommandline("java -jar "+pathToInputFiles+"/JavaTestJob.jar 30 1")
    # adding a job-specific input file
    #job.addInputFileUrl("/home/markus/test/singleJobFile.txt")
    # the walltime for the job. Can be set individually or for the multijob (which would have to be done later)
    job.setWalltimeInSeconds(60)
    # adding the job to the multijob
    multiPartJob.addJob(job)
    
multiPartJob.setDefaultNoCpus(1);
multiPartJob.setDefaultWalltimeInSeconds(60);   
    
# now we add an input file that is common to all jobs
#multiPartJob.addInputFile("/home/markus/sample input files/JavaTestJob.jar");
# we don't want to submit to tpac because it doesn't work
#multiPartJob.setSitesToExclude(["uq", "hpsc", "auckland", "canterbury"]);
    
try:
    print "Creating jobs on the backend and staging files..."
    multiPartJob.prepareAndCreateJobs(True)
except (JobsException), error:
    for job in error.getFailures().keySet():
        print "Job: "+job.getJobname()+", Error: "+error.getFailures().get(job).getLocalizedMessage()