Example #1
0
def main():
    """
    Run an pvm job on a grid resource. To run in local mode please install pvm
    """

    # mig.debug_mode_on() # uncomment to enable debug print outs
    # mig.local_mode_on() # uncomment to enable local mode execution
    
    
    mig.test_connection() # Check if we can connect to the MiG server
    

    proc = subprocess.Popen("gcc example.c -o pvm_example -lpvm3 -lgpvm3", shell= True, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    out, err = proc.communicate()
    pvm_program = "pvm_example" # The PVM executable
    cmd = "$PVM_WRAP ./pvm_example 4 Hello" # The shell command to execute on the grid resource

    # specify to the job that we want PVM as RTE and we want to use the DIKU VGRID
    specifications = {"RUNTIMEENVIRONMENT":"PVM-WRAP-1.0", "VGRID":"DIKU"}
    
    # Create and submit the grid job
    job_id = mig.create_job(cmd, executables=pvm_program, resource_specifications=specifications)
    print "\nJob (ID : %s) submitted. \n\n" % job_id

    # Wait for the job to finish while monitoring the status
    polling_frequency = 10 # seconds
    while not mig.job_finished(job_id):
        job_info = mig.job_info(job_id) # get an info dictionary
        print 'Grid job : %(ID)s \t %(STATUS)s ' % job_info
        time.sleep(polling_frequency) # wait a while before polling again

    print mig.job_output(job_id)
Example #2
0
def main():
    """
    Run an mpi job on a grid resource. To run in local mode please install mpi.
    """

    # mig.debug_mode_on() # uncomment to enable debug print outs
    # mig.local_mode_on() # uncomment to enable local mode execution

    mig.test_connection()  # Check if we can connect to the MiG server
    mpi_file = "example.c"  # mpi program source file

    # The shell command to execute on the grid resource using 4 processes. We need to it compile on the resource first.
    cmds = ["mpicc -O2 example.c -o example", "$MPI_WRAP mpirun -np 4 ./example Hello"]

    # specify that we need require MPI as a runtime env and use the DIKU vgrid cluster
    specifications = {"RUNTIMEENVIRONMENT": "MPI-WRAP-2.0", "VGRID": "DIKU"}
    # Create and submit the grid job
    job_id = mig.create_job(cmds, input_files=mpi_file, resource_specifications=specifications)
    print "\nJob (ID : %s) submitted. \n\n" % job_id

    # Wait for the job to finish while monitoring the status
    polling_frequency = 10  # seconds
    while not mig.job_finished(job_id):
        job_info = mig.job_info(job_id)  # get an info dictionary
        print "Grid job : %(ID)s \t %(STATUS)s " % job_info
        time.sleep(polling_frequency)  # wait a while before polling again

    print mig.job_output(job_id)
Example #3
0
def main():
    """
    Execute a simple grid job and print the output.
    """
    
    # mig.debug_mode_on() # uncomment to enable debug print outs
    # mig.local_mode_on() # uncomment to enable local mode execution

    # Check if we can connect to the MiG server
    mig.test_connection()

    # Create and submit the grid job
    job_id = mig.create_job("echo HELLO GRID")
    print "\nJob (ID : %s) submitted. \n\n" % job_id

    # Wait for the job to finish while monitoring the status
    polling_frequency = 10 # seconds
    while not mig.job_finished(job_id):
        job_info = mig.job_info(job_id) # get an info dictionary
        print 'Grid job : %(ID)s \t %(STATUS)s ' % job_info
        time.sleep(polling_frequency) # wait a while before polling again
    
    print mig.job_output(job_id)
Example #4
0
def main():
    """
    Execute a simple grid job and print the output.
    """

    # mig.debug_mode_on() # uncomment to enable debug print outs
    # mig.local_mode_on() # uncomment to enable local mode execution

    # Check if we can connect to the MiG server
    mig.test_connection()

    # Create and submit the grid job
    job_id = mig.create_job("echo HELLO GRID")
    print "\nJob (ID : %s) submitted. \n\n" % job_id

    # Wait for the job to finish while monitoring the status
    polling_frequency = 10  # seconds
    while not mig.job_finished(job_id):
        job_info = mig.job_info(job_id)  # get an info dictionary
        print 'Grid job : %(ID)s \t %(STATUS)s ' % job_info
        time.sleep(polling_frequency)  # wait a while before polling again

    print mig.job_output(job_id)
Example #5
0
def main():
    """
    Executes the bash file test_executable.sh in a grid job. 
    Afterwards, the result is downloaded and printed to screen.
    """

    # mig.debug_mode_on() # uncomment to enable debug print outs
    # mig.local_mode_on() # uncomment to enable local mode execution
    
    mig.test_connection() # Check if we can connect to the MiG server

    # The program we want to execute on the grid
    executable_file = "test_executable.sh"
    # The shell command to execute on the grid resource
    cmd = "./test_executable.sh > out.txt"
    # Create and submit the grid job
    job_id = mig.create_job(cmd, output_files=["out.txt"], executables=[executable_file])
    print "\nJob (ID : %s) submitted. \n\n" % job_id
    
    # Wait for the job to finish while monitoring the status
    polling_frequency = 10 # seconds
    while not mig.job_finished(job_id):
        job_info = mig.job_info(job_id) # get an info dictionary
        print 'Grid job : %(ID)s \t %(STATUS)s ' % job_info
        time.sleep(polling_frequency) # wait a while before polling again

    # Download the result file and print
    output_file = mig.get_file("out.txt")
    f = open(output_file)
    print "Output file (%s) contains :\n %s \n\n" % (output_file, str(f.readlines()))
    f.close()

    # Clean up
    os.remove(output_file) # remove locally
    mig.remove(output_file) # remove on the MiG server
    print "Output ("+output_file+") deleted."
Example #6
0
 def check_connection(self):
     success = mig.test_connection()
     if not success:
         raise Exception("MiG connection error. Could not execute remote test command :"+str(func)+". You are propably not connected to MiG.")