[Swift-commit] r3597 - SwiftApps/SwiftR/Swift/R

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Fri Sep 3 16:57:20 CDT 2010


Author: wilde
Date: 2010-09-03 16:57:20 -0500 (Fri, 03 Sep 2010)
New Revision: 3597

Modified:
   SwiftApps/SwiftR/Swift/R/Swift.R
Log:
Fix to retain names of input and result lists. Added manual mode. Prelim changes to option handling.

Modified: SwiftApps/SwiftR/Swift/R/Swift.R
===================================================================
--- SwiftApps/SwiftR/Swift/R/Swift.R	2010-09-03 19:50:16 UTC (rev 3596)
+++ SwiftApps/SwiftR/Swift/R/Swift.R	2010-09-03 21:57:20 UTC (rev 3597)
@@ -1,4 +1,4 @@
-swiftapply <- function( func, arglists, site=NULL, callsperbatch=NULL )
+swiftapply <- function( func, arglists, site=NULL, callsperbatch=NULL, manualmode=NULL )
 {
   # Move swiftprops into a Swift namespace
 
@@ -8,13 +8,15 @@
 #    swiftprops$callsperbatch <<- 1
 #  }
 
+  # Set Swift default options if not pre-set by user
+
   if (is.null(getOption("swift.site")))
-    options(swift.site="local");
+    options(swift.site="local")
   if (is.null(getOption("swift.callsperbatch")))
     options(swift.callsperbatch=1)
+  if (is.null(getOption("swift.manualmode")))
+    options(swift.manualmode = FALSE)
 
-  # Set Swift properties
-
 #  if(is.null(site))
 #    if( is.null(swiftprops) || is.null(swiftprops$site))
 #      site <- "local"
@@ -29,7 +31,9 @@
   if(is.null(site))
     site <- getOption("swift.site")
   if(is.null(callsperbatch))
-     callsperbatch <- getOption("swift.callsperbatch")
+    callsperbatch <- getOption("swift.callsperbatch")
+  if(is.null(manualmode))
+    manualmode <- getOption("swift.manualmode")
 
   cat("\nSwift R properties:\n")
   cat("  site =",site,"\n");
@@ -64,8 +68,22 @@
   RunSwiftScript <- system.file(package="Swift","exec/RunSwiftScript.sh")
   RunRScript <- system.file(package="Swift","exec/RunR.sh")
   swiftapplyScript <- system.file(package="Swift","exec/swiftapply.swift")
-  system(paste(RunSwiftScript,rundir,site,swiftapplyScript,RunRScript,sep=" "))
 
+  if( manualmode ) { # Prompt for return (empty line) to continue; assumes user ran a manual R to process the call.
+    cat("Manual Swift Run:\n  run dir: ", getwd(), "/", rundir,"\n\n")
+    cat("  swift script: ", RunSwiftScript, "\n")
+    cat("  site: ", site,"\n")
+    cat("  swiftapplyScript: ", swiftapplyScript,"\n")
+    cat("  RunRScript: ", RunRScript,"\n\n")
+    cat("  Use RunAllR.sh to process and press return when complete:")
+    system(paste("cp ", system.file(package="Swift","exec/RunAllR.sh"), rundir))
+    readLines(n=1)
+  }
+  else {
+    system(paste(RunSwiftScript,rundir,site,swiftapplyScript,RunRScript))
+#    system(paste(RunSwiftScript,rundir,site,swiftapplyScript,RunRScript,sep=" "))
+  }
+
   # Fetch the batch results
 
   rno <- 1
@@ -76,19 +94,24 @@
     nresults <- length(result)
     for(r in 1:nresults) {
       rlist[[rno]] <- result[[r]]
+#DB cat("swiftapply: result rno=",rno,":\n")
+#DB cat(rlist[[rno]]@output$gradient,"\n")
       rno <- rno + 1
     }
   }
+  names(rlist) = names(arglists)
   return(rlist)
 }
 
 swiftLapply <- function( tlist, func, ... )
 {
+  if (length(tlist) == 0) return(tlist)
   arglists <- list()
   narglists <- length(tlist)
   for(i in 1 : narglists) {
     arglists[[i]] <- list(tlist[[i]], ...);
   }
+  names(arglists) = names(tlist)
   swiftapply(func, arglists)
 }
 #####




More information about the Swift-commit mailing list