Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with multiple job service instances #5

Closed
oweidner opened this issue Dec 1, 2011 · 1 comment
Closed

Problem with multiple job service instances #5

oweidner opened this issue Dec 1, 2011 · 1 comment

Comments

@oweidner
Copy link
Contributor

oweidner commented Dec 1, 2011

Multiple instances of a job service during a session fail more or less randomly:

#!/usr/bin/env python

# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

'''This examples shows how to copy a file to a remote 
   host via ssh using a custom security context.

   If something doesn't work as expected, try to set 
   SAGA_VERBOSE=3 in your environment before you run the
   script in order to get some debug output.

   If you think you have encountered a defect, please 
   report it at: https://github.com/oweidner/bliss/issues
'''

__author__    = "Ole Christian Weidner"
__email__     = "ole.weidner@me.com"
__copyright__ = "Copyright 2011, Ole Christian Weidner"
__license__   = "MIT"

import time
import bliss.saga as saga

def main():

    execution_host = saga.Url("pbs+ssh://queenbee.loni.org") 
    bfast_base_dir = saga.Url("sftp://queenbee.loni.org/work/oweidner/bfast")

    try:
        ctx = saga.Context()
        ctx.type = saga.Context.SSH
        ctx.userid  = 'oweidner' # like 'ssh username@host ...'
        ctx.usercert = '/Users/s1063117/.ssh/id_rsa' # like ssh -i ...'

        session = saga.Session()
        session.contexts.append(ctx)

        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)

        js = saga.job.Service(execution_host, session)

        jd = saga.job.Description()
        jd.wall_time_limit   = "0:05:00"
        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()
        time.sleep(1)
        print "Job started with ID '%s' and working directory: '%s'"\
          % (myjob.jobid, workdir)

        myjob.wait()

        print "Job with ID '%s' finished (RC: %s). Output available in: '%s'"\
          % (myjob.jobid, myjob.exitcode, workdir)

    except saga.Exception, ex:
        print "Oh, snap! An error occured: %s" % (str(ex))

if __name__ == "__main__":
    for i in range (0,8):
        main()
@pradeepmantha
Copy link
Contributor

Below script fails...

import sys, time
import bliss.saga as saga

def main():

try:
# set up a security context (optional)
# if no security context is defined, the PBS
# plugin will pick up the default set of ssh
# credentials of the user, i.e., ~/.ssh/id_rsa

   # create a job service for Futuregrid's 'india' PBS cluster
   # and attach the SSH security context to it
   js = saga.job.Service("pbs+ssh://alamo.futuregrid.org")
   js1 = saga.job.Service("pbs+ssh://alamo.futuregrid.org")

   # describe our job
   jd = saga.job.Description()
   # resource requirements
   jd.wall_time_limit = 5 #minutes
   jd.total_cpu_count = 1
   # environment, executable & arguments
   jd.environment = {'SLEEP_TIME':"hello_saga"}
   jd.executable  = '/bin/cat'
   jd.arguments   = ['$SLEEP_TIME']
   # output options
   jd.output = "bliss_pbssh_job.stdout"
   jd.error  = "bliss_pbssh_job.stderr"

   # create the job (state: New)
   myjob = js.create_job(jd)
   myjob1 = js1.create_job(jd)

   print "Job ID    : %s" % (myjob.jobid)
   print "Job State : %s" % (myjob.get_state())

   print "\n...starting job...\n"
   # run the job (submit the job to PBS)
   myjob.run()
   myjob1.run()

   print "Job ID    : %s" % (myjob.jobid)
   print "Job State : %s" % (myjob.get_state())

   print "\n...waiting for job...\n"
   # wait for the job to either finish or fail
   myjob.wait()
   myjob1.wait()

   print "Job State : %s" % (myjob.get_state())
   print "Exitcode  : %s" % (myjob.exitcode)

except saga.Exception, ex:
print "An error occured during job execution: %s" % (str(ex))
sys.exit(-1)

if name == "main":
main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants