banesullivan / scooby

🐶 🕵️ Great Dane turned Python environment detective

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should packages be alphabetical?

banesullivan opened this issue · comments

As my #14 (comment) outlines, packages are shown by order of insertion... should they be sorted alphabetically?

But what about the core packages... would we want those first?

I imagine some projects might want to report on ~20 packages and sorting through a non-alphabetized list of those wouldn't be fun

I like that.

What if we had NumPy, SciPy, Matplotlib, IPython, and scooby listed the defaults for theoptional argument to investigate. That way a user could easily type the following for a package they want to include in the default report:

Just implemented in #15

>>> import scooby
>>> scooby.investigate('pyvista') 

------------------------------------------------------
  Date: Sat Jun 29 18:12:17 2019 MDT
  Platform: Darwin-18.5.0-x86_64-i386-64bit

             12 : CPU(s)
         x86_64 : Machine
          64bit : Architecture
        32.0 GB : RAM

  3.7.3 | packaged by conda-forge | (default, Mar 27
  2019, 15:43:19)  [Clang 4.0.1
  (tags/RELEASE_401/final)]

         Python : Environment

         0.20.4 : pyvista
         1.16.3 : numpy
          1.3.0 : scipy
          7.5.0 : IPython
          3.1.0 : matplotlib
          0.2.1 : scooby

  Intel(R) Math Kernel Library Version 2018.0.3
  Product Build 20180406 for Intel(R) 64
  architecture applications
------------------------------------------------------

and that way it would show the package(s) listed by the user as the core option and the packages that we (developers of scooby) think are import if they are available but not raise an alarm if those packages aren't available.

Then if you are adding pyvista as a dependency to your project to report on the stuff you care about, you could implement a function like the following which I have in pyvista/pyvista#272

def generate_report(additional=None, ncol=3, text_width=54):
    """Generate an environment report using :module:`scooby`

    Parameters
    ----------
    additional : list(ModuleType), list(str)
        List of packages or package names to add to output information.

    ncol : int, optional
        Number of package-columns in html table; only has effect if
        ``mode='HTML'`` or ``mode='html'``. Defaults to 3.

    text_width : int, optional
        The text width for non-HTML display modes

    """
    core = ['pyvista', 'vtk', 'numpy', 'imageio', 'appdirs', 'scooby']
    optional = ['matplotlib', 'PyQt5', 'IPython', 'ipywidgets', 'colorcet',
                'cmocean']
    report = scooby.investigate(core=core, optional=optional,
                                additional=additional, ncol=ncol,
                                text_width=text_width)
    return report

Then when a user is reporting a PyVista bug/issue, all we have to do is ask them to type pyvista.generate_report(). Plus they still have the option to add other packages.

Just in case some users what an alphabetized list, we could add a keyword argument to scooby.investigate() that would trigger a sorting of the self._packages dictionary.

Or should we have scooby always appended as the very last package to report? I'm thinking incase another package forgets to add scooby to their optional list and scooby's version is relevant for some reason.

I implemented an optional way to sort everything and I like it:

Screen Shot 2019-06-29 at 7 26 23 PM