[cig-commits] r15727 - in cs/pythia/trunk/pyre: applications inventory inventory/odb scripts

leif at geodynamics.org leif at geodynamics.org
Wed Sep 30 15:27:24 PDT 2009


Author: leif
Date: 2009-09-30 15:27:23 -0700 (Wed, 30 Sep 2009)
New Revision: 15727

Added:
   cs/pythia/trunk/pyre/applications/SimpleComponentHarness.py
Removed:
   cs/pythia/trunk/pyre/applications/ComponentHarnessAdapter.py
Modified:
   cs/pythia/trunk/pyre/applications/ComponentHarness.py
   cs/pythia/trunk/pyre/applications/Daemon.py
   cs/pythia/trunk/pyre/applications/DynamicComponentHarness.py
   cs/pythia/trunk/pyre/applications/ServiceDaemon.py
   cs/pythia/trunk/pyre/applications/__init__.py
   cs/pythia/trunk/pyre/inventory/ConfigContext.py
   cs/pythia/trunk/pyre/inventory/Configurable.py
   cs/pythia/trunk/pyre/inventory/odb/Curator.py
   cs/pythia/trunk/pyre/scripts/jobstart.py
Log:
Eliminated some gratuitous incompatibilities between CIG Pyre and
standard Pyre.


Modified: cs/pythia/trunk/pyre/applications/ComponentHarness.py
===================================================================
--- cs/pythia/trunk/pyre/applications/ComponentHarness.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/applications/ComponentHarness.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -12,64 +12,58 @@
 #
 
 
-class ComponentHarness(object):
+from SimpleComponentHarness import SimpleComponentHarness
 
 
-    def harnessComponent(self):
-        """harness an external component"""
+class ComponentHarness(SimpleComponentHarness):
+    """a mixin class used to create a component harness which is itself a component"""
 
-        # create the component
-        component = self.createComponent()
 
-        # initialize the persistent store used by the component to configure itself
-        curator = self.prepareComponentCurator()
+    def updateConfiguration(self, registry):
+        """divide settings between myself and the harnessed component"""
+        
+        myRegistry, yourRegistry = self.filterConfiguration(registry)
+        self.componentRegistry.update(yourRegistry)
+        return super(ComponentHarness, self).updateConfiguration(myRegistry)
 
-        # prepare optional configuration for the component
-        registry = self.prepareComponentConfiguration(component)
 
-        # configure the component
-        # collect unknown traits for the components and its subcomponents
-        context = self.configureHarnessedComponent(component, curator, registry)
+    def _fini(self):
+        """finalize the component"""
+        
+        if self.component:
+            self.component.fini()
 
-        if not context.verifyConfiguration(component, 'strict'):
-            return
+        return
 
-        # initialize the component
-        component.init()
 
-        # register it
-        self.component = component
+    def prepareComponentCurator(self):
+        """prepare the persistent store manager for the harnessed component"""
 
-        return component
+        # the host component has a notion of its persistent store that
+        # it wants to share with the harnessed component
+        return self.getCurator()
+        
 
+    def prepareComponentConfiguration(self, component):
+        """prepare the settings for the harnessed component"""
 
-    def createComponent(self):
-        """create the harnessed component"""
-        raise NotImplementedError(
-            "class %r must override 'createComponent'" % self.__class__.__name__)
+        # the host component has a registry with settings for the
+        # harnessed component
+        registry = self.componentRegistry
+        registry.name = component.name
 
+        return registry
 
-    def configureHarnessedComponent(self, component, curator, registry):
-        """configure the harnessed component"""
 
-        context = component.newConfigContext()
+    def createComponentRegistry(self):
+        """create a registry instance to store a configuration for the harnessed component"""
         
-        # link the component with the curator
-        component.setCurator(curator)
-        component.initializeConfiguration(context)
+        return self.createRegistry()
 
-        # update the component's inventory with the optional settings we
-        # have gathered on its behalf
-        component.updateConfiguration(registry)
 
-        # load the configuration onto the inventory
-        component.applyConfiguration(context)
-
-        return context
-
-
     def __init__(self):
-        self.component = None
+        super(ComponentHarness, self).__init__()
+        self.componentRegistry = self.createComponentRegistry()
         return
 
 

