alibi icon indicating copy to clipboard operation
alibi copied to clipboard

Add nbstripout

Open mauicv opened this issue 3 years ago • 5 comments

Add nbstripout as a pre-commit-hook. nbstripout is configured to remove everything except the cell outputs. I've also run it against all the files.

mauicv avatar Apr 27 '22 14:04 mauicv

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Codecov Report

Merging #644 (44a08c5) into master (3772a89) will increase coverage by 0.06%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #644      +/-   ##
==========================================
+ Coverage   80.39%   80.45%   +0.06%     
==========================================
  Files          77       77              
  Lines       10597    10634      +37     
==========================================
+ Hits         8519     8556      +37     
  Misses       2078     2078              
Impacted Files Coverage Δ
alibi/explainers/tests/test_ale.py 100.00% <0.00%> (ø)
alibi/explainers/ale.py 64.57% <0.00%> (+4.27%) :arrow_up:

codecov[bot] avatar Apr 27 '22 14:04 codecov[bot]

This slightly changes our example notebooks as there are no more execution counts besides cells (i.e. [1] becomes [ ]), this is probably not an issue per-se, but as this is as pre-commit hook then it will not be used by everyone so we will end up with a mix of real and null execution counts in the docs. Is there an option to keep the execution counts?

jklaise avatar Apr 27 '22 15:04 jklaise

This slightly changes our example notebooks as there are no more execution counts besides cells (i.e. [1] becomes [ ]), this is probably not an issue per-se, but as this is as pre-commit hook then it will not be used by everyone so we will end up with a mix of real and null execution counts in the docs. Is there an option to keep the execution counts?

Hmm True, Although if not everyone uses this then they're we'll still end up with the other stuff, like the pycharm data in the notebooks? I had left the execution count stuff out as it was annoying editing the notebooks so the execution count was in the correct order. I almost want to suggest going the other way and adding tests to check the notebooks have been cleaned? This would push developers to use the pre-commit hook/clean them themselves. Maybe this isn't necessary though.

mauicv avatar Apr 27 '22 16:04 mauicv

  • nbstripout doesn't actually remove metadata introduced by pycharm.
  • It can be run so as not to submit changes to the notebooks using nbstriptout run --dry-run but seemingly this option doesn't work with the --keep-outputs option.

In order to remove the pycharm metadata in #583 I just wrote a quick script that does so using nbformat. I've committed it here as potentially it's a simpler solution.

mauicv avatar Apr 28 '22 13:04 mauicv