[cig-commits] r11278 - in cs/pythia/trunk: opal/conf pyre/applications pyre/inventory pyre/inventory/odb

leif at geodynamics.org leif at geodynamics.org
Wed Feb 27 16:56:01 PST 2008


Author: leif
Date: 2008-02-27 16:56:00 -0800 (Wed, 27 Feb 2008)
New Revision: 11278

Modified:
   cs/pythia/trunk/opal/conf/__init__.py
   cs/pythia/trunk/pyre/applications/Application.py
   cs/pythia/trunk/pyre/applications/ComponentHarness.py
   cs/pythia/trunk/pyre/applications/Shell.py
   cs/pythia/trunk/pyre/inventory/ConfigContext.py
   cs/pythia/trunk/pyre/inventory/Configurable.py
   cs/pythia/trunk/pyre/inventory/Inventory.py
   cs/pythia/trunk/pyre/inventory/odb/Curator.py
Log:
Complain about typos in the app name in .cfg files -- e.g.:

[citcoms]
steps = 5

Previously, this option would be silently ignored, since the user
wrote "citcoms" instead of "CitcomS".

These are diagnosed as "unknown components", which means they are not
reported when --typos=relaxed, they are reported as warnings when
--typos=strict (the default), and they are reported as errors when
--typos=pedantic.

This change assumes that .cfg/.pml files aren't shared across
applications, which seems to be the case.


Modified: cs/pythia/trunk/opal/conf/__init__.py
===================================================================
--- cs/pythia/trunk/opal/conf/__init__.py	2008-02-27 23:17:23 UTC (rev 11277)
+++ cs/pythia/trunk/opal/conf/__init__.py	2008-02-28 00:56:00 UTC (rev 11278)
@@ -12,7 +12,7 @@
     curator.depositories += site.inventory.getDepositories()
     
     context = site.newConfigContext()
-    site.initializeConfiguration()
+    site.initializeConfiguration(context)
     site.applyConfiguration(context)
     
     if not context.verifyConfiguration(site, 'strict'):

Modified: cs/pythia/trunk/pyre/applications/Application.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Application.py	2008-02-27 23:17:23 UTC (rev 11277)
+++ cs/pythia/trunk/pyre/applications/Application.py	2008-02-28 00:56:00 UTC (rev 11278)
@@ -76,9 +76,11 @@
                 except Exception, error:
                     context.error(error, locator=locator)
                 else:
-                    paramRegistry = shelf['inventory'].getFacility(self.name)
-                    if paramRegistry:
-                        self.updateConfiguration(paramRegistry)
+                    for facilityName, node in shelf['inventory'].facilities.iteritems():
+                        if facilityName == self.name:
+                            self.updateConfiguration(node)
+                        else:
+                            context.unknownComponent(facilityName, node)
             else:
                 self.argv.append(arg)
         return

Modified: cs/pythia/trunk/pyre/applications/ComponentHarness.py
===================================================================
--- cs/pythia/trunk/pyre/applications/ComponentHarness.py	2008-02-27 23:17:23 UTC (rev 11277)
+++ cs/pythia/trunk/pyre/applications/ComponentHarness.py	2008-02-28 00:56:00 UTC (rev 11278)
@@ -52,16 +52,18 @@
     def configureHarnessedComponent(self, component, curator, registry):
         """configure the harnessed component"""
 
+        context = component.newConfigContext()
+        
         # link the component with the curator
         component.setCurator(curator)
-        component.initializeConfiguration()
+        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
-        context = component.applyConfiguration()
+        component.applyConfiguration(context)
 
         return context
 

Modified: cs/pythia/trunk/pyre/applications/Shell.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Shell.py	2008-02-27 23:17:23 UTC (rev 11277)
+++ cs/pythia/trunk/pyre/applications/Shell.py	2008-02-28 00:56:00 UTC (rev 11278)
@@ -69,7 +69,7 @@
         context = app.newConfigContext()
 
         # look for settings
-        self.initializeConfiguration()
+        self.initializeConfiguration(context)
         
         # Temporarily set the app's registry to my own, so that
         # updateConfiguration() will work in readParameterFiles() and
@@ -93,6 +93,8 @@
         # transfer user input to my inventory
         self.applyConfiguration(context)
 
+        uc = context.puntUnknownComponents()
+
         # verify that my input did not contain any typos
         if not context.verifyConfiguration(self, 'strict'):
             import sys
@@ -109,6 +111,7 @@
         
         # start fresh
         context = app.newConfigContext()
+        context.receiveUnknownComponents(uc) # well, almost fresh
 
         # update user options from the command line
         app.updateConfiguration(app.registry)

Modified: cs/pythia/trunk/pyre/inventory/ConfigContext.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/ConfigContext.py	2008-02-27 23:17:23 UTC (rev 11277)
+++ cs/pythia/trunk/pyre/inventory/ConfigContext.py	2008-02-28 00:56:00 UTC (rev 11278)
@@ -84,6 +84,18 @@
         return
 
 
+    def puntUnknownComponents(self):
+        from pyre.inventory import registry
+        uc = self.unknownComponents
+        self.unknownComponents = registry("inventory")
+        return uc
+
+
+    def receiveUnknownComponents(self, uc):
+        self.unknownComponents = uc
+        return
+
+
     def verifyConfiguration(self, component, modeName):
         """verify that the user input did not contain any typos"""
 
@@ -94,7 +106,7 @@
         for path, value, locator in node.allProperties():
             self.error(ConfigContext.UnrecognizedPropertyError(path, value, locator))
 
-        node = self.unknownComponents.getNode(component.name)
+        node = self.unknownComponents
         for path, value, locator in node.allProperties():
             self.error(ConfigContext.UnknownComponentError(path, value, locator))
 

Modified: cs/pythia/trunk/pyre/inventory/Configurable.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/Configurable.py	2008-02-27 23:17:23 UTC (rev 11277)
+++ cs/pythia/trunk/pyre/inventory/Configurable.py	2008-02-28 00:56:00 UTC (rev 11278)
@@ -50,9 +50,9 @@
         return self.inventory.retrieveConfiguration(registry)
 
 
-    def initializeConfiguration(self):
+    def initializeConfiguration(self, context):
         """initialize my private registry using my private settings"""
-        return self.inventory.initializeConfiguration()
+        return self.inventory.initializeConfiguration(context)
 
 
     def loadConfiguration(self, filename):

Modified: cs/pythia/trunk/pyre/inventory/Inventory.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/Inventory.py	2008-02-27 23:17:23 UTC (rev 11277)
+++ cs/pythia/trunk/pyre/inventory/Inventory.py	2008-02-28 00:56:00 UTC (rev 11278)
@@ -15,13 +15,13 @@
 class Inventory(object):
 
 
-    def initializeConfiguration(self):
+    def initializeConfiguration(self, context):
         # load my settings from the persistent store
         # NYI: load options based on my facility as well?
         #      it might be useful when we auto-generate settings for an entire group of clients
         #      whose names may not be known when their configurations are built
         self._priv_registry = self._priv_curator.getTraits(
-            self._priv_name,
+            self._priv_name, context,
             vault=self._priv_vault,
             extraDepositories=self._priv_depositories)
 
@@ -81,7 +81,7 @@
         for component in myComponents:
             # associate a persistent store with every subcomponent
             component.setCurator(self._priv_curator)
-            component.initializeConfiguration()
+            component.initializeConfiguration(context)
 
             # construct a list of the public names of this component
             # setting are overriden from left to right
@@ -199,7 +199,7 @@
 
         # set the component's curator
         component.setCurator(self._priv_curator)
-        component.initializeConfiguration()
+        component.initializeConfiguration(context)
 
         # find any relevant traits in my registry
         # look for facility traits

Modified: cs/pythia/trunk/pyre/inventory/odb/Curator.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/odb/Curator.py	2008-02-27 23:17:23 UTC (rev 11277)
+++ cs/pythia/trunk/pyre/inventory/odb/Curator.py	2008-02-28 00:56:00 UTC (rev 11278)
@@ -18,7 +18,7 @@
 class Curator(Base):
 
 
-    def getTraits(self, name, encodings=['pml','cfg'], vault=[], extraDepositories=[]):
+    def getTraits(self, name, context, encodings=['pml','cfg'], vault=[], extraDepositories=[]):
         """load cascade of inventory values for component <name>"""
 
         # initialize the registry object
@@ -36,8 +36,13 @@
             codecs=codecs, address=location, symbol='inventory', extras=extraDepositories,
             errorHandler=self._recordTraitLookup):
 
-            # update the registry
-            target = traits.getFacility(name)
+            # search for traits under 'name'
+            for facilityName, node in traits.facilities.iteritems():
+                if facilityName == name:
+                    target = node
+                else:
+                    context.unknownComponent(facilityName, node)
+
             if target:
                 # update the registry
                 registry = target.update(registry)



More information about the cig-commits mailing list