Deleted: cs/pythia/trunk/pyre/applications/ComponentHarnessAdapter.py
===================================================================
--- cs/pythia/trunk/pyre/applications/ComponentHarnessAdapter.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/applications/ComponentHarnessAdapter.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -1,69 +0,0 @@
-#!/usr/bin/env python
-#
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
-#                      California Institute of Technology
-#                        (C) 2006  All Rights Reserved
-#
-# {LicenseText}
-#
-# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#
-
-
-from ComponentHarness import ComponentHarness
-
-
-class ComponentHarnessAdapter(ComponentHarness):
-    """a mixin class used to create a component harness which is itself a component"""
-
-
-    def updateConfiguration(self, registry):
-        """divide settings between myself and the harnessed component"""
-        
-        myRegistry, yourRegistry = self.filterConfiguration(registry)
-        self.componentRegistry.update(yourRegistry)
-        return super(ComponentHarnessAdapter, self).updateConfiguration(myRegistry)
-
-
-    def _fini(self):
-        """finalize the component"""
-        
-        if self.component:
-            self.component.fini()
-
-        return
-
-
-    def prepareComponentCurator(self):
-        """prepare the persistent store manager for the harnessed component"""
-
-        # the host component has a notion of its persistent store that
-        # it wants to share with the harnessed component
-        return self.getCurator()
-        
-
-    def prepareComponentConfiguration(self, component):
-        """prepare the settings for the harnessed component"""
-
-        # the host component has a registry with settings for the
-        # harnessed component
-        registry = self.componentRegistry
-        registry.name = component.name
-
-        return registry
-
-
-    def createComponentRegistry(self):
-        """create a registry instance to store a configuration for the harnessed component"""
-        
-        return self.createRegistry()
-
-
-    def __init__(self):
-        ComponentHarness.__init__(self)
-        self.componentRegistry = self.createComponentRegistry()
-        return
-
-
-# end of file 

Modified: cs/pythia/trunk/pyre/applications/Daemon.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Daemon.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/applications/Daemon.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -86,8 +86,7 @@
             os.close(1)
             os.close(0)
         
-        # launch the application
-        if spawn:
+            # launch the application
             try:
                 self.main(*self.args, **self.kwds)
             except KeyboardInterrupt:

Modified: cs/pythia/trunk/pyre/applications/DynamicComponentHarness.py
===================================================================
--- cs/pythia/trunk/pyre/applications/DynamicComponentHarness.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/applications/DynamicComponentHarness.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -12,10 +12,10 @@
 #
 
 
-from ComponentHarnessAdapter import ComponentHarnessAdapter
+from ComponentHarness import ComponentHarness
 
 
-class DynamicComponentHarness(ComponentHarnessAdapter):
+class DynamicComponentHarness(ComponentHarness):
 
 
     def createComponent(self):

Modified: cs/pythia/trunk/pyre/applications/ServiceDaemon.py
===================================================================
--- cs/pythia/trunk/pyre/applications/ServiceDaemon.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/applications/ServiceDaemon.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -13,10 +13,10 @@
 
 from Application import Application
 from Daemon import Daemon as Stager
-from ComponentHarnessAdapter import ComponentHarnessAdapter
+from ComponentHarness import ComponentHarness
 
 
-class ServiceDaemon(ComponentHarnessAdapter, Application, Stager):
+class ServiceDaemon(ComponentHarness, Application, Stager):
 
 
     class Inventory(Application.Inventory):
@@ -62,7 +62,7 @@
     def __init__(self, name):
         Application.__init__(self, name, facility='daemon')
         Stager.__init__(self)
-        ComponentHarnessAdapter.__init__(self)
+        ComponentHarness.__init__(self)
         return
 
 

Copied: cs/pythia/trunk/pyre/applications/SimpleComponentHarness.py (from rev 15101, cs/pythia/trunk/pyre/applications/ComponentHarness.py)
===================================================================
--- cs/pythia/trunk/pyre/applications/SimpleComponentHarness.py	                        (rev 0)
+++ cs/pythia/trunk/pyre/applications/SimpleComponentHarness.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+#                      California Institute of Technology
+#                        (C) 2006  All Rights Reserved
+#
+# {LicenseText}
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+
+class SimpleComponentHarness(object):
+
+
+    def harnessComponent(self):
+        """harness an external component"""
+
+        # create the component
+        component = self.createComponent()
+
+        # initialize the persistent store used by the component to configure itself
+        curator = self.prepareComponentCurator()
+
+        # prepare optional configuration for the component
+        registry = self.prepareComponentConfiguration(component)
+
+        # configure the component
+        # collect unknown traits for the components and its subcomponents
+        context = self.configureHarnessedComponent(component, curator, registry)
+
+        if not context.verifyConfiguration(component, 'strict'):
+            return
+
+        # initialize the component
+        component.init()
+
+        # register it
+        self.component = component
+
+        return component
+
+
+    def createComponent(self):
+        """create the harnessed component"""
+        raise NotImplementedError(
+            "class %r must override 'createComponent'" % self.__class__.__name__)
+
+
+    def configureHarnessedComponent(self, component, curator, registry):
+        """configure the harnessed component"""
+
+        context = component.newConfigContext()
+        
+        # link the component with the curator
+        component.setCurator(curator)
+        component.initializeConfiguration(context)
+
+        # update the component's inventory with the optional settings we
+        # have gathered on its behalf
+        component.updateConfiguration(registry)
+
+        # load the configuration onto the inventory
+        component.applyConfiguration(context)
+
+        return context
+
+
+    def __init__(self):
+        super(SimpleComponentHarness, self).__init__()
+        self.component = None
+        return
+
+
+# end of file 


Property changes on: cs/pythia/trunk/pyre/applications/SimpleComponentHarness.py
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: cs/pythia/trunk/pyre/applications/__init__.py
===================================================================
--- cs/pythia/trunk/pyre/applications/__init__.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/applications/__init__.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -15,9 +15,9 @@
 from Application import Application
 from AppRunner import AppRunner
 from ComponentHarness import ComponentHarness
-from ComponentHarnessAdapter import ComponentHarnessAdapter
 from Script import Script
 from Shell import Shell
+from SimpleComponentHarness import SimpleComponentHarness
 from SuperScript import SuperScript
 
 

Modified: cs/pythia/trunk/pyre/inventory/ConfigContext.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/ConfigContext.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/inventory/ConfigContext.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -96,6 +96,23 @@
         return
 
 
+    def unknownTraits(self):
+        unrecognizedProperties = []
+        unknownComponents = []
+        
+        node = self.unrecognizedProperties
+        for path, value, locator in node.allProperties():
+            path = '.'.join(path[1:])
+            unrecognizedProperties.append((path, value, locator))
+
+        node = self.unknownComponents
+        for path, value, locator in node.allProperties():
+            path = '.'.join(path[1:-1])
+            unknownComponents.append(path)
+
+        return (unrecognizedProperties, unknownComponents)
+
+
     def verifyConfiguration(self, component, modeName):
         """verify that the user input did not contain any typos"""
 

Modified: cs/pythia/trunk/pyre/inventory/Configurable.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/Configurable.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/inventory/Configurable.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -135,10 +135,11 @@
             context = self.newConfigContext()
         
         self.inventory.configureComponent(component, context, registry)
-        
-        return context
 
+        # for backwards compatibility, return the traditional "up, uc" pair
+        return context.unknownTraits()
 
+
     def collectDefaults(self, registry=None):
         """return a registry containing my default values"""
         if registry is None:

Modified: cs/pythia/trunk/pyre/inventory/odb/Curator.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/odb/Curator.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/inventory/odb/Curator.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -18,7 +18,7 @@
 class Curator(Base):
 
 
-    def getTraits(self, name, context, encodings=['pml','cfg','pcs'], vault=[], extraDepositories=[]):
+    def getTraits(self, name, context=None, encodings=['pml','cfg','pcs'], vault=[], extraDepositories=[]):
         """load cascade of inventory values for component <name>"""
 
         # initialize the registry object
@@ -41,7 +41,7 @@
             for facilityName, node in traits.facilities.iteritems():
                 if facilityName == name:
                     target = node
-                else:
+                elif context:
                     context.unknownComponent(facilityName, node)
 
             if target:

Modified: cs/pythia/trunk/pyre/scripts/jobstart.py
===================================================================
--- cs/pythia/trunk/pyre/scripts/jobstart.py	2009-09-30 22:08:13 UTC (rev 15726)
+++ cs/pythia/trunk/pyre/scripts/jobstart.py	2009-09-30 22:27:23 UTC (rev 15727)
@@ -11,8 +11,9 @@
 #
 
 
-from pyre.schedulers import jobstart
-jobstart()
+if __name__ == '__main__':
+    from pyre.schedulers import jobstart
+    jobstart()
 
 
 # end of file



More information about the CIG-COMMITS mailing list