https://github.com/adrn/dropoutput
Remove cell numbers and output from IPython notebooks when adding to a git repository
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (7.6%) to scientific vocabulary
Repository
Remove cell numbers and output from IPython notebooks when adding to a git repository
Basic Info
- Host: GitHub
- Owner: adrn
- License: mit
- Language: Python
- Default Branch: main
- Size: 8.79 KB
Statistics
- Stars: 9
- Watchers: 3
- Forks: 2
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
Clear Jupyter notebook output on commit
Removes cell numbers and output from IPython notebooks added to a git repository, but leaves the files unchanged.
Note: this only works for notebook versions >= 3
Install
Clone or download this repository. Let's assume you clone it to:
~/.config/git/dropoutput/Make sure the
drop_ipynb_output.pyscript is executable, e.g.:chmod a+x ~/.config/git/dropoutput/drop_ipynb_output.pyAdd a git filter for files with .ipynb extensions. Add this to your git attributes file (usually located in
~/.config/git/attributes):*.ipynb filter=clean_ipynbConnect the
drop_ipynb_output.pyscript to the filter:git config --global filter.clean_ipynb.clean "~/.config/git/dropoutput/drop_ipynb_output.py %f" git config --global filter.clean_ipynb.smudge cat
Configuration
By default, this script will tell git to ignore prompt numbers and cell output when adding any .ipynb file to a git repositorie. Note that the notebook files themselves are not changed, this script just filters out the outputs before adding and committing with git.
This default behavior can be changed either on a notebook-by-notebook basis, or for entire paths. To include output for a single notebook, modify the metadata of the notebook (Edit -> Edit Notebook Metadata in the menu bar) and add this line to the metadata:
"git" : { "clear_outputs" : false }
To include output for any notebook that matches a given glob pattern (e.g., for an entire path), you can create and add paths to the file: ~/.config/git/cleanipynbignore. For example, to include output for all notebooks in ~/projects/notebooks that start with "demo", add a line to the ignore file with:
~/projects/notebooks/demo*
Acknowledgements
This code was inspired by this blog post.
Owner
- Name: Adrian Price-Whelan
- Login: adrn
- Kind: user
- Location: NYC
- Company: Flatiron Institute
- Website: adrian.pw
- Repositories: 124
- Profile: https://github.com/adrn
GitHub Events
Total
Last Year
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Adrian Price-Whelan | a****w@g****m | 17 |
Issues and Pull Requests
Last synced: over 1 year ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 5.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Carreau (1)