https://github.com/adrn/dropoutput

Remove cell numbers and output from IPython notebooks when adding to a git repository

https://github.com/adrn/dropoutput

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
Last synced: 11 months ago · JSON representation

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
Created over 10 years ago · Last pushed about 6 years ago
Metadata Files
Readme License

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

  1. Clone or download this repository. Let's assume you clone it to:

    ~/.config/git/dropoutput/
    
  2. Make sure the drop_ipynb_output.py script is executable, e.g.:

    chmod a+x ~/.config/git/dropoutput/drop_ipynb_output.py
    
  3. Add a git filter for files with .ipynb extensions. Add this to your git attributes file (usually located in ~/.config/git/attributes):

    *.ipynb  filter=clean_ipynb
    
  4. Connect the drop_ipynb_output.py script 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

GitHub Events

Total
Last Year

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 17
  • Total Committers: 1
  • Avg Commits per committer: 17.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels