Skip to content

Instantly share code, notes, and snippets.

@oweidner
Created November 10, 2011 02:43
Show Gist options
  • Save oweidner/1353955 to your computer and use it in GitHub Desktop.
Save oweidner/1353955 to your computer and use it in GitHub Desktop.
Bliss Example: Run a BFAST task on a remote cluster via PBS+SSH
#!/usr/bin/env python
import sys, time
import bliss.saga as saga
def main(jobno, session, jobservice):
bfast_base_dir = saga.Url("sftp://india.futuregrid.org/N/u/oweidner/software/bfast/")
try:
workdir = "%s/tmp/run/%s" % (bfast_base_dir.path, str(int(time.time())))
basedir = saga.filesystem.Directory(bfast_base_dir, session=session)
basedir.make_dir(workdir)
jd = saga.job.Description()
jd.wall_time_limit = 5 # wall-time in minutes
jd.total_cpu_count = 1
jd.environment = {'BFAST_DIR':bfast_base_dir.path}
jd.working_directory = workdir
jd.executable = '$BFAST_DIR/bin/bfast'
jd.arguments = ['match', '-A 1',
'-r $BFAST_DIR/data/small/reads_5K/reads.10.fastq',
'-f $BFAST_DIR/data/small/reference/hg_2122.fa']
myjob = js.create_job(jd)
myjob.run()
print "Job #%s started with ID '%s' and working directory: '%s'"\
% (jobno, myjob.jobid, workdir)
myjob.wait()
print "Job #%s with ID '%s' finished (RC: %s). Output available in: '%s'"\
% (jobno, myjob.jobid, myjob.exitcode, workdir)
basedir.close()
except saga.Exception, ex:
print "An error occured during job execution: %s" % (str(ex))
sys.exit(-1)
if __name__ == "__main__":
execution_host = saga.Url("pbs+ssh://india.futuregrid.org")
ctx = saga.Context()
ctx.type = saga.Context.SSH
ctx.userid = 'oweidner' # like 'ssh username@host ...'
ctx.userkey = '/Users/oweidner/.ssh/rsa_work' # like ssh -i ...'
session = saga.Session()
session.contexts.append(ctx)
js = saga.job.Service(execution_host, session)
for i in range (0, 4):
main(i, session, js)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment