[cig-commits] r6698 - in cs/pythia/trunk: mpi pyre/applications pyre/schedulers

leif at geodynamics.org leif at geodynamics.org
Wed Apr 25 23:20:17 PDT 2007


Author: leif
Date: 2007-04-25 23:20:17 -0700 (Wed, 25 Apr 2007)
New Revision: 6698

Modified:
   cs/pythia/trunk/mpi/Application.py
   cs/pythia/trunk/mpi/__init__.py
   cs/pythia/trunk/pyre/applications/Preprocessor.py
   cs/pythia/trunk/pyre/schedulers/Job.py
Log:
Added more macros, and made some minor bug fixes and refinements.

    ${home}
    ${user}
    ${hostname}
    ${wd}
    ${pid}

This leaves ${job.id}, which is the most awkward to implement.  Things
would be so much easier if we had Squeak's #snapshotPrimitive... I'd
create a parallel version, of course...


Modified: cs/pythia/trunk/mpi/Application.py
===================================================================
--- cs/pythia/trunk/mpi/Application.py	2007-04-26 04:10:41 UTC (rev 6697)
+++ cs/pythia/trunk/mpi/Application.py	2007-04-26 06:20:17 UTC (rev 6698)
@@ -42,7 +42,7 @@
         requires = self.requires()
         entry = self.entryName()
         argv = self.getArgv(*args, **kwds)
-        state = self.getStateArgs() + self.job.getStateArgs()
+        state = self.getStateArgs('launch')
         
         # initialize the job
         job = self.job
@@ -67,7 +67,7 @@
         requires = self.requires()
         entry = self.entryName()
         argv = self.getArgv(*args, **kwds)
-        state = self.getStateArgs() + self.job.getStateArgs()
+        state = self.getStateArgs('compute')
         
         # initialize the launcher
         launcher = self.launcher
@@ -92,11 +92,12 @@
         self.main(*args, **kwds)
 
 
-    def getStateArgs(self):
+    def getStateArgs(self, stage):
         state = []
-        state.append("--nodes=%d" % self.nodes) # in case it was computed
-        # define macros
-        state.append("--macros.nodes=%d" % self.nodes)
+        if stage == 'launch':
+            state.append("--nodes=%d" % self.nodes) # in case it was computed
+            state.append("--macros.nodes=%d" % self.nodes)
+        state.extend(self.job.getStateArgs(stage))
         return state
 
 

Modified: cs/pythia/trunk/mpi/__init__.py
===================================================================
--- cs/pythia/trunk/mpi/__init__.py	2007-04-26 04:10:41 UTC (rev 6697)
+++ cs/pythia/trunk/mpi/__init__.py	2007-04-26 06:20:17 UTC (rev 6698)
@@ -29,7 +29,7 @@
 
     rank = MPI_Comm_rank(MPI_COMM_WORLD)
     macros = {
-        'rank': str(rank),
+        'rank': ("%04d" % rank),
         }
 
     kwds = kwds.get('kwds', dict())

Modified: cs/pythia/trunk/pyre/applications/Preprocessor.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Preprocessor.py	2007-04-26 04:10:41 UTC (rev 6697)
+++ cs/pythia/trunk/pyre/applications/Preprocessor.py	2007-04-26 06:20:17 UTC (rev 6698)
@@ -14,7 +14,7 @@
 from pyre.components import Component
 from pyre.util import expandMacros
 from pyre.inventory.odb.Registry import Registry
-import os
+import os, getpass, socket
 
 
 class Preprocessor(Component):
@@ -49,15 +49,27 @@
                 if self.recur.has_key(key):
                     return ""
                 self.recur[key] = True
-                value = expandMacros(self.macros[key], self)
-                del self.recur[key]
+                try:
+                    value = expandMacros(self.macros[key], self)
+                finally:
+                    del self.recur[key]
                 return value
 
         macros = {}
         
         # add environment variables
         macros.update(os.environ)
-        
+
+        # add useful macros
+        macros['home'] = os.path.expanduser("~")
+        if False:
+            macros['user'] = os.getlogin() # OSError: [Errno 25] Inappropriate ioctl for device
+        else:
+            macros['user'] = getpass.getuser()
+        macros['hostname'] = socket.gethostname()
+        macros['wd'] = os.getcwd()
+        macros['pid'] = str(os.getpid())
+
         # flatten my macro registry
         for path, value, locator in self.macros.allProperties():
             key = '.'.join(path[1:])

Modified: cs/pythia/trunk/pyre/schedulers/Job.py
===================================================================
--- cs/pythia/trunk/pyre/schedulers/Job.py	2007-04-26 04:10:41 UTC (rev 6697)
+++ cs/pythia/trunk/pyre/schedulers/Job.py	2007-04-26 06:20:17 UTC (rev 6698)
@@ -47,10 +47,10 @@
         self.nodes = 1
 
 
-    def getStateArgs(self):
+    def getStateArgs(self, stage):
         state = []
-        # define macros
-        state.append("--macros.job.name=%s" % self.task)
+        if stage == 'launch':
+            state.append("--macros.job.name=%s" % self.task)
         return state
 
 



More information about the cig-commits mailing list