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

ketan at ci.uchicago.edu ketan at ci.uchicago.edu
Mon May 5 15:54:01 CDT 2014


Author: ketan
Date: 2014-05-05 15:54:01 -0500 (Mon, 05 May 2014)
New Revision: 7812

Modified:
   SwiftApps/swift-galaxy/swift/swiftforeachlist.sh
Log:
invoke Swift/T

Modified: SwiftApps/swift-galaxy/swift/swiftforeachlist.sh
===================================================================
--- SwiftApps/swift-galaxy/swift/swiftforeachlist.sh	2014-05-05 18:35:47 UTC (rev 7811)
+++ SwiftApps/swift-galaxy/swift/swiftforeachlist.sh	2014-05-05 20:54:01 UTC (rev 7812)
@@ -4,124 +4,239 @@
 
 k_or_t=$1
 shift
-sites=$1 # comma separated list of sites
-shift
-swiftargs=$1 
-shift
-interpreter=$1
-shift
-executable=$1
-shift
-stdin=$1
-shift
-listfile=$1
-shift
-outloc=$1
-shift
-logfile=$1
-shift
-outlistfile=$1
-shift
-stringargs=$1
-shift 
 
-#workout the array only if user adds args else make it blank
-if [ "${stringargs}"  ] ; then
-    stringarrayexpr='string stringargs[]=['$(echo $stringargs | sed -e 's/ *$//g' -e 's/[^ ][^ ]*/"&"/g' -e 's/ /,/g')'];';
+if [ "$k_or_t" = "swiftK"  ] ; then
+    #invoke the k.sh
+    k "${@}"
 else
-    stringarrayexpr='string stringargs[];'
+    #invoke the t.sh
+    t "${@}"
+    echo "stc + turbine; not implemented yet" > /tmp/swiftT.txt
 fi
 
-#workout standard input file
-if [ "${stdin}" ] ; then
-    stdinfilexpr='file stdinfile<'\"${stdin}\"'>;'
-else
-    stdinfilexpr='file stdinfile<'\"/dev/null\"'>;'
-fi
 
