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

Wrap matplotlib use in meas_mosaic

    XMLWordPrintable

Details

    Description

      meas.mosaic.utils does a module-level import of matplotlib and sets the backend to Agg.

      a) Specifically the matplotlib.use("Agg") line should be removed.

      It has no effect if the user has already loaded a backend, and spews a big chunk of distracting warnings.

      b) The overall import of matplotlib should not happen at the module level, because that code gets run when importing the module.  Importing the module happens even just opening a Butler object view to the repo.  Specifically, meas_mosaic gets imported by just the following code.

      import os
      import lsst.afw.display as afwDisplay
      from lsst.daf.persistence import Butler
       
      repo = os.getenv('REPO')
      butler = Butler(repo)
      

      Philosophically I don't believe that opening a Butler should trigger setting up matplotlib.

      Editorial: I believe that all plotting imports should be protected and separated from the data analysis.  But this implies a refactoring that may not be justified given the imminent replacement by jointcal

      Attachments

        Issue Links

          Activity

            Good point.  Considering.

            wmwood-vasey Michael Wood-Vasey added a comment - Good point.  Considering.

            After some discussion with Parejkoj, it became clear that the correct way to solve this for validateDrp.py example runs would be to specify the backend in a current-working directory level matplotlibrc file. This has the benefit of removing hard-coded lines that might not even work and making it more clear where this is happening for the runs that we'd like to distribute to displayless nodes.

            wmwood-vasey Michael Wood-Vasey added a comment - After some discussion with Parejkoj , it became clear that the correct way to solve this for validateDrp.py example runs would be to specify the backend in a current-working directory level matplotlibrc file. This has the benefit of removing hard-coded lines that might not even work and making it more clear where this is happening for the runs that we'd like to distribute to displayless nodes.
            wmwood-vasey Michael Wood-Vasey added a comment - - edited

            After further discussion it may be that putting these lines in bin.src/validateDrp.py is a better and more clearer solution.

            wmwood-vasey Michael Wood-Vasey added a comment - - edited After further discussion it may be that putting these lines in bin.src/validateDrp.py is a better and more clearer solution.
            Parejkoj John Parejko added a comment -

            One comment about your comment, otherwise you're good to go.

            Parejkoj John Parejko added a comment - One comment about your comment, otherwise you're good to go.

            Merged to master.

            wmwood-vasey Michael Wood-Vasey added a comment - Merged to master.

            People

              wmwood-vasey Michael Wood-Vasey
              wmwood-vasey Michael Wood-Vasey
              John Parejko, Simon Krughoff (Inactive)
              John Parejko, Merlin Fisher-Levine, Michael Wood-Vasey, Paul Price, Simon Krughoff (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Jenkins

                  No builds found.