-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a getting started notebook for jupytext (and Binder) #257
Conversation
Codecov Report
@@ Coverage Diff @@
## master #257 +/- ##
=======================================
Coverage 99.16% 99.16%
=======================================
Files 66 66
Lines 6491 6491
=======================================
Hits 6437 6437
Misses 54 54 Continue to review full report at Codecov.
|
Thanks @choldgraf . Yes sure a step by step demo is a great idea! And even maybe, we could cleanup the demo folder and just keep 1. this getting started notebook, and 2. the other World population notebook (which role is to demo all the available formats). |
@@ -3,3 +3,8 @@ python -m bash_kernel.install | |||
|
|||
# Trust our notebook | |||
jupyter trust demo/World\ population.ipynb | |||
|
|||
# Set up extensions for JupyterLab and Notebook | |||
jupyter labextension install jupyterlab-jupytext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. If we don't include that line, then we get asked if the jupytext extension for jupyterlab should be built, so it's better to do that in advance
binder/postBuild
Outdated
# Set up extensions for JupyterLab and Notebook | ||
jupyter labextension install jupyterlab-jupytext | ||
jupyter nbextension install --py jupytext --user | ||
jupyter nbextension enable --py jupytext --user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these two lines are not needed: the notebook extension is already available in the current binder
demo/get_started.ipynb
Outdated
"\n", | ||
"That's it! If you have Jupytext installed, it will now save your notebook in\n", | ||
"markdown format automatically when you save this `.ipynb` file.\n", | ||
"\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add something like 'in addition'. It is important to make it clear that Jupyter will continue to save the original notebook as well! Also, maybe we can mention that the two files really point to the same document, and that the Markdown file can be edited as well.
demo/get_started.ipynb
Outdated
"from IPython.display import JSON\n", | ||
"notebook = nbf.read('./get_started.ipynb', nbf.NO_CONVERT)\n", | ||
"JSON(notebook['metadata'])" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice example! Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chris, one meta-question... would you mind if we stored this notebook in its Markdown representation in the demo
folder, and generate the ipynb
in the postBuild with Jupytext? This way we would'nt need to review an ipynb file any more 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh that's a cool idea - yeah sounds good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More explicitly: I was thinking of adding these lines to postBuild
:
cd demo
jupytext get_started.md --to ipynb --update-metadata '{"jupytext":null}'
rm get_started.md
demo/get_started.ipynb
Outdated
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"plt.scatter(*np.random.randn(2, 100), c=np.random.randn(100), s=np.random.rand(100)*100)" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me think that we do not have an explicit mention that Jupytext works with every kind of notebook, even the most interactive notebooks with widgets, etc... Maybe we could write a FAQ section in the help and include typical questions like that one.
ok - latest push does the following things:
What do you think? |
Excellent! Thank you so much @choldgraf . I have only three remarks left:
|
good points - ok I think I addressed all of the above. I also fixed #255 by a hacky solution, which is to add an anchor to the link. Apparently readthedocs will automatically strip out the |
Well done! Thank you again @choldgraf |
This adds an extra notebook to the demo notebooks, updates the Binder
postBuild
files to activate the lab and notebook extensions, and updates the Binder link to point to this new notebook.Here's what the link will look like when people click it now:
https://mybinder.org/v2/gh/choldgraf/jupytext/binder_env?urlpath=lab/tree/demo/get_started.ipynb
(note, the link above points to my fork so it'll build, but the PR link points to the right repo)
What do you think? :-)