Repository: dask/dask

Issue:
Improving bug report template
This is a suggestion to simplify reporting the dask version in the issue template by providing a suggested code snippet to run (in the **Environment** section of the issue template):

```python
import dask; print("- Dask version:", dask.__version__)
import sys; print("- Python version:", sys.version)
```



Discussion:
Thanks for the suggestion @SultanOrazbayev. I'd go a step further and follow the lead from other projects like `pandas` / `xarray` and add a `dask.show_versions()` method which outputs all the version/system-related information we want included when users open an issue. That would let us replace that section in the template with something like "Include the output of `dask.show_versions()`".

Is this something you're interested in working on? (no obligation though)
Thanks, James, yes, I am interested in this!

On Thursday, May 19, 2022, James Bourbeau ***@***.***> wrote:

> Thanks for the suggestion @SultanOrazbayev
> <https://github.com/SultanOrazbayev>. I'd go a step further and follow
> the lead from other projects like pandas / xarray and add a
> dask.show_versions() method which outputs all the version/system-related
> information we want included when users open an issue. That would let us
> replace that section in the template with something like "Include the
> output of dask.show_versions()".
>
> Is this something you're interested in working on? (no obligation though)
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/dask/dask/issues/9099#issuecomment-1130390141>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AE2FWER5Z77TABRSB7MVYJDVKU4GJANCNFSM5WIN5EVA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>

I'll propose an alternative which is that we just don't ask people for this
information.  I almost never provide it, and I find it useful only a small
fraction of the time.  Should we reconsider asking folks to provide this?

On Wed, May 18, 2022 at 2:04 PM Sultan Orazbayev ***@***.***>
wrote:

> Thanks, James, yes, I am interested in this!
>
> On Thursday, May 19, 2022, James Bourbeau ***@***.***> wrote:
>
> > Thanks for the suggestion @SultanOrazbayev
> > <https://github.com/SultanOrazbayev>. I'd go a step further and follow
> > the lead from other projects like pandas / xarray and add a
> > dask.show_versions() method which outputs all the version/system-related
> > information we want included when users open an issue. That would let us
> > replace that section in the template with something like "Include the
> > output of dask.show_versions()".
> >
> > Is this something you're interested in working on? (no obligation though)
> >
> > —
> > Reply to this email directly, view it on GitHub
> > <https://github.com/dask/dask/issues/9099#issuecomment-1130390141>, or
> > unsubscribe
> > <
> https://github.com/notifications/unsubscribe-auth/AE2FWER5Z77TABRSB7MVYJDVKU4GJANCNFSM5WIN5EVA
> >
> > .
> > You are receiving this because you were mentioned.Message ID:
> > ***@***.***>
> >
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/dask/dask/issues/9099#issuecomment-1130398225>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACKZTCEHEB5WGTB3TOHTQTVKU5K3ANCNFSM5WIN5EVA>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>

> I am interested in this!

Great, getting a bit more specific it would be nice to have output like the following:

```python
>>> import dask
>>> dask.show_versions()
Python: 3.9.6
Platform: darwin
Versions:
- dask: X.Y.Z
- distributed: X.Y.Z
- numpy: X.Y.Z
- pandas: X.Y.Z
- cloudpickle: X.Y.Z
- fsspec: X.Y.Z
- bokeh: X.Y.Z
- fastparquet: X.Y.Z
- pyarrow: X.Y.Z
- zarr: X.Y.Z
```

> Should we reconsider asking folks to provide this?

I find myself asking questions like "What version of `dask` are you using? Have you tried the latest release yet?" / "What version of `pandas` / `numpy` / `pyarrow` / ... are you using?" often. I think something like `dask.show_versions()` would allow us to answer several of those questions proactively without users needing to do much. That said, we don't require any of this information when opening an issue, so folks can still feel free to not include it, but it streamlines the process for those that do 

Resolving patch:
diff --git a/dask/utils.py b/dask/utils.py
--- a/dask/utils.py
+++ b/dask/utils.py
@@ -1945,3 +1945,45 @@ def cached_cumsum(seq, initial_zero=False):
         # Construct a temporary tuple, and look up by value.
         result = _cumsum(tuple(seq), initial_zero)
     return result
+
+
+def show_versions() -> None:
+    """Provide version information for bug reports."""
+
+    from importlib.metadata import PackageNotFoundError, version
+    from json import dumps
+    from platform import uname
+    from sys import stdout, version_info
+
+    from distributed import __version__ as distributed_version
+
+    from dask import __version__ as dask_version
+
+    deps = [
+        "numpy",
+        "pandas",
+        "cloudpickle",
+        "fsspec",
+        "bokeh",
+        "fastparquet",
+        "pyarrow",
+        "zarr",
+    ]
+
+    result: dict[str, str | None] = {
+        # note: only major, minor, micro are extracted
+        "Python": ".".join([str(i) for i in version_info[:3]]),
+        "Platform": uname().system,
+        "dask": dask_version,
+        "distributed": distributed_version,
+    }
+
+    for modname in deps:
+        try:
+            result[modname] = version(modname)
+        except PackageNotFoundError:
+            result[modname] = None
+
+    stdout.writelines(dumps(result, indent=2))
+
+    return


Test patch: