You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_static/misc/mergeWithNotebooks.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,13 @@ Interactive tutorials are in notebooks. A full "experiment" in the lab is contai
8
8
Jupyter notebooks have two sections: inputs (code, markdown) and outputs (stdout, plots, images). Interactive python notebook files embed compiled outputs. This is good if you want to restart a kernel but still see the output, or if you close the file, etc.
9
9
10
10
### Solution 1 and Problem 2: The nbstripout filter
11
-
This is a cool thing that is integrated within the git commands. It basically ignores all of the outputs and metadata of `.ipynb` files. When you commit and push, it only pushes the inputs. It is installed via the requirements.txt, but there is also some interesting [discussion](https://stackoverflow.com/questions/18734739/using-ipython-notebooks-under-version-control/20844506) and [documentation](https://github.com/toobaz/ipynb_output_filter)
11
+
`nbstripout` is a Git filter and "hides" the output and some metadata in `.ipynb` files from Git such that it does not get committed. This allows only tracking the actual input code cells in Git. It is installed via the `requirements.txt`, but there is also some interesting [discussion](https://stackoverflow.com/questions/18734739/using-ipython-notebooks-under-version-control/20844506) and [documentation](https://github.com/kynan/nbstripout)
12
12
13
13
#### There are three downsides:
14
14
1. What if you liked keeping those outputs without rerunning every commit?
15
15
2. It has to strip evvverything, including all those high-quality graphics, every single time you `git status`.
16
16
3. It crashes your essential commands. Very easy to get into a chicken-and-egg hole where you can't `diff` anything because __some__thing isn't JSON -- causing a crash -- but you can't figure out what isn't JSON because you can't see which files just changed.
17
-
4. It corrupts your files. That's why we made cleannbline.
17
+
4. It can corrupt files. That's why we made `cleannbline`.
18
18
19
19
### Solution 2. Deactivate the nbstripout filter
20
20
@@ -75,13 +75,13 @@ Run
75
75
76
76
git status
77
77
78
-
It takes some time. What is that error? It means that some of the notebooks are not sufficiently JSON for the nbstripout filter.
78
+
It takes some time. What is that error? It means that some of the notebooks are not valid JSON and cannot be parsed by the `nbstripout` filter.
79
79
80
80
In the crash log, it should point to a certain file, let's say `notebooks/Test.ipynb` First, clean it with
81
81
82
82
./cleannbline notebooks/Test.ipynb
83
83
84
-
Then, open that file in Sublime and search for `<<<<`. Sometimes conflicts in your stash can get hidden in a way that does not show up in Jupyter. nbstripout will crash. You can find it in Sublime.
84
+
Then, open that file in Sublime and search for `<<<<`. Sometimes conflicts in your stash can get hidden in a way that does not show up in Jupyter. `nbstripout` will crash. You can find it in Sublime.
85
85
86
86
Return to running `git status` until it completes without error. It should show a ton of modifications: those are the effects of stripping. Add those and commit
87
87
@@ -95,13 +95,13 @@ Your filter is currently active, so when you try
95
95
96
96
it will automatically crash. As above though, it will point to a file. Keep going until `git status` completes. Add those and commit.
97
97
98
-
Side note: even though `git status` shows a ton of modifications, you should get a clean `git diff` (Although sometimes it will just crash, NBD). Both commands are applying the ipynb filter... in some way.
98
+
Side note: even though `git status` shows a ton of modifications, you should get a clean `git diff` (Although sometimes it will just crash, NBD). Both commands are applying the `.ipynb` filter... in some way.
You will get conflicts in two categories: notebooks and other. Since there are `<<<<`things everywhere, your `git diff` will crash while you're in the merge. It also doesn't point you to an offending file. Here is where you'll really appreciate Sublime.
104
+
You will get conflicts in two categories: notebooks and other. Since there are `<<<<`conflict markers everywhere, your `git diff` will crash while you're in the merge. It also doesn't point you to an offending file. Here is where you'll really appreciate Sublime.
105
105
106
106
Make sure Sublime opens the entire `notebooks`_directory_. That way Find All will search all the files.
107
107
@@ -116,7 +116,7 @@ Repeat for all the notebooks. Then do the same for all the regular code files. W
116
116
117
117
git commit
118
118
119
-
If for some reason, you want to escape the merge while keeping the test_merge branch stripped, you can run `git reset --hard`
119
+
If for some reason, you want to abandon the merge while keeping the test_merge branch stripped, you can run `git reset --hard`
120
120
121
121
#### Finalize
122
122
Double check that everything went well (i.e. open some notebooks in Jupyter). If something screwed up in your merging _or_ stripping, you can just delete the test_merge branch and start over.
0 commit comments