Skip to content

Commit

Permalink
Various things (#19)
Browse files Browse the repository at this point in the history
* Remove investigate; closes #17

* Correct empty lists

* Adjust travis

* Partly addresses #18

- OS-info is name the same for text and html
- Environment is now the same for text and html

Removed all RUH-ROH. As we discussed earlier. The name is goofy, but all
the rest should be serious. For wide adaption.

* Addresses #18

* Simplifying things

* Massively simplify the version check.

* Remove all flake8-complaints

* Update README to reflect changes

* Differentiate unknown version from not installed

* Make NA/UNK more verbose
  • Loading branch information
prisae authored and banesullivan committed Jun 30, 2019
1 parent 984d7ca commit 540ba6c
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 363 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ install:
- python -m pip install numpy scipy

script:
- python -c "import scooby; print(scooby.investigate())"
- python -c "import scooby; print(scooby.investigate(core='numpy'))"
- python -c "import scooby; print(scooby.investigate(additional=['mock', 'foo']))"
- python -c "import scooby; print(scooby.investigate(additional=['foo',]))"
- python -c "import scooby, mock; print(scooby.investigate(additional=[mock,]))"
- python -c "import scooby, mock; print(scooby.investigate(additional=mock))"
- python -c "import scooby, mock; print(scooby.investigate(additional=mock)._repr_html_())"
- python -c "import scooby; print(scooby.Report())"
- python -c "import scooby; print(scooby.Report(core='numpy'))"
- python -c "import scooby; print(scooby.Report(additional=['mock', 'foo']))"
- python -c "import scooby; print(scooby.Report(additional=['foo',]))"
- python -c "import scooby, mock; print(scooby.Report(additional=[mock,]))"
- python -c "import scooby, mock; print(scooby.Report(additional=mock))"
- python -c "import scooby, mock; print(scooby.Report(additional=mock)._repr_html_())"
# Test sorting
- python -c "import scooby; print(scooby.investigate(additional=['collections', 'foo', 'aaa'], sort=True))"
- python -c "import scooby; print(scooby.Report(additional=['collections', 'foo', 'aaa'], sort=True))"

notifications:
email:
Expand Down
203 changes: 100 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

A Great Dane turned Python environment detective

This is a toolset to easily report your Python environment's package versions
and hardware resources.
This is a lightweight toolset to easily report your Python environment's
package versions and hardware resources.


Install from [PyPI](https://pypi.org/project/scooby/):

Expand All @@ -27,12 +28,19 @@ environment you care most about.
If `scooby` is unable to detect aspects of an environment that you'd like to
know, please share this with us as a feature requests or pull requests.

This work is derived from [Dieter Werthmüller](https://github.com/prisae)'s work
towards creating a version reporting tool for the [empymod](https://github.com/empymod/)
and [SimPEG](https://github.com/simpeg/) projects.
This package has been altered to create a lightweight implementation so that it
can easily be used as an environment reporting tool in any Python library with
minimal impact.





The scooby reporting is derived from the versioning-scripts created by [Dieter
Werthmüller](https://github.com/prisae) for
[empymod](https://empymod.github.io), [emg3d](https://empymod.github.io), and
the [SimPEG](https://github.com/simpeg/) framework. It was heavily inspired by
`ipynbtools.py` from [qutip](https://github.com/qutip) and
[`watermark.py`](https://github.com/rasbt/watermark). This package has been
altered to create a lightweight implementation so that it can easily be used as
an environment reporting tool in any Python library with minimal impact.

## Usage

Expand All @@ -55,180 +63,169 @@ else:

### Generating Reports

Use Scooby's `investigate` method to generate `Report` objects. These objects
have representation methods implemented so that if outputted, they show
a nicely formatted report but you could also capture the report as an object
itself.
Use Scooby's `Report` objects. These objects have representation methods
implemented so that if outputted, they show a nicely formatted report but you
could also capture the report as an object itself.

```py
>>> import scooby
>>> scooby.investigate()
>>> scooby.Report()
```
```
------------------------------------------------------
Date: Tue Jun 25 16:17:46 2019 MDT
Platform: Darwin-18.5.0-x86_64-i386-64bit
--------------------------------------------------------------
Date: Sun Jun 30 14:18:44 2019 CEST
12 : CPU(s)
Linux : OS
4 : CPU(s)
x86_64 : Machine
64bit : Architecture
32.0 GB : RAM
7.7 GB : RAM
IPython : Environment
3.7.3 | packaged by conda-forge | (default, Mar 27
2019, 15:43:19) [Clang 4.0.1
(tags/RELEASE_401/final)]
Python 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0]
1.16.3 : numpy
1.3.0 : scipy
1.2.1 : scipy
7.5.0 : IPython
3.1.0 : matplotlib
3.0.3 : matplotlib
0.2.2 : scooby
Intel(R) Math Kernel Library Version 2018.0.3
Product Build 20180406 for Intel(R) 64
architecture applications
------------------------------------------------------
Intel(R) Math Kernel Library Version 2019.0.3 Product
Build 20190125 for Intel(R) 64 architecture applications
--------------------------------------------------------------
```

But you can also add addtional packages too if you'd like via the `addtional`
keyword argument:

```py
>>> scooby.investigate(additional='pyvista')
>>> scooby.Report(additional='pyvista')
```
```
------------------------------------------------------
Date: Tue Jun 25 16:18:01 2019 MDT
Platform: Darwin-18.5.0-x86_64-i386-64bit
--------------------------------------------------------------
Date: Sun Jun 30 14:18:44 2019 CEST
12 : CPU(s)
Linux : OS
4 : CPU(s)
x86_64 : Machine
64bit : Architecture
32.0 GB : RAM
7.7 GB : RAM
IPython : Environment
3.7.3 | packaged by conda-forge | (default, Mar 27
2019, 15:43:19) [Clang 4.0.1
(tags/RELEASE_401/final)]
Python 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0]
0.20.2 : pyvista
1.16.3 : numpy
1.3.0 : scipy
1.2.1 : scipy
7.5.0 : IPython
3.1.0 : matplotlib
0.20.4 : pyvista
3.0.3 : matplotlib
0.2.2 : scooby
Intel(R) Math Kernel Library Version 2018.0.3
Product Build 20180406 for Intel(R) 64
architecture applications
------------------------------------------------------
Intel(R) Math Kernel Library Version 2019.0.3 Product
Build 20190125 for Intel(R) 64 architecture applications
--------------------------------------------------------------
```

Or maybe you want a whole bunch of additional packages:

```py
>>> scooby.investigate(additional=['pyvista', 'vtk', 'appdirs',])
>>> scooby.Report(additional=['pyvista', 'vtk', 'appdirs',])
```
```
------------------------------------------------------
Date: Tue Jun 25 16:18:16 2019 MDT
Platform: Darwin-18.5.0-x86_64-i386-64bit
--------------------------------------------------------------
Date: Sun Jun 30 14:18:44 2019 CEST
12 : CPU(s)
Linux : OS
4 : CPU(s)
x86_64 : Machine
64bit : Architecture
32.0 GB : RAM
7.7 GB : RAM
IPython : Environment
3.7.3 | packaged by conda-forge | (default, Mar 27
2019, 15:43:19) [Clang 4.0.1
(tags/RELEASE_401/final)]
Python 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0]
0.20.2 : pyvista
8.1.2 : vtk
1.4.3 : appdirs
1.16.3 : numpy
1.3.0 : scipy
1.2.1 : scipy
7.5.0 : IPython
3.1.0 : matplotlib
0.20.4 : pyvista
8.2.0 : vtk
1.4.3 : appdirs
3.0.3 : matplotlib
0.2.2 : scooby
Intel(R) Math Kernel Library Version 2018.0.3
Product Build 20180406 for Intel(R) 64
architecture applications
------------------------------------------------------
Intel(R) Math Kernel Library Version 2019.0.3 Product
Build 20190125 for Intel(R) 64 architecture applications
--------------------------------------------------------------
```


Want to add a package to investigate but aren't sure if it is present,
simply define the `optional` list in the arguments. Note that the default
libraries of `numpy`, `scipy`, `IPython`, and `matplotlib` are defaults for
optional argument, so you might want to put those in the `core` argument if
you care about those.
Want to add a package to investigate but aren't sure if it is present, simply
define the `optional` list in the arguments. Note that the default libraries of
`numpy`, `scipy`, `IPython`, and `matplotlib` (and `scooby`) are defaults for
optional argument, so you might want to put those in the `core` argument if you
care about those.

```py
>>> scooby.investigate(core=['numpy', 'matplotlib'], optional=['foo', ])
>>> scooby.Report(core=['numpy', 'matplotlib'], optional=['foo', ])
```
```
------------------------------------------------------
Date: Tue Jun 25 17:51:30 2019 MDT
Platform: Darwin-18.5.0-x86_64-i386-64bit
--------------------------------------------------------------
Date: Sun Jun 30 14:23:24 2019 CEST
12 : CPU(s)
Linux : OS
4 : CPU(s)
x86_64 : Machine
64bit : Architecture
32.0 GB : RAM
7.7 GB : RAM
IPython : Environment
3.7.3 | packaged by conda-forge | (default, Mar 27
2019, 15:43:19) [Clang 4.0.1
(tags/RELEASE_401/final)]
Python 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0]
1.16.3 : numpy
3.1.0 : matplotlib
3.0.3 : matplotlib
Intel(R) Math Kernel Library Version 2018.0.3
Product Build 20180406 for Intel(R) 64
architecture applications
------------------------------------------------------
Intel(R) Math Kernel Library Version 2019.0.3 Product
Build 20190125 for Intel(R) 64 architecture applications
--------------------------------------------------------------
```

Since the `foo` package wasn't found and it's optional, nothing is reported.
But what if you need some sort of error message that a package wasn't found?
Then add your package to the `additional` list and Scooby will let you now it
was not found but like any good pooch, Scooby will complete the investigation:
Then add your package to the `additional` list and Scooby will report it, just
with a `NA`:

```py
>>> scooby.investigate(additional=['foo',])
>>> scooby.Report(additional=['foo',])
```
```
------------------------------------------------------
Date: Tue Jun 25 21:23:56 2019 MDT
Platform: Darwin-18.5.0-x86_64-i386-64bit
--------------------------------------------------------------
Date: Sun Jun 30 14:23:50 2019 CEST
12 : CPU(s)
Linux : OS
4 : CPU(s)
x86_64 : Machine
64bit : Architecture
32.0 GB : RAM
7.7 GB : RAM
IPython : Environment
3.7.3 | packaged by conda-forge | (default, Mar 27
2019, 15:43:19) [Clang 4.0.1
(tags/RELEASE_401/final)]
Python 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0]
NA : foo
1.16.3 : numpy
1.3.0 : scipy
1.2.1 : scipy
7.5.0 : IPython
3.1.0 : matplotlib
RUH-ROH! These modules were either unavailable or
the version attribute is unknown:
unavailable : foo
3.0.3 : matplotlib
0.2.2 : scooby
Intel(R) Math Kernel Library Version 2018.0.3
Product Build 20180406 for Intel(R) 64
architecture applications
------------------------------------------------------
Intel(R) Math Kernel Library Version 2019.0.3 Product
Build 20190125 for Intel(R) 64 architecture applications
--------------------------------------------------------------
```


## Optional Requirements

The following are a list of optional requirements and their purpose:
The following is a list of optional requirements and their purpose:

- `psutil`: report total RAM in GB
- `mkl`: report Intel(R) Math Kernel Library version
Binary file modified assets/jupyter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 17 additions & 42 deletions scooby/__init__.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,24 @@
# coding=utf-8
"""
A Great Dane turned Python environment detective
================================================
A lightweight toolset to easily report your Python environment's package
versions and hardware resources.
History
-------
The scooby reporting is derived from the versioning-scripts created by Dieter
Werthmüller for ``empymod``, ``emg3d``, and the ``SimPEG`` framework
(https://empymod.github.io; https://simpeg.xyz). It was heavily inspired by
``ipynbtools.py`` from ``qutip`` (https://github.com/qutip) and
``watermark.py`` from https://github.com/rasbt/watermark.
"""

# These are our default optional packages to investigate
SCOOBY_PACKAGES = ['numpy', 'scipy', 'IPython', 'matplotlib']

from scooby.extras import MKL_INFO, TOTAL_RAM, sort_dictionary
from scooby.knowledge import VERSION_ATTRIBUTES
from scooby.mysteries import in_ipython, in_ipykernel
from scooby.report import Report
from scooby.mysteries import in_ipython, in_ipykernel


def investigate(core=None,
optional=SCOOBY_PACKAGES,
additional=None,
ncol=3, text_width=54, sort=False):
"""
Have Scooby investigate the active Python environment. This returns a
:class:`scooby.Report` object which displays the system information
when a ``__repr__`` method is called (through outputting or printing).
Parameters
----------
core : list(ModuleType), list(str)
The core packages to list first.
optional : list(ModuleType), list(str)
A list of packages to list if they are available. If not available,
no warnings or error will be thrown.
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
sort : bool, optional
Sort the packages when the report is shown
"""
versions = Report(core=core, optional=optional, additional=additional,
ncol=ncol, text_width=text_width, sort=sort)
return versions
__all__ = ['Report', 'in_ipython', 'in_ipykernel']


__author__ = 'Dieter Werthmüller & Bane Sullivan'
Expand Down
Loading

0 comments on commit 540ba6c

Please sign in to comment.