Skip to content

Commit

Permalink
Actually, existing approach works pretty well...
Browse files Browse the repository at this point in the history
  • Loading branch information
mdda committed Apr 10, 2018
1 parent 04681ab commit 792194f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions bin/ipynb_optional_output_filter.py
Expand Up @@ -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"]
Expand All @@ -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:
Expand All @@ -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=(",", ": "))
3 changes: 3 additions & 0 deletions config/requirements.txt
Expand Up @@ -121,3 +121,6 @@ gensim

# Plotting of graphs (simpler, but beautiful too)
#seaborn


nbstripout

0 comments on commit 792194f

Please sign in to comment.