Example #1
0
from grisu.frontend.control.login import LoginManager
from grisu.frontend.model.job import JobObject
from grisu.model import GrisuRegistryManager

si = LoginManager.loginCommandline("LOCAL")

appInfo = GrisuRegistryManager.getDefault(si).getApplicationInformation(
    "ImageJ")

print 'app: ' + appInfo.getApplicationName()

for subloc in appInfo.getAvailableAllSubmissionLocations():
    print subloc

job = JobObject(si)
job.setTimestampJobname("imageJ")
job.setApplication("java")
job.setApplication("ImageJ")
job.setCommandline("echo Hello")

job.setSubmissionLocation("normal:ng2.ivec.org")

job.createJob("/ARCS/StartUp")
job.submitJob()

job.waitForJobToFinish(3)

print "Stdout: " + job.getStdOutContent()
print "Stderr: " + job.getStdErrContent()
Example #2
0
from grisu.frontend.control.login import LoginManager
from grisu.frontend.model.job import JobObject

si = LoginManager.loginCommandline("BeSTGRID-DEV")

print "Logged in."

job = JobObject(si)
job.setUniqueJobname("cat_job", si)
job.setCommandline("cat text0.txt")
job.addInputFileUrl("/home/markus/tmp/text0.txt")


job.createJob("/nz/nesi")
# job.setSubmissionLocation('[email protected]:ng2.auckland.ac.nz')
job.submitJob()

print "Job submitted."

job.waitForJobToFinish(10)

print "Job finished. Status: " + job.getStatusString(False)
print "Stdout: " + job.getStdOutContent()
print "Stderr: " + job.getStdErrContent()

job.kill(True)
Example #3
0
            print "Job distribution for restarted jobs:"
            for subLoc in batch_job.getOptimizationResult().keySet():
                resubmitted = True
                print subLoc + " : " + batch_job.getOptimizationResult().get(
                    subLoc)
        else:
            print "Job not restarted (yet)."

    print "Job not finished yet. Waiting..."
    time.sleep(3)

print "Multipartjob " + batch_job.getBatchJobname() + " finished."

# finally, everything is ready. We could do a lot more here, but you get the idea...
for job in batch_job.getJobs():
    print "Job: " + job.getJobname() + ", Status: " + job.getStatusString(
        False)
    print
    print "Stdout: "
    print job.getStdOutContent()
    print
    print "Stderr: "
    print job.getStdErrContent()
    print
    print

print "Finished."

# don't forget to exit properly. this cleans up possible existing threads/executors
sys.exit()
if not os.path.isdir(output_path):
    os.mkdir(output_path)

# This method on the BatchJobObject _should_ download the output files for all the
# jobs into the output_path directory.
# BUT it is currently incomplete and does not work
# See issue at
# batch_jobs.downloadResults(True,output_path,['.txt'],True,False)


for job in batch_jobs.getJobs():
    if job.isSuccessful(True):
        print "INFO: Downloading stdout for " + job.getJobname()
        stdout_file = open(os.path.join(output_path, job.getJobname() + "-stdout.txt"), "w")
        stdout_file.write(job.getStdOutContent())
        stdout_file.close()
        print "INFO: Downloading stderr for " + job.getJobname()
        stderr_file = open(os.path.join(output_path, job.getJobname() + "-stderr.txt"), "w")
        stderr_file.write(job.getStdErrContent())
        stderr_file.close()
    else:
        print "INFO: " + job.getJobname() + "failed! Nothing to download."
print "INFO: Outputs retrieved"

print ("INFO: Kill and clean " + batch_job_name + " jobs")
del_str = ""  # to put in scope
try:
    service_interface.kill(batch_job_name, True)
    status = service_interface.getActionStatus(batch_job_name)
    while not status.isFinished():
Example #5
0
print "Submitting jobs..."
batch_job.submit()


# now we wait for all jobs to be finished, checking for updates every 10 seconds. in real life we would set a much higher check intervall since we don't want to overload
# the backend and also it's not really necessary
batch_job.waitForJobToFinish(10)

print "BatchJob "+batch_job.getJobname()+" finished."

# finally, everything is ready. We could do a lot more here, but you get the idea...
for job in batch_job.getJobs():
    print "Job: "+job.getJobname()+", Status: "+job.getStatusString(False)
    print "Submitted to: "+job.getJobProperty(Constants.SUBMISSION_SITE_KEY)
    print
    print "Stdout: "
    print job.getStdOutContent()
    print
    print "Stderr: "
    print job.getStdErrContent()
    print
    print
    
print "Finished."
    
# don't forget to exit properly. this cleans up possible existing threads/executors
sys.exit()


job_name        = sys.argv[4]
working_directory = sys.argv[5]
output_files    = list()

# get list of output files for this job
for f in sys.argv[6:]:
    output_files.append(f)


print output_files
job = JobObject(si, job_name)

# Save stdout and stderr to files to be read by galaxy
try:
    out = open(outfile, "w")
    out.write(job.getStdOutContent())
    out.close()
except:
    print "Cannot open files to write results to"
    sys.exit(-2)
try:
    err = open(errfile, "w")
    err.write(job.getStdErrContent())
except:
# There is no stderr so just write blank file
    print "No stderr So just writing blakn file"
    err.write("")
    err.close()
try:
    ec = open(error_codefile, "w")
    exit_code = job.getStatus(False) - 1000
Example #7
0
try:
    os.mkdir(output_dir)
    print "INFO: Output directory is " + output_dir
except:
    print "HALT: Could not create output directory " + output_dir
    sys.exit(1)

# Retrieve job output
print "INFO: Downloading output to " + output_dir
for job in jobs:
    if job.isSuccessful(True):
        print "INFO: Downloading stdout for " + job.getJobname()
        stdout_file = open(
            os.path.join(current_dir, output_dir,
                         job.getJobname() + "-stdout.txt"), 'w')
        stdout_file.write(job.getStdOutContent())
        stdout_file.close()
        print "INFO: Downloading stderr for " + job.getJobname()
        stderr_file = open(
            os.path.join(current_dir, output_dir,
                         job.getJobname() + "-stderr.txt"), 'w')
        stderr_file.write(job.getStdErrContent())
        stderr_file.close()
    else:
        print "INFO: " + job.getJobname(
        ) + " was not successful, skipping download"

print "INFO: Kill all jobs to clean up"
for job in jobs:
    print "INFO: Killing " + job.getJobname()
    job.kill(True)