Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-11539

meas_base test_PluginLogs.py depends on global state

    XMLWordPrintable

    Details

      Description

      test_PluginLogs.py fails if you run all the tests for meas_base in a single process (such as would happen if you type pytest in the build directory. I think this is because the test is relying on the set of registered plugins but that set has been modified by earlier tests.

      ============================================== FAILURES ==============================================
      __________________________ RegisteredPluginsTestCase.testSingleFramePlugins __________________________
       
      self = <test_PluginLogs.RegisteredPluginsTestCase testMethod=testSingleFramePlugins>
       
          def testSingleFramePlugins(self):
              center = lsst.afw.geom.Point2D(50, 50)
              bbox = lsst.afw.geom.Box2I(lsst.afw.geom.Point2I(0, 0),
                                              lsst.afw.geom.Extent2I(100,100))
              dataset = lsst.meas.base.tests.TestDataset(bbox)
              dataset.addSource(1000000.0, center)
              registry = SingleFramePlugin.registry
              dependencies = registry.keys()
      >       task = self.makeSingleFrameMeasurementTask("base_SdssCentroid", dependencies=dependencies)
       
      tests/test_PluginLogs.py:132: 
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      python/lsst/meas/base/tests.py:515: in makeSingleFrameMeasurementTask
          return SingleFrameMeasurementTask(schema=schema, algMetadata=algMetadata, config=config)
      python/lsst/meas/base/sfm.py:267: in __init__
          self.initializePlugins(schema=self.schema)
      python/lsst/meas/base/baseMeasurement.py:232: in initializePlugins
          for executionOrder, name, config, PluginClass in sorted(self.config.plugins.apply()):
      ../../stack/DarwinX86/pex_config/13.0-3-g520d906/python/lsst/pex/config/registry.py:182: in apply
          retvals.append(self._field.typemap.registry[c](*args, config=self[c], **kw))
      python/lsst/meas/base/pluginRegistry.py:95: in __call__
          return (self.PluginClass.getExecutionOrder(), self.name, config, self.PluginClass)
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
       
      cls = <class 'test_ApCorrNameSet.ApCorrNameTestCase.testRegisterDecorator.<locals>.NonApCorrPlugin'>
       
          @classmethod
          def getExecutionOrder(cls):
              """Sets the relative order of plugins (smaller numbers run first).
          
                  In general, the following class constants should be used (other values
                  are also allowed, but should be avoided unless they are needed):
                  CENTROID_ORDER      centroids and other algorithms that require only a Footprint
                                      and its Peaks as input
                  SHAPE_ORDER         shape measurements and other algorithms that require getCentroid() to return
                                      a good centroid (in addition to a Footprint and its Peaks).
                  FLUX_ORDER          flux algorithms that require both getShape() and getCentroid(),
                                      in addition to a Footprint and its Peaks
                  DEFAULT_CATALOGCALCULATION plugins that only operate on the catalog
          
                  Must be reimplemented as a class method by concrete derived classes.
          
                  This approach was chosen instead of a full graph-based analysis of dependencies
                  because algorithm dependencies are usually both quite simple and entirely substitutable:
                  an algorithm that requires a centroid can typically make use of any centroid algorithms
                  outputs.  That makes it relatively easy to figure out the correct value to use for any
                  particular algorithm.
                  """
      >       raise NotImplementedError("All plugins must implement getExecutionOrder()")
      E       NotImplementedError: All plugins must implement getExecutionOrder()
       
      python/lsst/meas/base/pluginsBase.py:78: NotImplementedError
      =============================== 1 failed, 197 passed in 72.78 seconds ================================
      

      If I reverse the order of tests all tests pass (but "P" is late in the alphabet so there are only ten or so tests after it).

        Attachments

          Activity

          Hide
          ktl Kian-Tat Lim added a comment -

          I think the "proper" way to handle this is for this test to only check plugins that it knows are going to be present (either because they are explicitly added by this test or because they are installed by default).

          Show
          ktl Kian-Tat Lim added a comment - I think the "proper" way to handle this is for this test to only check plugins that it knows are going to be present (either because they are explicitly added by this test or because they are installed by default).
          Hide
          jbosch Jim Bosch added a comment -

          I agree with Kian-Tat Lim's proposal, though I think John Swinbank's proposal to fix the malformed plugins would also be worth doing.

          Show
          jbosch Jim Bosch added a comment - I agree with Kian-Tat Lim 's proposal, though I think John Swinbank 's proposal to fix the malformed plugins would also be worth doing.
          Hide
          swinbank John Swinbank added a comment -

          Downside to having tests specify up-front which plugins they will access is that it limits your ability to write a test for "do something with all known plugins" functionality. But in this case, it should be an easy workaround.

          Show
          swinbank John Swinbank added a comment - Downside to having tests specify up-front which plugins they will access is that it limits your ability to write a test for "do something with all known plugins" functionality. But in this case, it should be an easy workaround.
          Hide
          tjenness Tim Jenness added a comment -

          John Swinbank I've made the suggested fix that ensures the plugins are valid. Also did some flake8 fixes so that when DM-11514 lands we can turn on flake8 testing.

          Show
          tjenness Tim Jenness added a comment - John Swinbank I've made the suggested fix that ensures the plugins are valid. Also did some flake8 fixes so that when DM-11514 lands we can turn on flake8 testing.
          Hide
          swinbank John Swinbank added a comment -

          Looks ok — minor comments on the PR.

          Show
          swinbank John Swinbank added a comment - Looks ok — minor comments on the PR.

            People

            Assignee:
            tjenness Tim Jenness
            Reporter:
            tjenness Tim Jenness
            Reviewers:
            John Swinbank
            Watchers:
            Jim Bosch, John Swinbank, Kian-Tat Lim, Perry Gee, Tim Jenness
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins

                No builds found.