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

getPackageDir raises RuntimeError instead of pex::exceptions::NotFoundError

    XMLWordPrintable

    Details

      Description

      The documentation for utils.getPackageDir claims @throw lsst::pex::exceptions::NotFoundError if desired version can't be found, but it actually raises RuntimeError:

      In [1]: import lsst.utils
       
      In [2]: lsst.utils.getPackageDir('dajfsfsa')
      ---------------------------------------------------------------------------
      RuntimeError                              Traceback (most recent call last)
      <ipython-input-2-bac2a7aa8ca6> in <module>()
      ----> 1 lsst.utils.getPackageDir('dajfsfsa')
       
      RuntimeError: Package dajfsfsa not found
      

      We should either fix the docstring, or fix what is raised (likely at the pybind11 layer).

      We also need to fix the GetPackageDirTestCase unittest so that it tests against the correct exception being raised (it currently tests Exception, which is unhelpful).

        Attachments

          Issue Links

            Activity

            Hide
            pschella Pim Schellart [X] (Inactive) added a comment -

            Why not check against the negative case? If it is a RuntimeError then the test fails. If not, then import the exception and test against it too to be sure you get the right NotFoundError.

            Show
            pschella Pim Schellart [X] (Inactive) added a comment - Why not check against the negative case? If it is a RuntimeError then the test fails. If not, then import the exception and test against it too to be sure you get the right NotFoundError .
            Hide
            pschella Pim Schellart [X] (Inactive) added a comment -

            Of course you still need it to run in an otherwise clean environment, which is a separate story.

            Show
            pschella Pim Schellart [X] (Inactive) added a comment - Of course you still need it to run in an otherwise clean environment, which is a separate story.
            Hide
            pschella Pim Schellart [X] (Inactive) added a comment -

            Either way I'm not quite sure this test belongs here anyway, since any function in any package in the stack can have the exact same problem.

            Show
            pschella Pim Schellart [X] (Inactive) added a comment - Either way I'm not quite sure this test belongs here anyway, since any function in any package in the stack can have the exact same problem.
            Hide
            Parejkoj John Parejko added a comment -

            Either way I'm not quite sure this test belongs here anyway, since any function in any package in the stack can have the exact same problem.

            That's what DM-10415 is for.

            Given the discussion above and Tim Jenness's logic a few comments up, I've opted for option #2 (no import in test file, use assertIsInstance after assertRaises(Exception)). Waiting for jenkins run to pass before merging (I rebased to get travis happy): https://ci.lsst.codes/job/stack-os-matrix/23577/

            Show
            Parejkoj John Parejko added a comment - Either way I'm not quite sure this test belongs here anyway, since any function in any package in the stack can have the exact same problem. That's what DM-10415 is for. Given the discussion above and Tim Jenness 's logic a few comments up, I've opted for option #2 (no import in test file, use assertIsInstance after assertRaises(Exception) ). Waiting for jenkins run to pass before merging (I rebased to get travis happy): https://ci.lsst.codes/job/stack-os-matrix/23577/
            Hide
            Parejkoj John Parejko added a comment -

            Jenkins run passed.

            Rebased (travis passes), merged, and done.

            Show
            Parejkoj John Parejko added a comment - Jenkins run passed. Rebased (travis passes), merged, and done.

              People

              Assignee:
              Parejkoj John Parejko
              Reporter:
              Parejkoj John Parejko
              Reviewers:
              Nate Lust
              Watchers:
              Jim Bosch, John Parejko, Kian-Tat Lim, Krzysztof Findeisen, Nate Lust, Pim Schellart [X] (Inactive), Russell Owen, Tim Jenness
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.