-fileargs=()
-while [ $# -gt 0 ] ; do
-  fileargs+=("\"$1\"")
-  shift
-done
-
-#workout the array only if user adds args else make it blank
-if [ ${#fileargs[@]} -gt 0 ] ; then
-    tmp=$(printf -- '%s,' "${fileargs[@]}")
-    filearrayexpr='file fileargs[] <fixed_array_mapper; files="'$(echo $tmp | sed -e 's/,$//' -e 's/\"//g')'">;';
-else
-    filearrayexpr='file fileargs[];'
-fi
-
-cat << EOF > $wdir/script.swift
-
-/*
-*
-* Swift source script is generated automatically via the Swift-Galaxy
-* integration tool. Be careful before making any changes to it directly as
-* it might be tied with other configuration and paramter values.
-*
-*/
-
-type file;
-
-app (file _out, file _err) anapp(file _exec, int _i, string _stringargs[], file _fileargs[], file _stdin){
-    $interpreter @_exec _i _stringargs @_fileargs stdin=@_stdin stdout=@_out stderr=@_err;
+function k()
+{
+ sites=$1 # comma separated list of sites
+ shift
+ swiftargs=$1 
+ shift
+ interpreter=$1
+ shift
+ executable=$1
+ shift
+ stdin=$1
+ shift
+ listfile=$1
+ shift
+ outloc=$1
+ shift
+ logfile=$1
+ shift
+ outlistfile=$1
+ shift
+ stringargs=$1
+ shift 
+ 
+ #workout the array only if user adds args else make it blank
+ if [ "${stringargs}"  ] ; then
+     stringarrayexpr='string stringargs[]=['$(echo $stringargs | sed -e 's/ *$//g' -e 's/[^ ][^ ]*/"&"/g' -e 's/ /,/g')'];';
+ else
+     stringarrayexpr='string stringargs[];'
+ fi
+ 
+ #workout standard input file
+ if [ "${stdin}" ] ; then
+     stdinfilexpr='file stdinfile<'\"${stdin}\"'>;'
+ else
+     stdinfilexpr='file stdinfile<'\"/dev/null\"'>;'
+ fi
+ 
+ fileargs=()
+ while [ $# -gt 0 ] ; do
+   fileargs+=("\"$1\"")
+   shift
+ done
+ 
+ #workout the array only if user adds args else make it blank
+ if [ ${#fileargs[@]} -gt 0 ] ; then
+     tmp=$(printf -- '%s,' "${fileargs[@]}")
+     filearrayexpr='file fileargs[] <fixed_array_mapper; files="'$(echo $tmp | sed -e 's/,$//' -e 's/\"//g')'">;';
+ else
+     filearrayexpr='file fileargs[];'
+ fi
+ 
+ cat << EOF > $wdir/script.swift
+ 
+ /*
+ *
+ * Swift source script is generated automatically via the Swift-Galaxy
+ * integration tool. Be careful before making any changes to it directly as
+ * it might be tied with other configuration and paramter values.
+ *
+ */
+ 
+ type file;
+ 
+ app (file _out, file _err) anapp(file _exec, int _i, string _stringargs[], file _fileargs[], file _stdin){
+     $interpreter @_exec _i _stringargs @_fileargs stdin=@_stdin stdout=@_out stderr=@_err;
+ }
+ $stringarrayexpr
+ $filearrayexpr
+ $stdinfilexpr
+ 
+ file exec<"$executable">;
+ file listfile<"$listfile">;
+ string list[] = readData(listfile);
+ foreach l, i in list{
+     file out <single_file_mapper; file=@strcat("$outloc", "/", l, ".", i, ".out")>;
+     file err <single_file_mapper; file=@strcat("$outloc", "/", l, ".", i, ".err")>;
+     (out,err) = anapp(exec, i, stringargs, fileargs, stdinfile);
+ }
+EOF
+ 
+ swift=$(which swift)
+ 
+ BASEDIR=$(dirname $0)
+ $BASEDIR/buildsite.sh $sites $wdir
+ 
+ #build config
+ cat << EOF > $wdir/cf
+ use.provider.staging=true
+ wrapperlog.always.transfer=true
+ execution.retries=0
+ provider.staging.pin.swiftfiles=false
+ sitedir.keep=true
+ lazy.errors=false
+ EOF
+ 
+ #build tc
+ IFS=',' read -ra S <<< "$sites"
+ for site in "${S[@]}" ; do
+ cat << EOF >> $wdir/tc
+ $site $interpreter $interpreter
+EOF
+ done
+ 
+ touch None # Create a "None" file in case user does not specify any stdin file
+ $swift -sites.file $wdir/sites.xml -tc.file $wdir/tc -config $wdir/cf $wdir/script.swift "${swiftargs}" 2>$logfile
+ EXITCODE=$?
+ 
+ `for i in \`find $outloc -type f\`; do echo "\`basename $i\` $i"; done`
+ 
+ cat << EOF > $outlistfile
+ `for i in $(find $outloc -type f -iname "*.out"); do echo "$i"; done`
+EOF
+ 
+ if [ "$EXITCODE" -ne "0" ]; then
+        cat $logfile >&2
+ fi
+ exit $EXITCODE
+ 
+ #dum ditty dum ditty dum dum dum
 }
-$stringarrayexpr
-$filearrayexpr
-$stdinfilexpr
 
-file exec<"$executable">;
-file listfile<"$listfile">;
-string list[] = readData(listfile);
-foreach l, i in list{
-    file out <single_file_mapper; file=@strcat("$outloc", "/", l, ".", i, ".out")>;
-    file err <single_file_mapper; file=@strcat("$outloc", "/", l, ".", i, ".err")>;
-    (out,err) = anapp(exec, i, stringargs, fileargs, stdinfile);
-}
-EOF
 
-swift=$(which swift)
+function t()
+{
 
-BASEDIR=$(dirname $0)
-$BASEDIR/buildsite.sh $sites $wdir
+ sites=$1 # comma separated list of sites
+ shift
+ swiftargs=$1 
+ shift
+ interpreter=$1
+ shift
+ executable=$1
+ shift
+ stdin=$1
+ shift
+ listfile=$1
+ shift
+ outloc=$1
+ shift
+ logfile=$1
+ shift
+ outlistfile=$1
+ shift
+ stringargs=$1
+ shift 
+ 
+ #workout the array only if user adds args else make it blank
+ if [ "${stringargs}" ] ; then
+     stringarrayexpr='string stringargs[]=['$(echo $stringargs | sed -e 's/ *$//g' -e 's/[^ ][^ ]*/"&"/g' -e 's/ /,/g')'];';
+ else
+     stringarrayexpr='string stringargs[];'
+ fi
+ 
+ #workout standard input file
+ if [ "${stdin}" ] ; then
+     stdinfilexpr='file stdinfile<'\"${stdin}\"'>;'
+ else
+     stdinfilexpr='file stdinfile<'\"/dev/null\"'>;'
+ fi
+ 
+ fileargs=()
+ while [ $# -gt 0 ] ; do
+   fileargs+=("\"$1\"")
+   shift
+ done
+ 
+ #workout the array only if user adds args else make it blank
+ if [ ${#fileargs[@]} -gt 0 ] ; then
+     tmp=$(printf -- '%s,' "${fileargs[@]}")
+     filearrayexpr='file fileargs[] <fixed_array_mapper; files="'$(echo $tmp | sed -e 's/,$//' -e 's/\"//g')'">;';
+ else
+     filearrayexpr='file fileargs[];'
+ fi
+ 
+ cat << EOF > $wdir/script.swift
+ 
+ /*
+ *
+ * Swift source script is generated automatically via the Swift-Galaxy
+ * integration tool. Be careful before making any changes to it directly as
+ * it might be tied with other configuration and paramter values.
+ *
+ */
+ 
+ import files;
+ 
+ app (file _out, file _err) anapp(file _exec, int _i, string _stringargs[], file _fileargs[], file _stdin){
+     $interpreter _exec _i _stringargs _fileargs @stdin=_stdin @stdout=_out @stderr=_err;
+ }
 
-#build config
-cat << EOF > $wdir/cf
-use.provider.staging=true
-wrapperlog.always.transfer=true
-execution.retries=0
-provider.staging.pin.swiftfiles=false
-sitedir.keep=true
-lazy.errors=false
+ $stringarrayexpr
+ $filearrayexpr
+ $stdinfilexpr
+ 
+ file exec<"$executable">;
+ file listfile<"$listfile">;
+ string list[] = split(read(input_file(listfile)),"\n");
+ foreach l, i in list{
+     file out <sprintf("$outloc/%s.%i.out", l, i)>;
+     file err <sprintf("$outloc/%s.%i.err", l, i)>;
+     (out,err) = anapp(exec, i, stringargs, fileargs, stdinfile);
+ }
 EOF
+ 
+ stc=$(which stc)
+ turbine=$(which turbine)
+ touch None # Create a "None" file in case user does not specify any stdin file
+ $stc -j `which java` $wdir/script.swift "${swiftargs}" 2>$logfile
+ 
+ $turbine -n 3 $wdir/script.tcl
 
-#build tc
-IFS=',' read -ra S <<< "$sites"
-for site in "${S[@]}" ; do
-cat << EOF >> $wdir/tc
-$site $interpreter $interpreter
+ EXITCODE=$?
+ 
+ $(for i in $(find $outloc -type f); do echo "$(basename $i) $i"; done)
+ 
+ cat << EOF > $outlistfile
+ $(for i in $(find $outloc -type f -iname "*.out"); do echo "$i"; done)
 EOF
-done
+ 
+ if [ "$EXITCODE" -ne "0" ]; then
+        cat $logfile >&2
+ fi
+ exit $EXITCODE
 
-touch None # Create a "None" file in case user does not specify any stdin file
-if [ "$k_or_t" = "swiftK"  ] ; then
-    $swift -sites.file $wdir/sites.xml -tc.file $wdir/tc -config $wdir/cf $wdir/script.swift "${swiftargs}" 2>$logfile
-    EXITCODE=$?
-else
-    echo "stc + turbine; not implemented yet" > /tmp/swiftT.txt
-fi
-
-`for i in \`find $outloc -type f\`; do echo "\`basename $i\` $i"; done`
-
-cat << EOF > $outlistfile
-`for i in $(find $outloc -type f -iname "*.out"); do echo "$i"; done`
-EOF
-
-if [ "$EXITCODE" -ne "0" ]; then
-       cat $logfile >&2
-fi
-exit $EXITCODE
-
-#dum ditty dum ditty dum dum dum
+}




More information about the Swift-commit mailing list