Sharing Jupyter notebooks during lectures

I’m an instructor/trainer in Python and data science. Just about every day, I’m teaching a course to a company somewhere in the world.

My main tool in lectures is Jupyter; I currently use the notebook, but will likely switch to the lab in the future.

Right now, I type + talk when I lecture, live-coding everything. I then share my notebooks (via e-mail) at the end of each class day. So if I have a 4-day course, I end up having 4 .ipynb files, which I e-mail to course participants.

This is obviously less than ideal. I’d love to have my students be able to view my notebooks as I’m writing them. (This is particularly true when I give them exercises, which happens a lot; they ask me to scroll up and down so that they can see the reference material and/or the question text.)

I’ve tried a few ways to do this so far, but they’ve all ended poorly, mostly because Jupyter doesn’t seem to offer a read-only mode for my students to view the notebooks while I continue to write to them.

So:

  • Is there a good way for me to have read/write access to a Jupyter notebook, and for my students to have read-only access, while I continue to update it?
  • If there isn’t a good way to do this, is there a non-terrible way?

I’m open to any and all ideas. Thanks!

Reuven

1 Like

Have you tried Chris Holdgraf’s gitautopush?

3 Likes

I didn’t realize that anybody used that other than me :slight_smile:

but yes I was going to suggest the same workflow. gitautopush is a little tool that watches a folder and automatically git-pushes any changes that it finds. I use it for live-coding lectures. At the beginning of class I send students a link to my github repo, then turn on gitautopush in a new terminal pointing it to my content folder. As I make changes throughout the class, they’re automatically pushed up to github, and students can just refresh the page to get the latest version

3 Likes

“gitautopush” seems like an interesting idea, and better than what I have now (i.e., nothing). But it would require committing on a regular basis.

Is there a way that I can use Jupyter read-write on a public server, and my students can access it read-only, so that as it checkpoints/saves, they can see the latest updates?

I spoke way too soon. I missed the part that it auto-commits. I thought that it would only (as per the name) auto push.

That said, many of my students don’t know Git. (Although I do teach Git courses, so maybe it’s a good business opportunity…) But again, this is far better than nothing. I’m going to play with it, and see how far I can get. But additional ideas are very welcome.

There are a few options to how you integrate the students relating to the updating versions made by gitautopush. It sounds like you might want to use the nbconvert step and use a URL which I discuss in the second paragraph, but first I want to address your concern about git.

The students wouldn’t necessarily need to know git is involved, just that you are posting updates as you progress through the training. You can just post for them the link to the static (a.ka. read-only) version at Github and they view that, refreshing every so often. Github has its own URL shortener so you could just give them a link made from there to the notebook and they could watch it . Or use a similar URL shortener to make a link to the notebook. (I like yellkey for giving out the link with a simple word, but it is only temporary. Bit.ly lets you customize the url so you can make it something easier to type/remember and that will be permanent.) The static views nbviewier renders look nicer and work without the reload errors that notebooks on Github often throw, but they don’t update entirely fast.

Or if you are using the nbconvert option, you just give them a link to the html version notebook you are working on. (Chris’s suggestion is to use public sharing of the HTML link via Dropbox.) Again here you can use a shortener to make the distribution easier if you aren’t simply posting it in as a link on a page somewhere. Does the meta refresh tag work in modern browsers still? If so, you could add a step that adds the tag to the HTML nbconvert makes and then not have to instruct the students to refresh every so often.

3 Likes

Aha, this makes a lot of sense. I was thinking that it would push to a repo, but then people would have to pull to get the update. Your point is that GitHub makes repos visible, such that they can just use a browser.

I’m going to play with this a bit. I’m doing some training next week, and I’ll let you know how it goes! This should be very exciting.

2 Likes

@choldgraf, you have changed my life! Wow! I started using gitautopush yesterday in one of my classes, and while I have to standardize the naming and locations, it’s generally doing what I want – making my current notebook available to my students.

I didn’t figure out how the nbviewer option works; the documentation indicates that an image shows you what to do, but the image didn’t make it clear for me. Would you please describe that, too?

This is really an amazing tool that more people should know about. I’m delighted and impressed, as well as grateful.

6 Likes

Hey @reuven - I just released a new version of gitautopush that should be a little bit more straightforward to use (and maintain). It removes the nbconvert functionality, but replaces it with more discoverabl nbviewer links etc. I’d love to hear any feedback if you’ve got it!

https://github.com/choldgraf/gitautopush

4 Likes