Skip to content

Commit 001e228

Browse files
committed
Add autoformatting and update documentation
1 parent c10f2ea commit 001e228

File tree

6 files changed

+145
-10
lines changed

6 files changed

+145
-10
lines changed

.flake8

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[flake8]
2+
# Ignore style and complexity
3+
# E: style errors
4+
# W: style warnings
5+
# F401: module imported but unused
6+
# F811: redefinition of unused `name` from line `N`
7+
# F841: local variable assigned but never used
8+
ignore = E, C, W, F401, F403, F811, F841, E402, I100, I101, D400
9+
exclude =
10+
helm-chart,
11+
hooks,
12+
setup.py,
13+
statuspage,
14+
versioneer.py

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/asottile/reorder_python_imports
3+
rev: v1.3.5
4+
hooks:
5+
- id: reorder-python-imports
6+
language_version: python3.6
7+
- repo: https://github.com/ambv/black
8+
rev: 18.9b0
9+
hooks:
10+
- id: black
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v2.1.0
13+
hooks:
14+
- id: end-of-file-fixer
15+
- id: check-json
16+
- id: check-yaml
17+
exclude: ^helm-chart/nbviewer/templates/
18+
- id: check-case-conflict
19+
- id: check-executables-have-shebangs
20+
- id: requirements-txt-fixer
21+
- id: flake8

.travis.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
language: python
2+
3+
python:
4+
- 3.7
5+
- 3.8
6+
7+
before_install:
8+
- pip install --upgrade setuptools pip
9+
10+
install:
11+
- pip install --editable .
12+
13+
script:
14+
- python -m pytest -vvv nbresuse
15+
16+
17+
jobs:
18+
include:
19+
- name: autoformatting check
20+
python: 3.6
21+
# NOTE: It does not suffice to override to: null, [], or [""]. Travis will
22+
# fall back to the default if we do.
23+
before_install: echo "Do nothing before install."
24+
install: pip install pre-commit
25+
script:
26+
- pre-commit run --all-files
27+
after_success: echo "Do nothing after success."
28+
after_failure:
29+
- |
30+
echo "You can install pre-commit hooks to automatically run formatting"
31+
echo "on each commit with:"
32+
echo " pre-commit install"
33+
echo "or you can run by hand on staged files with"
34+
echo " pre-commit run"
35+
echo "or after-the-fact on already committed files with"
36+
echo " pre-commit run --all-files"

CONTRIBUTING.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Contributing
22

3-
Contributions to nbresuse are highly welcome!
3+
Contributions to NBResuse are highly welcome! As a [Jupyter](https://jupyter.org) project,
4+
you can follow the [Jupyter contributor guide](https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html).
5+
6+
Make sure to also follow [Project Jupyter's Code of Conduct](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md)
7+
for a friendly and welcoming collaborative environment.
48

59
## Development set up
610

@@ -51,4 +55,38 @@ We recommend using [pipenv](https://docs.pipenv.org/) to make development easier
5155

5256
```bash
5357
MEM_LIMIT=$(expr 128 \* 1024 \* 1024) jupyter notebook
54-
```
58+
```
59+
60+
8. NBResuse has adopted automatic code formatting so you shouldn't
61+
need to worry too much about your code style.
62+
As long as your code is valid,
63+
the pre-commit hook should take care of how it should look. Here is how to set up pre-commit hooks for automatic code formatting, etc.
64+
65+
```bash
66+
pre-commit install
67+
```
68+
69+
You can also invoke the pre-commit hook manually at any time with
70+
71+
```bash
72+
pre-commit run
73+
```
74+
75+
which should run any autoformatting on your code
76+
and tell you about any errors it couldn't fix automatically.
77+
You may also install [black integration](https://github.com/ambv/black#editor-integration)
78+
into your text editor to format code automatically.
79+
80+
If you have already committed files before setting up the pre-commit
81+
hook with `pre-commit install`, you can fix everything up using
82+
`pre-commit run --all-files`. You need to make the fixing commit
83+
yourself after that.
84+
85+
9. It's a good idea to write tests to exercise any new features,
86+
or that trigger any bugs that you have fixed to catch regressions. `pytest` is used to run the test suite. You can run the tests with:
87+
88+
```bash
89+
python -m pytest -vvv nbresuse
90+
```
91+
92+
in the repo directory.

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
# nbresuse
1+
**[Installation](#installation)** |
2+
**[Configuration](#configuration)** |
3+
**[Resources Displayed](#resources-displayed)** |
4+
**[Contributing](#contributing)**
5+
6+
# NBResuse
7+
8+
[![PyPI](https://img.shields.io/pypi/v/nbresuse.svg)](https://pypi.python.org/pypi/nbresuse)
9+
[![PyPI](https://img.shields.io/pypi/l/nbresuse.svg)](https://pypi.python.org/pypi/nbresuse)
10+
[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/yuvipanda/nbresuse/issues)
11+
[![TravisCI build status](https://img.shields.io/travis/jupyter/nbviewer/master?logo=travis)](https://travis-ci.org/yuvipanda/nbresuse)
212
[![Build Status](https://dev.azure.com/tpaine154/jupyter/_apis/build/status/timkpaine.nbresuse?branchName=master)](https://dev.azure.com/tpaine154/jupyter/_build/latest?definitionId=17&branchName=master)
313
[![Coverage](https://img.shields.io/azure-devops/coverage/tpaine154/jupyter/17)](https://dev.azure.com/tpaine154/jupyter/_build?definitionId=17&_a=summary)
4-
[![PyPI](https://img.shields.io/pypi/l/nbresuse.svg)](https://pypi.python.org/pypi/nbresuse)
5-
[![PyPI](https://img.shields.io/pypi/v/nbresuse.svg)](https://pypi.python.org/pypi/nbresuse)
6-
714

815

916
![Screenshot with memory limit](screenshot.png)
1017

11-
NB Resource Usage (nbresuse) is a small extension for Jupyter Notebooks that
18+
NB Resource Usage (NBResuse) is a small extension for Jupyter Notebooks that
1219
displays an indication of how much resources your current notebook server and
1320
its children (kernels, terminals, etc) are using. This is displayed in the
1421
main toolbar in the notebook itself, refreshing every 5s.
@@ -80,9 +87,14 @@ As a command line argument:
8087
jupyter notebook --ResourceUseDisplay.track_cpu_percent=True
8188
```
8289

83-
## Resources displayed
90+
## Resources Displayed
8491

85-
Currently it only displays Memory usage (just RSS). Other metrics will be
92+
Currently the server extension only reports memory usage (just RSS) and CPU usage. Other metrics will be
8693
added in the future as needed.
8794

88-
The notebook extension currently doesn't show CPU usage.
95+
The notebook extension currently doesn't show CPU usage, only memory usage.
96+
97+
## Contributing
98+
99+
If you would like to contribute to the project, please read the [`CONTRIBUTING.md`](CONTRIBUTING.md). The `CONTRIBUTING.md` file
100+
explains how to set up a development installation and how to run the test suite.

setup.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
from glob import glob
22
import setuptools
3+
import pathlib
4+
5+
# The directory containing this file
6+
HERE = pathlib.Path(__file__).parent
7+
8+
# The text of the README file
9+
README = (HERE / "README.md").read_text()
310

411
setuptools.setup(
512
name="nbresuse",
613
version='0.3.3',
714
url="https://github.com/yuvipanda/nbresuse",
815
author="Yuvi Panda",
916
description="Simple Jupyter extension to show how much resources (RAM) your notebook is using",
17+
long_description=README,
18+
long_description_content_type="text/markdown",
19+
license="BSD",
20+
classifiers=[
21+
"License :: OSI Approved :: BSD License",
22+
"Programming Language :: Python :: 3",
23+
],
1024
packages=setuptools.find_packages(),
1125
install_requires=[
1226
'psutil>=5.6.0',

0 commit comments

Comments
 (0)