Name | squeaky JSON |
Version |
0.7.0
JSON |
| download |
home_page | |
Summary | Remove noise from notebooks for cleaner version control diffs |
upload_time | 2024-03-09 11:42:04 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Squeaky
> ✨ Make your Jupyter notebooks squeaky clean ✨
Squeaky removes unwanted changes to your notebooks to make your Git diffs
cleaner. Tools like [nbdime](https://nbdime.readthedocs.io/en/latest/) and
[ReviewNB](https://www.reviewnb.com/) are awesome, but can be clunky and
difficult to learn. Instead, Squeaky makes it easier to manage notebook diffs
with standard Git tools.
## Usage
First, install:
```sh
pip install squeaky
```
Then use Squeaky to clean a notebook:
```sh
squeaky path/to/notebook(s).ipynb
```
To check notebooks without modifying them, use the `--check` flag.
```sh
squeaky path/to/notebook.ipynb --check
```
### Jupyter pre-save hook
You can automatically run your notebooks through Squeaky before saving them by
editing your Jupyter config file. First, find the location of your config
directory by running
```sh
jupyter --config-dir
```
Your config directory may contain either a `jupyter_lab_config.py` or a
`jupyter_server_config.py` (if neither exists, create an empty file with either
of these names).
> :warning: If you're using Jupyter notebook < 7, then the file will be called
> `jupyter_notebook_config.py`.
Then, add the following lines to that config file.
```python
from squeaky import squeaky_clean_hook
c.FileContentsManager.pre_save_hook = squeaky_clean_hook
```
### Pre-commit hook
To use with [pre-commit](https://pre-commit.com/), add the following to your
`.pre-commit-config.yaml`.
```yaml
repos:
- repo: local
hooks:
- name: Clean notebooks
id: clean-notebooks
entry: squeaky --check
language: python
files: '(.*?).ipynb$'
```
## Features
- **Reset metadata**
If you're running your notebooks in CI, then you probably don't care about
the last environment a notebook was edited in. Squeaky resets notebook
metadata to a standard metadata.
- **Minify SVGs**
Setting code image outputs to SVGs makes images look great, but comes with
horrendous diffs. Squeaky minifies SVG outputs to a single line, which also
reduces file size.
- **Reset IDs in SVG outputs**
SVG outputs have another problem: Randomized IDs in the source. Squeaky
re-generates these IDs deterministically using on the cell's unique ID. This
means re-running the notebook won't change the output unless the image
actually changes.
- **Remove trailing whitespace**
Often missed in markdown (but not in version control), Squeaky removes
trailing whitespace from ends of lines *and* empty lines from ends and
beginnings of cells.
- **Remove empty cells**
Squeaky removes empty cells, including that annoying empty code cell at the
bottom of every other notebook.
- **Add missing cell IDs**
Cells without IDs now raise a warning in `nbformat`. Squeaky adds these IDs
for you so you don't need to think about it.
## Contributing
To install requirements and add pre-commit hooks:
```sh
pip install -r requirements-dev.txt
pre-commit install
```
To run unit tests (also run on commit):
```sh
tox
```
## Wishlist
- **Turn off features through config file**
Raw data
{
"_id": null,
"home_page": "",
"name": "squeaky",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "",
"author_email": "Frank Harkins <frankharkins@hotmail.co.uk>",
"download_url": "https://files.pythonhosted.org/packages/6a/67/afc4ced0e3bffa871ba66b656a7f63d7b72851a9d1f99daf6304230f0b54/squeaky-0.7.0.tar.gz",
"platform": null,
"description": "# Squeaky\n\n> \u2728 Make your Jupyter notebooks squeaky clean \u2728\n\nSqueaky removes unwanted changes to your notebooks to make your Git diffs\ncleaner. Tools like [nbdime](https://nbdime.readthedocs.io/en/latest/) and\n[ReviewNB](https://www.reviewnb.com/) are awesome, but can be clunky and\ndifficult to learn. Instead, Squeaky makes it easier to manage notebook diffs\nwith standard Git tools.\n\n\n## Usage\n\nFirst, install:\n\n```sh\npip install squeaky\n```\n\nThen use Squeaky to clean a notebook:\n\n```sh\nsqueaky path/to/notebook(s).ipynb\n```\n\nTo check notebooks without modifying them, use the `--check` flag.\n\n```sh\nsqueaky path/to/notebook.ipynb --check\n```\n\n### Jupyter pre-save hook\n\nYou can automatically run your notebooks through Squeaky before saving them by\nediting your Jupyter config file. First, find the location of your config\ndirectory by running\n\n```sh\njupyter --config-dir\n```\n\nYour config directory may contain either a `jupyter_lab_config.py` or a\n`jupyter_server_config.py` (if neither exists, create an empty file with either\nof these names).\n\n> :warning: If you're using Jupyter notebook < 7, then the file will be called\n> `jupyter_notebook_config.py`.\n\nThen, add the following lines to that config file.\n\n```python\nfrom squeaky import squeaky_clean_hook\nc.FileContentsManager.pre_save_hook = squeaky_clean_hook\n```\n\n### Pre-commit hook\n\nTo use with [pre-commit](https://pre-commit.com/), add the following to your\n`.pre-commit-config.yaml`.\n\n```yaml\nrepos:\n - repo: local\n hooks:\n - name: Clean notebooks\n id: clean-notebooks\n entry: squeaky --check\n language: python\n files: '(.*?).ipynb$'\n```\n\n## Features\n\n- **Reset metadata**\n\n If you're running your notebooks in CI, then you probably don't care about\n the last environment a notebook was edited in. Squeaky resets notebook\n metadata to a standard metadata.\n\n- **Minify SVGs**\n\n Setting code image outputs to SVGs makes images look great, but comes with\n horrendous diffs. Squeaky minifies SVG outputs to a single line, which also\n reduces file size.\n\n- **Reset IDs in SVG outputs**\n\n SVG outputs have another problem: Randomized IDs in the source. Squeaky\n re-generates these IDs deterministically using on the cell's unique ID. This\n means re-running the notebook won't change the output unless the image\n actually changes.\n\n- **Remove trailing whitespace**\n\n Often missed in markdown (but not in version control), Squeaky removes\n trailing whitespace from ends of lines *and* empty lines from ends and\n beginnings of cells.\n\n- **Remove empty cells**\n \n Squeaky removes empty cells, including that annoying empty code cell at the\n bottom of every other notebook.\n\n- **Add missing cell IDs**\n\n Cells without IDs now raise a warning in `nbformat`. Squeaky adds these IDs\n for you so you don't need to think about it.\n\n## Contributing\n\nTo install requirements and add pre-commit hooks:\n\n```sh\npip install -r requirements-dev.txt\npre-commit install\n```\n\nTo run unit tests (also run on commit):\n\n```sh\ntox\n```\n\n## Wishlist\n\n- **Turn off features through config file**\n",
"bugtrack_url": null,
"license": "",
"summary": "Remove noise from notebooks for cleaner version control diffs",
"version": "0.7.0",
"project_urls": {
"Bug Tracker": "https://github.com/frankharkins/squeaky-nb/issues",
"Homepage": "https://github.com/frankharkins/squeaky-nb"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b63a3ca6127c4987482f0cfc3e9f8ca71b6de85647979a3f115bb12c261558a8",
"md5": "ca3f28c43eea2547a5fa9c85e3714cdb",
"sha256": "f9810e459e394dc0a66115fd2a7a508ded2c8f11fe2e856bc5c48339739fd48a"
},
"downloads": -1,
"filename": "squeaky-0.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ca3f28c43eea2547a5fa9c85e3714cdb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12431,
"upload_time": "2024-03-09T11:42:02",
"upload_time_iso_8601": "2024-03-09T11:42:02.932901Z",
"url": "https://files.pythonhosted.org/packages/b6/3a/3ca6127c4987482f0cfc3e9f8ca71b6de85647979a3f115bb12c261558a8/squeaky-0.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6a67afc4ced0e3bffa871ba66b656a7f63d7b72851a9d1f99daf6304230f0b54",
"md5": "296a17756c0db80aab66fd1970b21e7a",
"sha256": "404c79ed32be0bdcf031998aabd65011a22af48ccb2905c298e61081aa5effc1"
},
"downloads": -1,
"filename": "squeaky-0.7.0.tar.gz",
"has_sig": false,
"md5_digest": "296a17756c0db80aab66fd1970b21e7a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 22603,
"upload_time": "2024-03-09T11:42:04",
"upload_time_iso_8601": "2024-03-09T11:42:04.677177Z",
"url": "https://files.pythonhosted.org/packages/6a/67/afc4ced0e3bffa871ba66b656a7f63d7b72851a9d1f99daf6304230f0b54/squeaky-0.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-09 11:42:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "frankharkins",
"github_project": "squeaky-nb",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "squeaky"
}