Thursday, November 5, 2009

Xgrid: initial success



I've been exploring Xgrid a little more, and I think I've made significant progress. Following the previous posts (here and here), I fired up an Xgrid Controller from the command line, checked it out in Xgrid Admin, and then did a few examples:


sudo xgrid -h localhost -p pw -job run /usr/bin/cal



   November 2009
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30



sudo xgrid -h localhost -p pw -job run /usr/bin/printenv



XGRID_PROCESSOR_SPEED=2400
XGRID_AGENT_NAME=localhost
XGRID_PROCESSOR_COUNT=1


We run /bin/echo with an argument:


sudo xgrid -h localhost -p pw -job run \
/bin/echo "Hello echo world"



Hello echo world


Now, to do serious work, you'll want to copy over a directory that has goodies in it. For starters here is a text file in /temp on my Desktop:


sudo xgrid -h localhost -p pw -job run \
-in /Users/te/Desktop/temp \
/bin/cat /temp/text.txt



Hello world!


And, without further ado, here is a Python script:


sudo xgrid -h localhost -p pw \
-job run /usr/bin/python /temp/script.py \
-in /Users/te/Desktop/temp



Hello world from Python!


Change that last to be a submit request:


sudo xgrid -h localhost -p pw \
-job submit /usr/bin/python /temp/script.py \
-in /Users/te/Desktop/temp



{
jobIdentifier = 26;
}



sudo xgrid -h localhost -p pw -job attributes -id 26



{
jobAttributes = {
activeCPUPower = 0;
applicationIdentifier = "com.apple.xgrid.cli";
dateNow = "2009-11-05 13:09:15 -0500";
dateStarted = "2009-11-05 13:09:04 -0500";
dateStopped = "2009-11-05 13:09:04 -0500";
dateSubmitted = "2009-11-05 13:09:04 -0500";
jobStatus = Finished;
name = "/usr/bin/python";
percentDone = 100;
taskCount = 1;
undoneTaskCount = 0;
};
}



sudo xgrid -h localhost -p pw -job specification -id 26


Actually, this output is too long to post! It starts like:


{
jobSpecification = {
applicationIdentifier = "com.apple.xgrid.cli";
inputFiles = {
".DS_Store" = {
fileData = <00000001 42756431 00001000 00000800 00001000 00000025 00000000 00000000 00000000 00000000 00000000 00000800 00000800 00000000 00000000 00000000 00000000 00000002 00000000 00000000 00000001 00001000 00000000 00000000 00000000 00000000 00000000
...


There are instructions in Drew McCormack's tutorial for using the result from this specification thingie to build a plist file that can be used for batch jobs that execute multiple commands. But that's hardly necessary if we can run a Python script.

Just remember to check your permissions! I've read that we execute our code in /tmp as user nobody. I'm not sure of that because I couldn't get /bin/ls to work in xgrid. So make sure any user can run the application you want to run (say BLAST, that's our next goal).

One more thing, let's see whether we can get an executable to move from the Client to the Agent and run. Compile this (and test it):


// gcc -o test test.m -framework Foundation -fobjc-gc-only
// ./test
#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
NSLog(@"Hello, Cocoa world!");
return 0;
}


Now do:


sudo xgrid -h localhost -p pw \
-job run ./temp/test \
-in /Users/te/Desktop/temp


minus the log stuff, the output is:


Hello, Cocoa world!


I'd call that a pretty good morning!

[UPDATE: sudo is only needed for the xgridctl command, not for xgrid. My bad.

No comments: