[Swift-commit] r4973 - in SwiftApps/SwiftMontage: . bin scripts

jonmon at ci.uchicago.edu jonmon at ci.uchicago.edu
Tue Aug 9 23:30:00 CDT 2011


Author: jonmon
Date: 2011-08-09 23:30:00 -0500 (Tue, 09 Aug 2011)
New Revision: 4973

Added:
   SwiftApps/SwiftMontage/bin/
   SwiftApps/SwiftMontage/bin/SwiftMontage
   SwiftApps/SwiftMontage/setup.sh
Removed:
   SwiftApps/SwiftMontage/exec/
Modified:
   SwiftApps/SwiftMontage/TODO
   SwiftApps/SwiftMontage/scripts/SwiftMontage_Batch.swift
Log:
o added setup.sh file that sets certain environment variables need by SwiftMontage
o Modified TODO file, removed the montage.sh entry
o removed exec directory
o added bin directory and SwiftMontage execution script. This is written in python.


Modified: SwiftApps/SwiftMontage/TODO
===================================================================
--- SwiftApps/SwiftMontage/TODO	2011-08-10 01:48:34 UTC (rev 4972)
+++ SwiftApps/SwiftMontage/TODO	2011-08-10 04:30:00 UTC (rev 4973)
@@ -1,9 +1,6 @@
 o scripts/Swift_Montage_Batch.swift
   -- Need to fix mProjectBatch.  Currently calls mProject blindly.  Need to figure out how to choose between mProject and mProjectPP
 
-o exec/montage.sh
-  -- Figure out how to specify what site location that are going to be run on and do gensites on the templates
-
 o optimizations
   -- Try different sites.xml settings. Try different throttleing parameters as well as different queue sizes.
 

Added: SwiftApps/SwiftMontage/bin/SwiftMontage
===================================================================
--- SwiftApps/SwiftMontage/bin/SwiftMontage	                        (rev 0)
+++ SwiftApps/SwiftMontage/bin/SwiftMontage	2011-08-10 04:30:00 UTC (rev 4973)
@@ -0,0 +1,87 @@
+#!/usr/bin/python
+
+import os
+import subprocess
+import sys
+import argparse
+
+def setup_opts():
+    parser = argparse.ArgumentParser(description="Run a Montage workflow using the Swift parallel scripting lanugage.")
+    parser.add_argument("--rawdir", dest="raw_dir", action="store",
+                        help="Specify which directory to use for the raw image data.")
+
+    parser.add_argument("--unrectified", dest="unrectified", action="store_true",
+                        help="Generate a mosaic with no background rectification")
+
+    parser.add_argument("--workflow", dest="workflow",
+                        help="Use the specified Swiftscript instead of the default built in SwiftMontage one.")
+
+    parser.add_argument("--execution-sites", dest="sites", nargs="+",
+                        help="The site list to use for execution")
+
+    args = parser.parse_args()
+
+    return args
+
+def create_work_directory():
+
+    # default is SwiftMontage_run.0, if there are other directories then adjust the SwiftMontage_run directory count
+    SwiftMontage_run_directory = "SwiftMontage_run.0"
+    last_SwiftMontage_run = 0
+    directories = os.listdir( os.getcwd() )
+
+    # This might cause a performance problem(to even begin to start Swift)
+    # Need to figure out how maybe purge these SwiftMontage_run directories
+    # For now I can manually purge
+    SwiftMontage_runs = []
+    for direc in directories:
+        ( name, sep, SwiftMontage_run_num ) = direc.partition( "." )
+        try:
+            SwiftMontage_runs.append( int(SwiftMontage_run_num) )
+        except ValueError:
+            # Don't worry about files that are not SwiftMontage_run directories
+            pass
+
+    SwiftMontage_runs.sort()
+
+    # if the directories list is not empty, create the name of the SwiftMontage_run directory
+    if SwiftMontage_runs:
+        last_SwiftMontage_run = SwiftMontage_runs[ len(SwiftMontage_runs)-1 ] + 1
+        SwiftMontage_run_directory = "SwiftMontage_run."+str(last_SwiftMontage_run)
+
+    return (SwiftMontage_run_directory, last_SwiftMontage_run)
+
+def main():
+    rc = 0
+    args = setup_opts()
+
+    (work_directory, last) = create_work_directory()
+    if args.sites:
+        execution_sites=" ".join( map ( str, args.sites ) )
+        sys.stdout.write( "Executing Swift on \"" + execution_sites + "\"\n" )
+    else:
+        sys.stdout.write("Executing Swift on \"localhost\"\n" )
+    sys.stdout.write( "Execution directory: " + work_directory + "\n\n" )
+
+    try:
+        os.mkdir( work_directory )
+    except os.error:
+        sys.stderr.write( "Could not create SwiftMontage_run directory "+work_directory+". Exiting.\n")
+        return 1
+
+    if args.workflow:
+        sys.stdout.write("Using user provided Swiftscript!\n")
+        rc = 0 # Call definition for user provided script
+    elif args.unrectified:
+        sys.stdout.write("Generating mosaic without background rectification!\n")
+        rc = 0 # Call definistion for default montage workflow(not rectification)
+    elif not args.unrectified:
+        sys.stdout.write("Generating mosaic with background rectification!\n")
+        rc = 0 # Call definistion for default montage workflow(with rectification)
+
+    return rc
+
+if __name__ == "__main__":
+    rc = main()
+    sys.exit( rc )
+


Property changes on: SwiftApps/SwiftMontage/bin/SwiftMontage
___________________________________________________________________
Added: svn:executable
   + *

Modified: SwiftApps/SwiftMontage/scripts/SwiftMontage_Batch.swift
===================================================================
--- SwiftApps/SwiftMontage/scripts/SwiftMontage_Batch.swift	2011-08-10 01:48:34 UTC (rev 4972)
+++ SwiftApps/SwiftMontage/scripts/SwiftMontage_Batch.swift	2011-08-10 04:30:00 UTC (rev 4973)
@@ -25,7 +25,7 @@
 
     foreach d_entry, i in diffs
     {
-        Image img_1 <single_file_mapper; file = @strcat( src, "/", @d_entry.plus )>; 
+        Image img_1 <single_file_mapper; file = @strcat( src, "/", @d_entry.plus )>;
         Image img_2 <single_file_mapper; file = @strcat( src, "/", @d_entry.minus )>;
 
         Image diff_img <single_file_mapper; file = @strcat( dest, "/", @d_entry.diff )>;
@@ -42,15 +42,15 @@
     Status stats[];
 
     Table status_tbl = create_status_table( diff_tbl );
-    
+
     foreach d_entry, i in diffs
     {
-        Image img_1 <single_file_mapper; file = @strcat( src, "/", @d_entry.plus )>; 
+        Image img_1 <single_file_mapper; file = @strcat( src, "/", @d_entry.plus )>;
         Image img_2 <single_file_mapper; file = @strcat( src, "/", @d_entry.minus )>;
 
         Image diff_img <single_file_mapper; file = @strcat( dest, "/", @d_entry.diff )>;
 	Status stat_file <single_file_mapper; file = @strcat( stat,"/stat.", @d_entry.diff )>;
-        
+
         ( diff_img, stat_file ) = mDiffFit( img_1, img_2, hdr );
 
 	diff_imgs[ i ] = diff_img;

Added: SwiftApps/SwiftMontage/setup.sh
===================================================================
--- SwiftApps/SwiftMontage/setup.sh	                        (rev 0)
+++ SwiftApps/SwiftMontage/setup.sh	2011-08-10 04:30:00 UTC (rev 4973)
@@ -0,0 +1,7 @@
+SWIFTMONTAGE_HOME=`pwd`
+
+export PATH=$SWIFTMONTAGE_HOME/bin:$PATH
+export SWIFT_LIB=$SWIFTMONTAGE_HOME/scripts:$SWIFT_LIB
+
+export SWIFTMONTAGE_TEMPLATES=$SWIFTMONTAGE_HOME/templates
+export SWIFTMONTAGE_SCRIPTS=$SWIFTMONTAGE_HOME/scripts




More information about the Swift-commit mailing list