Skip to content
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

Merged
merged 5 commits into from
Jun 20, 2019

Conversation

choldgraf
Copy link
Contributor

@choldgraf choldgraf commented Jun 19, 2019

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? :-)

@codecov
Copy link

codecov bot commented Jun 19, 2019

Codecov Report

Merging #257 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 513b7a6...c0ff979. Read the comment docs.

@mwouts
Copy link
Owner

mwouts commented Jun 19, 2019

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
Copy link
Owner

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
Copy link
Owner

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

"\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",
Copy link
Owner

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.

"from IPython.display import JSON\n",
"notebook = nbf.read('./get_started.ipynb', nbf.NO_CONVERT)\n",
"JSON(notebook['metadata'])"
]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice example! Thanks

Copy link
Owner

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 😄

Copy link
Contributor Author

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

Copy link
Owner

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

"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)"
]
Copy link
Owner

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.

@choldgraf
Copy link
Contributor Author

ok - latest push does the following things:

  • Removes most of the demo files (all but the World population.ipynb one)
  • Adds a "getting started" file in markdown
  • Adds a bit to the postBuild script that will create a notebook from this, then remove the md file in the Binder
  • Addresses some miscellaneous stuff you mentioned above

What do you think?

@mwouts
Copy link
Owner

mwouts commented Jun 20, 2019

Excellent! Thank you so much @choldgraf . I have only three remarks left:

  • I'd prefer to keep all the text representations of the World Population notebook (sorry I was not clear), because it is even easier to go to the demo folder on GitHub and have a look at them rather than starting binder. And we have links to these text representations in the doc - see also Links to sample md files do not work in read the docs #255
  • I think you can remove the Paired Jupyter notebook and python script completely. So, in .gitignore we should just see get_started.ipynb
  • In the notebook, you use the word language to describe the text representation of the notebook. Maybe I would have rather used format. What do you think?

@choldgraf
Copy link
Contributor Author

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 .md if you're using the markdown parser, but if you make it mylink.org/myfile.md#some-header then that will prevent it from being stripped.

@mwouts mwouts merged commit af70905 into mwouts:master Jun 20, 2019
@mwouts
Copy link
Owner

mwouts commented Jun 20, 2019

Well done! Thank you again @choldgraf

@mwouts mwouts mentioned this pull request Jun 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants