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

lsstDebug behaviour does not match documentation

    XMLWordPrintable

    Details

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

      Description

      The lsstDebug documentation claims:

      It is always safe to interrogate lsstDebug; for example lsstDebug.Info("Robert.Hugh.Lupton").isBadPerson will return False.

      In fact, this is only true if a Robert.Hugh.Lupton module has been imported. Otherwise, we get:

      In [1]: import lsstDebug
       
      In [2]: lsstDebug.Info("Robert.Hugh.Lupton")
      ---------------------------------------------------------------------------
      KeyError                                  Traceback (most recent call last)
      <ipython-input-2-7b61e1f45b97> in <module>()
      ----> 1 lsstDebug.Info("Robert.Hugh.Lupton")
       
      /ssd/lsstsw/stack_20170409/Linux64/base/13.0-5-g77abda3+2/python/lsstDebug.pyc in __init__(self, modname)
           51     def __init__(self, modname):
           52         import sys
      ---> 53         self.__dict__["_dict"] = sys.modules[modname].__dict__
           54         self._modname = modname
           55
       
      KeyError: 'Robert.Hugh.Lupton'
      

      Thanks to Michael Wood-Vasey [X] on CLO for spotting this.

        Attachments

          Activity

          Hide
          swinbank John Swinbank added a comment -

          Robert Lupton — I think you understand the design of this system better than anybody (since you produced it). What's the intended behaviour here? Is this a code or a documentation bug?

          Show
          swinbank John Swinbank added a comment - Robert Lupton — I think you understand the design of this system better than anybody (since you produced it). What's the intended behaviour here? Is this a code or a documentation bug?
          Hide
          rhl Robert Lupton added a comment -

          There's confusion here about levels of indirection. In your package create an LsstDebug object:

          import lsstDebug
           
          debugInfo= lsstDebug.Info(__name__)
          

          then you can ask debugInfo about me:

          print(debugInfo.RobertHughLupton)
          

          and it'll say that I'm a false knave (or False anyway)

          So it's a documentation bug – that example's in package Robert.Hugh.Lupton.

          Show
          rhl Robert Lupton added a comment - There's confusion here about levels of indirection. In your package create an LsstDebug object: import lsstDebug   debugInfo= lsstDebug.Info(__name__) then you can ask debugInfo about me: print(debugInfo.RobertHughLupton) and it'll say that I'm a false knave (or False anyway) So it's a documentation bug – that example's in package Robert.Hugh.Lupton .
          Hide
          lskelvin Lee Kelvin added a comment - - edited

          Doc strings in mainpage.dox and lsstDebug.py have been updated to more accurately reflect the behaviour of lsstDebug. Successfully completed Jenkins.

          Show
          lskelvin Lee Kelvin added a comment - - edited Doc strings in mainpage.dox and lsstDebug.py have been updated to more accurately reflect the behaviour of lsstDebug . Successfully completed Jenkins .
          Hide
          rhl Robert Lupton added a comment -

          I think it might be clearer to say that you may interrogate lsstDebug for any string in sys.modules, i.e. for the _name_ of any package that has been imported. I suspect that I didn't support any random string to reduce the probability of typos.

          Otherwise, good to merge.

          Show
          rhl Robert Lupton added a comment - I think it might be clearer to say that you may interrogate lsstDebug for any string in sys.modules , i.e. for the _ name _ of any package that has been imported. I suspect that I didn't support any random string to reduce the probability of typos. Otherwise, good to merge.
          Hide
          lskelvin Lee Kelvin added a comment -

          Thank you for the review and comments. I've made the changes you suggest and merged to master.

          Show
          lskelvin Lee Kelvin added a comment - Thank you for the review and comments. I've made the changes you suggest and merged to master.

            People

            Assignee:
            lskelvin Lee Kelvin
            Reporter:
            swinbank John Swinbank
            Reviewers:
            Robert Lupton
            Watchers:
            Christopher Waters, Lee Kelvin, Michael Wood-Vasey [X] (Inactive), Robert Lupton
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins Builds

                No builds found.