[Swift-commit] r7557 - SwiftApps/swift-galaxy/swift

ketan at ci.uchicago.edu ketan at ci.uchicago.edu
Mon Feb 3 19:12:46 CST 2014


Author: ketan
Date: 2014-02-03 19:12:46 -0600 (Mon, 03 Feb 2014)
New Revision: 7557

Added:
   SwiftApps/swift-galaxy/swift/swiftforeach.sh
   SwiftApps/swift-galaxy/swift/swiftforeach.xml
Log:
unify

Added: SwiftApps/swift-galaxy/swift/swiftforeach.sh
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeach.sh	                        (rev 0)
+++ SwiftApps/swift-galaxy/swift/swiftforeach.sh	2014-02-04 01:12:46 UTC (rev 7557)
@@ -0,0 +1,98 @@
+#!/bin/bash
+
+#ToDo:
+#
+#1. Add a variable number of arguments such that user can add and remove them.
+#
+
+# numeric range
+site=$1
+shift
+interpreter=$1
+shift
+executable=$1
+shift
+rstart=$1
+shift
+rend=$1
+shift
+stepsize=$1
+shift
+outloc=$1
+shift
+outlistfile=$1
+shift
+logfile=$1
+shift
+
+a=()
+while [ $# -gt 0 ] ; do
+  a+=("\"$1\"")
+  shift
+done
+
+#workout the array only if user adds args else make it blank
+if [ ${#a[@]} -gt 0 ] ; then
+    tmp=$(printf -- '%s,' "${a[@]}")
+    arrayexpr='string args[]=['$(echo $tmp | sed s/,$//)'];';
+else
+    arrayexpr='string args[];'
+fi
+
+#Build Swift source code
+cat << EOF > /tmp/script.swift
+type file;
+
+app (file _out, file _err) anapp(file _exec, int _i, string _args[]){
+    $interpreter @_exec _i _args stdout=@_out stderr=@_err;
+}
+$arrayexpr
+
+file exec<"$executable">;
+foreach i in [$rstart:$rend:$stepsize]{
+    file out <single_file_mapper; file=@strcat("$outloc", "/", i, ".out")>;
+    file err <single_file_mapper; file=@strcat("$outloc", "/", i, ".err")>;
+    (out,err) = anapp(exec, i, args);
+}
+EOF
+
+swift=$(which swift)
+
+#build site
+BASEDIR=$(dirname $0)
+$BASEDIR/buildsite.sh $site
+
+#build config
+cat << EOF > /tmp/cf
+use.provider.staging=false
+wrapperlog.always.transfer=true
+execution.retries=0
+provider.staging.pin.swiftfiles=false
+sitedir.keep=true
+lazy.errors=false
+EOF
+
+#build tc
+cat << EOF > /tmp/tc
+$site $interpreter $interpreter
+EOF
+
+$swift -sites.file /tmp/sites.xml -tc.file /tmp/tc -config /tmp/cf /tmp/script.swift 2>$logfile
+EXITCODE=$?
+
+#`for i in \`find $HOME/swift-sandbox -type f\`; do echo "\`basename $i\` $i"; done`
+#Populate output file
+cat << EOF > $outlistfile
+`for i in \`find $outloc -type f\`; do echo "$i"; done`
+EOF
+
+#cleanup
+rm -rf /tmp/sites.xml /tmp/tc /tmp/cf /tmp/script.swift 
+
+if [ "$EXITCODE" -ne "0" ]; then
+       cat $logfile >&2
+fi
+
+exit $EXITCODE
+
+#dum ditty dum ditty dum dum dum


Property changes on: SwiftApps/swift-galaxy/swift/swiftforeach.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: SwiftApps/swift-galaxy/swift/swiftforeach.xml
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeach.xml	                        (rev 0)
+++ SwiftApps/swift-galaxy/swift/swiftforeach.xml	2014-02-04 01:12:46 UTC (rev 7557)
@@ -0,0 +1,113 @@
+<tool id="swiftforeachrange" name="numrangeforeach">
+    <description>A generic tool to run executable via Swift foreach parallel construct</description>
+
+    <command interpreter="bash">
+        swiftforeachrange.sh
+        $site 
+        $interpreter
+        $executable
+        $rstart
+        $rend
+        $stepsize
+        $outloc
+        $logfile
+        $outlist
+        #for $a in $arg
+            ${a.argname}
+        #end for
+    </command>
+
+    <inputs>
+        <param name="site" type="select" label="Execution Location">
+            <option value="localhost">Localhost</option>
+            <option value="midway">Midway</option>
+            <option value="uc3">UC3</option>
+            <option value="stampede">Stampede</option>
+        </param>
+
+        <param name="interpreter" type="select" label="Execution interpreter">
+            <option value="sh">sh</option>
+            <option value="python">python</option>
+            <option value="java">java</option>
+            <option value="R">R</option>
+            <option value="matlab">matlab</option>
+        </param>
+
+        <param format="sh,binexec" name="executable" type="data" label="Executable"/>
+
+        <param name="rstart" size="2" type="integer"  value="0" label="start"/>
+        <param name="rend" size="2" type="integer"  value="9" label="end"/>
+        <param name="stepsize" size="2" type="integer"  value="1" label="stepsize"/>
+        <repeat name="arg" title="arg">
+            <param name="argname" type="text" label="arg" />
+        </repeat>
+
+        <param name="outloc" size="50" type="text" value="$HOME/swift-sandbox" label="location for output files" help="Swift will write output files here on disc">
+            <sanitizer sanitize="False" />
+        </param>
+
+        <conditional name="configuration">
+            <param name="mode" type="select" label="Swift configuration">
+                <option value="default">default configuration</option>
+                <option value="advanced">advanced configuration</option>
+            </param>
+
+            <when value="default">
+            </when>
+            <when value="advanced">
+                <param name="remoteurl" size="50" type="text" value="midway.swift.rcc.uchicago.edu" label="remote url" help="remote resource to run jobs on"></param>
+                <param name="throttle" size="5" type="float" value="0.07" label="job throttle" help="number of parallel jobs to run"></param>
+                <param name="project" type="text" value="TG-STA110005S" label="Project allocation" help="name/code of project"></param>
+                <param name="slots" size="5" type="integer" value="1" label="slots" help="number of scheduler jobs"></param>
+                <param name="queue" size="5" type="text" value="normal" label="queue" help="queue to run jobs on"></param>
+                <param name="nodes" size="5" type="integer" value="1" label="nodes" help="number of nodes requested"></param>
+                <param name="nodegranularity" size="5" type="integer" value="1" label="node granularity" help="node granularity"></param>
+                <param name="jobspernode" size="5" type="integer" value="8" label="jobs per node" help="number of jobs per node requested"></param>
+                <param name="ppn" size="5" type="integer" value="8" label="ppn" help="processes per node requested"></param>
+                <param name="walltime" size="5" type="text" value="00:10:00" label="Job walltime" help="time in hh:mm:ss to request to scheduler for this job"></param>
+                <param name="maxtime" size="5" type="integer" value="700" label="application maxtime" help="Application maxtime in seconds for this job"></param>
+            </when>
+        </conditional>
+    </inputs>
+    <outputs>
+        <data format="txt" name="logfile" type="data" label="Swift output" />
+        <data format="txt" name="outlist" type="data" label="Output list" />
+    </outputs>
+
+    <!--
+  <code file="postprocess.py">
+    <hook postprocess="writeoutlist" />
+  </code>
+  -->
+
+<help>
+.. class:: warningmark
+
+**TIP**. Add args to provide additional arguments to your executable. 
+
+-----
+
+**What it does**
+
+This is a generic Swift tool that runs an executable over a range of numbers with arbitrary stepsize. 
+
+Execution location allows user to declare where to run the tool. Executable can be any arbitrary executable of type "binexec" uploaded by user.
+
+Start, end and stepsize are integer values. Note that the stepsize cannot be less than 1. Optionally, sser can add new arguments to be provided to the tool executable after the numeric argument. Each args box must contain exactly one argument without spaces.
+
+-----
+
+**Example**
+
+Pick up an executable from the Executable list. Enter the start, end and the step size values. Enter an additional argument "hello". 
+
+If an executable is echo.sh with following line:
+
+echo $@
+
+The start, end and step is 0, 9 and 2, the executable will be invoked in parallel 5 times for n where n is 0 2 4 6 8:
+
+echo n hello
+
+</help>
+</tool>




More information about the Swift-commit mailing list