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

Brokenness when comparing configs with inheritance relationship

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: pex_config
    • Labels:
      None

      Description

      ...or just similar field names, I suppose. Viz:

      In [1]: import lsst.pex.config as pexConfig
       
      In [2]: class SuperConfig(pexConfig.Config):
         ...:     foo = pexConfig.Field(doc="test", dtype=str)
         ...: 
       
      In [3]: class SubConfig(SuperConfig):
         ...:     bar = pexConfig.Field(doc="test", dtype=str)
         ...: 
       
      In [4]: super_c, sub_c = SuperConfig(), SubConfig()
       
      In [5]: pexConfig.compareConfigs("", super_c, sub_c)
      Out[5]: True
       
      In [6]: pexConfig.compareConfigs("", sub_c, super_c)
      ---------------------------------------------------------------------------
      AttributeError                            Traceback (most recent call last)
      <ipython-input-7-e502e8e334d3> in <module>()
      ----> 1 pexConfig.compareConfigs("", sub_c, super_c)
       
      /software/lsstsw/stack_20181012/stack/miniconda3-4.5.4-fcd27eb/Linux64/pex_config/16.0-7-g9645df7+1/python/lsst/pex/config/comparison.py in compareConfigs(name, c1, c2, shortcut, rtol, atol, output)
          101     equal = True
          102     for field in c1._fields.values():
      --> 103         result = field._compare(c1, c2, shortcut=shortcut, rtol=rtol, atol=atol, output=output)
          104         if not result and shortcut:
          105             return False
       
      /software/lsstsw/stack_20181012/stack/miniconda3-4.5.4-fcd27eb/Linux64/pex_config/16.0-7-g9645df7+1/python/lsst/pex/config/config.py in _compare(self, instance1, instance2, shortcut, rtol, atol, output)
          356         """
          357         v1 = getattr(instance1, self.name)
      --> 358         v2 = getattr(instance2, self.name)
          359         name = getComparisonName(
          360             _joinNamePath(instance1._name, self.name),
       
      AttributeError: 'SuperConfig' object has no attribute 'bar'
      

      Both of these comparisons are mistakes: the configs aren't equal, so shouldn't return as if they are (in the first case), and the comparison should certainly not raise.

        Attachments

          Issue Links

            Activity

            swinbank John Swinbank created issue -
            swinbank John Swinbank made changes -
            Field Original Value New Value
            Epic Link DM-14447 [ 80385 ]
            swinbank John Swinbank made changes -
            Status To Do [ 10001 ] In Progress [ 3 ]
            swinbank John Swinbank made changes -
            Description ...or just similar field names, I suppose. Viz:

            {code:python}
            In [1]: import lsst.pex.config as pexConfig

            In [2]: class SuperConfig(pexConfig.Config):
               ...: foo = pexConfig.Field(doc="test", dtype=str)
               ...:

            In [3]: class SubConfig(SuperConfig):
               ...: bar = pexConfig.Field(doc="test", dtype=str)
               ...:

            In [4]: super_c, sub_c = SuperConfig(), SubConfig()

            In [5]: pexConfig.compareConfigs("", super_c, sub_c)
            Out[5]: True

            In [6]: pexConfig.compareConfigs("", sub_c, super_c)
            ---------------------------------------------------------------------------
            AttributeError Traceback (most recent call last)
            <ipython-input-7-e502e8e334d3> in <module>()
            ----> 1 pexConfig.compareConfigs("", sub_c, super_c)

            /software/lsstsw/stack_20181012/stack/miniconda3-4.5.4-fcd27eb/Linux64/pex_config/16.0-7-g9645df7+1/python/lsst/pex/config/comparison.py in compareConfigs(name, c1, c2, shortcut, rtol, atol, output)
                101 equal = True
                102 for field in c1._fields.values():
            --> 103 result = field._compare(c1, c2, shortcut=shortcut, rtol=rtol, atol=atol, output=output)
                104 if not result and shortcut:
                105 return False

            /software/lsstsw/stack_20181012/stack/miniconda3-4.5.4-fcd27eb/Linux64/pex_config/16.0-7-g9645df7+1/python/lsst/pex/config/config.py in _compare(self, instance1, instance2, shortcut, rtol, atol, output)
                356 """
                357 v1 = getattr(instance1, self.name)
            --> 358 v2 = getattr(instance2, self.name)
                359 name = getComparisonName(
                360 _joinNamePath(instance1._name, self.name),

            AttributeError: 'SuperConfig' object has no attribute 'bar'
            {code}

            *Both* of these comparisons are mistakes: the comparisons aren't equal, so shouldn't return as if they are (in the first case), and the comparison should certainly not raise.
            ...or just similar field names, I suppose. Viz:

            {code:python}
            In [1]: import lsst.pex.config as pexConfig

            In [2]: class SuperConfig(pexConfig.Config):
               ...: foo = pexConfig.Field(doc="test", dtype=str)
               ...:

            In [3]: class SubConfig(SuperConfig):
               ...: bar = pexConfig.Field(doc="test", dtype=str)
               ...:

            In [4]: super_c, sub_c = SuperConfig(), SubConfig()

            In [5]: pexConfig.compareConfigs("", super_c, sub_c)
            Out[5]: True

            In [6]: pexConfig.compareConfigs("", sub_c, super_c)
            ---------------------------------------------------------------------------
            AttributeError Traceback (most recent call last)
            <ipython-input-7-e502e8e334d3> in <module>()
            ----> 1 pexConfig.compareConfigs("", sub_c, super_c)

            /software/lsstsw/stack_20181012/stack/miniconda3-4.5.4-fcd27eb/Linux64/pex_config/16.0-7-g9645df7+1/python/lsst/pex/config/comparison.py in compareConfigs(name, c1, c2, shortcut, rtol, atol, output)
                101 equal = True
                102 for field in c1._fields.values():
            --> 103 result = field._compare(c1, c2, shortcut=shortcut, rtol=rtol, atol=atol, output=output)
                104 if not result and shortcut:
                105 return False

            /software/lsstsw/stack_20181012/stack/miniconda3-4.5.4-fcd27eb/Linux64/pex_config/16.0-7-g9645df7+1/python/lsst/pex/config/config.py in _compare(self, instance1, instance2, shortcut, rtol, atol, output)
                356 """
                357 v1 = getattr(instance1, self.name)
            --> 358 v2 = getattr(instance2, self.name)
                359 name = getComparisonName(
                360 _joinNamePath(instance1._name, self.name),

            AttributeError: 'SuperConfig' object has no attribute 'bar'
            {code}

            *Both* of these comparisons are mistakes: the configs aren't equal, so shouldn't return as if they are (in the first case), and the comparison should certainly not raise.
            swinbank John Swinbank made changes -
            Reviewers Kian-Tat Lim [ ktl ]
            Status In Progress [ 3 ] In Review [ 10004 ]
            tjenness Tim Jenness made changes -
            Status In Review [ 10004 ] Reviewed [ 10101 ]
            swinbank John Swinbank made changes -
            Resolution Done [ 10000 ]
            Status Reviewed [ 10101 ] Done [ 10002 ]
            swinbank John Swinbank made changes -
            Link This issue relates to DM-11707 [ DM-11707 ]
            gkovacs Gabor Kovacs made changes -
            Link This issue is duplicated by DM-11707 [ DM-11707 ]
            gkovacs Gabor Kovacs made changes -
            Link This issue relates to DM-11707 [ DM-11707 ]

              People

              Assignee:
              swinbank John Swinbank
              Reporter:
              swinbank John Swinbank
              Reviewers:
              Kian-Tat Lim
              Watchers:
              John Swinbank, Kian-Tat Lim, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: