-
Notifications
You must be signed in to change notification settings - Fork 18
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
Use Google Colab to load ipynb examples directly from documentation? #57
Comments
Sounds worth trying out, although there a couple challenges. The big one is that we don't include all the trajectory files in the repository, so you'll need a way to download data files (maybe there are magics to help with that, though?) If you look at the OPS additional examples, I have a (bash) script to download and install from figshare. Requires curl and unzip: Also, our install isn't quite that easy (requires numpy and cython separately, because they're required for the build phase of MDTraj). That might be straightforward, although numpy often makes things difficult, especially if the environment already has numpy installed. Of course, if there's a way to use conda instead, then it is a lot easier. |
(sorry for formatting, as I am on my phone) |
Current status: https://colab.research.google.com/drive/1YSzxUtk_fVLhVNiLcJcBoJuc9g261RS-
Will see if I can alter the notebooks this week/ early next week. Question: do we want to host specific colab-versions of the ipynb's (maybe build on the fly by CI as we just have to add 1 cell to the start of the ipynb) or do we want to add the install and curl/unzip code to all our example notebooks? |
Glad to see that it (basically) works! I mean, you should definitely check that everything runs -- weird linking problems might only show up at runtime.
This is a good question. Let me list what I see as the pros/cons of each: Add install and download code to the notebooksPro:
Con:
Build colab-specific versions on the flyPro:
Con:
Alternate approachWhile typing this up, I thought of another possibility. What about adding the relevant information to a cell in each of the notebooks, but saving that cell as markdown? Give instructions on how to add a new code cell and then they copy-paste (it seems that colab doesn't have the ability to convert cell types; at least not that I could find). This avoids the cons of leaving that cell as runnable code, and remains easy to do. To add testing of our notebooks, we can just add the downloads to the testing script. |
Additional question: is there a way to add widgets in colab? (e.g., I think one of our examples suggesting visualizing with NGLView). I believe that NGLView manages to get itself working with Binder -- and we might consider doing something like what you're suggesting with Binder, instead of colab. This solves the installation side, at least. |
Quick answer: No custom widgets like NGLview for now, maybe later. nglviewer/nglview#816
I would opt for the badge in the examples with a link to a different ipynb on this repository (that is not included with the docs).
I will open a MR with these implementations soon. |
|
fair point.
Just my inexperience with binder vs colab. But you are right. That is probably the better way to go. |
From looking over it, Binder should be really easy to set up.
Take a look at nglview's binder dir for inspiration. I think we can plan on 2 kinds of badges/links:
Actually, I think we probably want to use the JupyterLab link format; see https://mybinder.readthedocs.io/en/latest/howto/user_interface.html to modify the URLs (basically, add You can already play with the mybinder site to set up the URLs -- right now the notebooks will error if you run them, because the requirements aren't installed, but here are the kinds of URLs I was thinking: |
I have gained some experience with setting up binder (for teaching purposes (python), and a proof of principle tutorial for a compiled Fortran program) and agree it is a better solution for our needs, shall I update the title of this issue to reflect that, or shall I close this and open a new issue? |
Looking at this link.
Together with
!pip install contact-map
jupytermagic
It should be feasible to allow people to run our examples from the website directly in their browser, without any download required.I think this would be a good idea to implement in our read the docs template for the examples (especially the badge mentioned in the link).
@dwhswenson what do you think?
The text was updated successfully, but these errors were encountered: