[Swift-user] Difficulty forming commandline

wilde at mcs.anl.gov wilde at mcs.anl.gov
Mon Oct 11 10:06:22 CDT 2010


Ketan, at least from a very brief review of your example, it looks like Swift of forming the command line pretty close to what it should be doing. 

The extra command line options you are observing are flags to the Swift application launching script "_swiftwrap" which runs on the execution host, with its current working directory being the temporary "job directory" as described in the Users Guide. 

If you put in debugging statements in Image_Crop, you'll see that the command line is coming in largely as you would expected. If Image_Crop is a binary, you can put a debugging wrapper script around it just while you are experimenting with how Swift works. 

The one issue you *might* be encountering is the passing of a directory as an argument. One common pitfall is that if you pass a "relative" directory as a string, your application will in fact be running with a different current working dircetory than you expect (ie, the job directory) and will this not be able to open the files. In fact, once you start running on distributed resources, the application may be running on a system that cant even access that directory. 

An approach to consider is to map all the files in that directory into an array (using for example simple_mapper, array_mapper, or your own external mapper), then pass the array as an argument to your app() function, and on the command line put something like @filename(myFileArray[0]). Then make the actual executable be a wrapper script that does a "dirname" of that argument so that your application gets invoked with a directory, as it requires. 

Its possible we should add an @dirname() primitive that works like @filename() to handle this common case without requiring a user-written wrapper shell script. 

- Mike 


----- "Ketan Maheshwari" <ketancmaheshwari at gmail.com> wrote: 
> Hello, 

> 
I have difficulty in forming a commandline that can be executed from within Swift. 

> 
I have a commandline in the following form: 

> 

Image_Crop -dir "Repository to process" -xmin someint -ymin someint -xmax someint -ymax someint 

> 

> 
I place it in Swiftscript as follows: 

> 
type messagefile; 

> 

(messagefile mf) image_crop (string somedir, int xmin, int ymin, int xmax, int ymax) { 
app { 
Image_Crop " -dir " somedir " -xmin " xmin " -ymin " ymin " -xmax " xmax " -ymax " ymax stdout=@filename(mf); 
} 
} 

> 

> 
I call it as follows: 

> 
messagefile icoutfile <"icout.txt">; 

> 
icoutfile = image_crop ("/home/ketan/MpiReg/dataold/sorted/g_8b1e46671d5733/",20,71,142,169); 

> 

> 
However, the call does not go through as expected. I suppose, Swift creates a wrapper around this call and adds more parameters and switches as shown in the log file inside its directory (*.d) as follows : 

> 

Image_Crop-txp9800k -jobdir t -e /home/ketan/MpiReg/bin/Image_Crop -out icout.txt -err stderr.txt -i -d -if -of icout.txt -k -status files -a -dir /home/ketan/MpiReg/dataold/sorted/g_8b1e46671d5733/ -xmin 20 -ymin 71 -xmax 142 -ymax 169 

> 

> 
It seems the binary Image_Crop does not go along well with the additional switches and parameters generated by the wrapper. 

> 
Any suggestions to approach this? 

> 

> 
Regards, 

> 
Ketan 

> 
> _______________________________________________ Swift-user mailing list Swift-user at ci.uchicago.edu http://mail.ci.uchicago.edu/mailman/listinfo/swift-user 

-- 
Michael Wilde 
Computation Institute, University of Chicago 
Mathematics and Computer Science Division 
Argonne National Laboratory 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-user/attachments/20101011/07c8f091/attachment.html>


More information about the Swift-user mailing list