Application examples

From SNIC Documentation
Revision as of 17:01, 11 October 2011 by Jonas Lindemann (LUNARC) (talk | contribs) (Generic examples)
Jump to: navigation, search

Generic examples

Example 1

This job just sends a script to a grid resource which writes "Hello, grid!" to standard output. The scripts stores standard input and output to the files stdout.txt och stderr.txt. All output is collected upon retrieval using the directive "/" in the outputFiles attribute. Walltime is set to 5 minutes. The executable is also added to the input files section.

XRSL job description (ex1.xrsl):

&(executable=run.sh)
(wallTime="5 minutes")
(stdout="stdout.txt")
(stderr="stderr.txt")
(inputFiles=("run.sh" ""))
(outputFiles=("/" ""))

Executable shell script (run.sh):

#!/bin/sh
echo "Hello, grid"

Usage:

arcsub ex1.xrsl

More verbose output is achieved with:

arcsub --debug=INFO ex1.xrsl

Example 2

Debug information from the used resources can be retrieved using the "gmlog" attribute. The value of the attribute specifies the name of the directory to store the debug information.

XRSL job description (ex2.xrsl):

&(executable=run.sh)
(cpuTime="5 minutes")
(stdout="stdout.txt")
(stderr="stderr.txt")
(inputFiles=("run.sh" ""))
(outputFiles=("/" ""))
(gmlog="grid.debug")

Executable shell script (run.sh):

#!/bin/sh
echo "Hello, grid"

Usage:

arcsub ex2.xrsl

Example 3 - Job sweep

This example illustrates how to do a simple job sweep and manage the sweep using ARC job lists. The implementation of the the job sweep will be done using Python, but could also easily be implemented using bash-scripts or any other scripting language.

To enable dynamic generation of XRSL description a template XRSL is defined in the jobDescription string variable.

#!/usr/bin/python

import os, sys

jobDescription = '''&(executable=run.sh)
(cpuTime='5 minutes')
(stdout=stdout.txt)
(stderr=stderr.txt)
(inputFiles=('run.sh' ''))
(jobName=job%04d)'''

In the string template, "job%04d" will be substituted with an integer value and the job names will have the format "job0000"-"job000n-1".

Next, a variable totalJobs is set to the total number of jobs to be submitted. We implement a job submission loop:

totalJobs = 4

for i in range(totalJobs):

In the job submission we are going to pass the XRSL as a string to the arcsub command. To do this we have to remove the line breaks in the template. This is done using the following statement:

	
	jobDescriptionString = "".join(jobDescription.split("\n"))
	os.system('arcsub --joblist=ex3.list --jobdescrstring="%s"' % (jobDescriptionString % i))

Octave / MATLAB examples

SciPy / Numpy examples

ARC Python API examples