コード例 #1
0
def main():
    try:
        # Your ssh identity on the remote machine. Change if necessary.
        ctx = rs.Context("ssh")
        #ctx.user_id  = "oweidner"
        #ctx.user_key = "/Users/oweidner/.ssh/sagaproj_rsa"

        session = rs.Session()
        session.add_context(ctx)

        # Create a job service object that represent the local machine.
        # The keyword 'fork://' in the url scheme triggers the 'shell' adaptor
        # which can execute jobs on the local machine as well as on a remote
        # machine via "ssh://hostname". You can use 'localhost' or replace
        # it with the name/address of a machien you have ssh access to.
        js = rs.job.Service("ssh://localhost", session=session)

        # describe our job
        jd = rs.job.Description()

        # Next, we describe the job we want to run. A complete set of job
        # description attributes can be found in the API documentation.
        jd.environment = {'MYOUTPUT': '"Hello from SAGA"'}
        jd.executable = '/bin/echo'
        jd.arguments = ['$MYOUTPUT']
        jd.output = "mysagajob.stdout"
        jd.error = "mysagajob.stderr"

        # Create a new job from the job description. The initial state of
        # the job is 'New'.
        myjob = js.create_job(jd)

        # Check our job's id and state
        print "Job ID    : %s" % (myjob.id)
        print "Job State : %s" % (myjob.state)

        print "\n...starting job...\n"

        # Now we can start our job.
        myjob.run()

        print "Job ID    : %s" % (myjob.id)
        print "Job State : %s" % (myjob.state)

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

        print "Job State : %s" % (myjob.state)
        print "Exitcode  : %s" % (myjob.exit_code)

        return 0

    except rs.SagaException, ex:
        # Catch all saga exceptions
        print "An exception occured: (%s) %s " % (ex.type, (str(ex)))
        # Trace back the exception. That can be helpful for debugging.
        print " \n*** Backtrace:\n %s" % ex.traceback
        return -1
コード例 #2
0
def main():
    try:
        # Your ssh identity on the remote machine
        ctx = rs.Context("ssh")
        ctx.user_id = "oweidner"

        session = rs.Session()
        session.add_context(ctx)

        # Create a job service object that represent a remote pbs cluster.
        # The keyword 'pbs' in the url scheme triggers the PBS adaptors
        # and '+ssh' enables PBS remote access via SSH.
        js = rs.job.Service("pbs+ssh://%s" % REMOTE_HOST, session=session)

        # describe our job
        jd = rs.job.Description()

        # Next, we describe the job we want to run. A complete set of job
        # description attributes can be found in the API documentation.
        jd.environment = {'MYOUTPUT': '"Hello from SAGA"'}
        jd.executable = '/bin/echo'
        jd.arguments = ['$MYOUTPUT']
        jd.output = "/tmp/mysagajob.stdout"
        jd.error = "/tmp/mysagajob.stderr"

        # Create a new job from the job description. The initial state of
        # the job is 'New'.
        myjob = js.create_job(jd)

        # Check our job's id and state
        print "Job ID    : %s" % (myjob.id)
        print "Job State : %s" % (myjob.state)

        print "\n...starting job...\n"

        # Now we can start our job.
        myjob.run()

        print "Job ID    : %s" % (myjob.id)
        print "Job State : %s" % (myjob.state)

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

        print "Job State : %s" % (myjob.state)
        print "Exitcode  : %s" % (myjob.exit_code)

        outfilesource = 'sftp://%s/tmp/mysagajob.stdout' % REMOTE_HOST
        outfiletarget = 'file://localhost/tmp/'
        out = rs.filesystem.File(outfilesource, session=session)
        out.copy(outfiletarget)

        print "Staged out %s to %s (size: %s bytes)\n" % (
            outfilesource, outfiletarget, out.get_size())

        return 0

    except rs.SagaException, ex:
        # Catch all saga exceptions
        print "An exception occured: (%s) %s " % (ex.type, (str(ex)))
        # Trace back the exception. That can be helpful for debugging.
        print " \n*** Backtrace:\n %s" % ex.traceback
        return -1
コード例 #3
0
imgx = 2048
imgy = 2048

# the number of tiles in X and Y direction
tilesx = 2
tilesy = 2

#-----------------------------------------------------------------------------
#
if __name__ == "__main__":
    try:
        # Your ssh identity on the remote machine
        ctx = rs.Context("ssh")
        #ctx.user_id = ""

        session = rs.Session()
        session.add_context(ctx)

        # list that holds the jobs
        jobs = []

        # create a working directory in /scratch
        dirname = '%s/mbrot/' % (REMOTE_FILE_ENDPOINT)
        workdir = rs.filesystem.Directory(dirname,
                                          rs.filesystem.CREATE,
                                          session=session)

        # copy the executable and warpper script to the remote host
        mbwrapper = rs.filesystem.File('file://localhost/%s/mandelbrot.sh' %
                                       os.getcwd())
        mbwrapper.copy(workdir.get_url())
コード例 #4
0
def main():
    try:
        # Your ssh identity on the remote machine
        ctx = rs.Context("ssh")
        ctx.user_id = "oweidner"

        session = rs.Session()
        # session.add_context(ctx)

        # Create a job service object that represent the local machine.
        # The keyword 'fork://' in the url scheme triggers the 'shell' adaptor
        # which can execute jobs on the local machine as well as on a remote
        # machine via "ssh://hostname".
        js = rs.job.Service("ssh://%s" % REMOTE_HOST, session=session)

        # describe our job
        jd = rs.job.Description()

        # Next, we describe the job we want to run. A complete set of job
        # description attributes can be found in the API documentation.
        jd.environment = {'MYOUTPUT': '"Hello from SAGA"'}
        jd.executable = '/bin/echo'
        jd.arguments = ['$MYOUTPUT']
        jd.output = "/tmp/mysagajob-%s.stdout" % getpass.getuser()
        jd.error = "/tmp/mysagajob-%s.stderr" % getpass.getuser()

        # Create a new job from the job description. The initial state of
        # the job is 'New'.
        myjob = js.create_job(jd)

        # Check our job's id and state
        print("Job ID    : %s" % (myjob.id))
        print("Job State : %s" % (myjob.state))

        print("\n...starting job...\n")

        # Now we can start our job.
        myjob.run()

        print("Job ID    : %s" % (myjob.id))
        print("Job State : %s" % (myjob.state))

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

        print("Job State : %s" % (myjob.state))
        print("Exitcode  : %s" % (myjob.exit_code))

        outfilesource = 'sftp://%s/tmp/mysagajob-%s.stdout' % (
            REMOTE_HOST, getpass.getuser())
        outfiletarget = "file://%s/" % os.getcwd()
        out = rs.filesystem.File(outfilesource, session=session)
        out.copy(outfiletarget)

        print("Staged out %s to %s (size: %s bytes)" %
              (outfilesource, outfiletarget, out.get_size()))

        return 0

    except rs.SagaException as ex:
        # Catch all saga exceptions
        print("An exception occured: (%s) %s " % (ex.type, (str(ex))))
        # Trace back the exception. That can be helpful for debugging.
        print(" \n*** Backtrace:\n %s" % ex.traceback)
        return -1