Skip to content

Commit

Permalink
print_versions outputs more, updated GH issue template (scverse#1343)
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored Aug 1, 2020
1 parent 2ea9f83 commit b9f3257
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 51 deletions.
28 changes: 19 additions & 9 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,29 @@ labels: bug
assignees: ''
---

<!-- Please give a clear and concise description of what the bug is: -->
...
- [ ] I have checked that this issue has not already been reported.
- [ ] I have confirmed this bug exists on the latest version of scanpy.
- [ ] (optional) I have confirmed this bug exists on the master branch of scanpy.

---

**Note**: Please read [this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) detailing how to provide the necessary information for us to reproduce your bug.


### Minimal code sample (that we can copy&paste without having any data)

<!-- Put a minimal reproducible example that reproduces the bug in the code block below: -->
```python
...
# Your code here
```

<!-- Put your Error output in this code block (if applicable, else delete the block): -->
```pytb
...
[Paste the error output produced by the above code here]
```

#### Versions:
<!-- Output of scanpy.logging.print_versions() -->
> ...
#### Versions

<details>

[Paste the output of scanpy.logging.print_versions() leaving a blank line after the details tag]

</details>
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ umap-learn>=0.3.10
legacy-api-wrap
setuptools_scm
packaging
sinfo
58 changes: 16 additions & 42 deletions scanpy/logging.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Logging and Profiling
"""
import logging
import sys
from functools import update_wrapper, partial
from logging import CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
from datetime import datetime, timedelta, timezone
from typing import Optional

import anndata.logging
from sinfo import sinfo


HINT = (INFO + DEBUG) // 2
Expand Down Expand Up @@ -110,58 +112,30 @@ def format(self, record: logging.LogRecord):
get_memory_usage = anndata.logging.get_memory_usage


_DEPENDENCIES_NUMERICS = [
'anndata', # anndata actually shouldn't, but as long as it's in development
'umap',
'numpy',
'scipy',
'pandas',
('sklearn', 'scikit-learn'),
'statsmodels',
('igraph', 'python-igraph'),
'louvain',
'leidenalg',
]


_DEPENDENCIES_PLOTTING = ['matplotlib', 'seaborn']


def _versions_dependencies(dependencies):
# this is not the same as the requirements!
for mod in dependencies:
mod_name, dist_name = mod if isinstance(mod, tuple) else (mod, mod)
def print_versions(*, file=None):
"""Print print versions of imported packages"""
if file is None:
sinfo(dependencies=True)
else:
stdout = sys.stdout
try:
imp = __import__(mod_name)
yield dist_name, imp.__version__
except (ImportError, AttributeError):
pass
sys.stdout = file
sinfo(dependencies=True)
finally:
sys.stdout = stdout


def print_versions():
"""\
Versions that might influence the numerical results.
Matplotlib and Seaborn are excluded from this.
"""
from ._settings import settings
modules = ['scanpy'] + _DEPENDENCIES_NUMERICS
print(' '.join(
f'{mod}=={ver}'
for mod, ver in _versions_dependencies(modules)
), file=settings.logfile)


def print_version_and_date():
def print_version_and_date(*, file=None):
"""\
Useful for starting a notebook so you see when you started working.
"""
from . import __version__
from ._settings import settings
if file is None:
file = sys.stdout
print(
f'Running Scanpy {__version__}, '
f'on {datetime.now():%Y-%m-%d %H:%M}.',
file=settings.logfile,
file=file,
)


Expand Down

0 comments on commit b9f3257

Please sign in to comment.