diff --git a/README.md b/README.md index 2d13d9f..0d9ca78 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,8 @@ For a concrete example, look at this link to [the recent revamped Reptile code f is in the MetaLearning folder of this repo. + + #### Git-friendly iPython Notebooks Using the code from : http://pascalbugnion.net/blog/ipython-notebooks-and-git.html (and @@ -226,6 +228,18 @@ simply add to its metadata (Edit-Metadata) as a first-level entry (``true`` is t "git" : { "suppress_outputs" : false }, ``` +#### Git-friendly iPython Notebooks (Looks promising, but...) + +[nbstripout](https://github.com/kynan/nbstripout) seems to do what we want, and can be installed more easily. + +Within the local python environment (or do this globally, as root, if you're committed) : + +``` +pip install nbstripout +```` + + + ### Useful resources diff --git a/bin/ipynb_optional_output_filter.py b/bin/ipynb_optional_output_filter.py index deb64b3..f39a061 100755 --- a/bin/ipynb_optional_output_filter.py +++ b/bin/ipynb_optional_output_filter.py @@ -65,7 +65,7 @@ json_in = json.loads(nb) nb_metadata = json_in["metadata"] -suppress_output = True +suppress_output = True # This is the default value - i.e. clean outputs by default if "git" in nb_metadata: if "suppress_outputs" in nb_metadata["git"]: suppress_output = nb_metadata["git"]["suppress_outputs"] @@ -81,6 +81,8 @@ def strip_output_from_cell(cell): cell["outputs"] = [] if "prompt_number" in cell: del cell["prompt_number"] + if "execution_count" in cell: + cell["execution_count"]=None # Translates to 'nil' in JSON if ipy_version == 2: @@ -91,4 +93,4 @@ def strip_output_from_cell(cell): for cell in json_in["cells"]: strip_output_from_cell(cell) -json.dump(json_in, sys.stdout, sort_keys=True, indent=1, separators=(",",": ")) +json.dump(json_in, sys.stdout, sort_keys=True, indent=1, separators=(",", ": ")) diff --git a/config/requirements.txt b/config/requirements.txt index d639144..3dbf958 100644 --- a/config/requirements.txt +++ b/config/requirements.txt @@ -121,3 +121,6 @@ gensim # Plotting of graphs (simpler, but beautiful too) #seaborn + + +nbstripout