Tip: speed up Binder launches by pulling github content in a Binder link with nbgitpuller

Wow. that’s astonishing how i looked right past all those 20 s when looking at the links in your notebook. Thanks for taking the time to write up such a thorough explanation. And thanks again for the technique.

1 Like

i can even directly link into a notebook that start copies in from another repo! thanks. so nice.

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/sawula/datasci_mods/HEAD/?urlpath=lab/tree/notebooks/Lesson%2000%20b0.ipynb). Just double-checked. That change in URL(path) to launch with a particular notebook does not trigger a rebuild.

I guess it was doing that with index.ipynb already.

Yes, the only thing that triggers a new build of the image is a change to the repository that is the source. In other words a new commit when you are directing the the head point.
The change at the end of the URL, after the ?, just directs Binder to pass instructions through to open that path upon start of the session.

However, if you edit your launch badge URL in the README in your main source repo to be ‘correct’ that should trigger a rebuild of your image.

Now I understand. Thanks!

Hi Chris. I’ve been using this approach for several years for a course I am teaching. Today, I suddenly get an error when trying to launch content with an environment defined in another repo:

Jupyter command jupyter-serverextension not found.

Any tips? I have tried using “jupyter server extension enable --py nbgitpuller --sys-prefix” in postBuild, which seems to enable nbgitpuller successfully, but then the binder page never loads.

Thanks.

/Peter

Okay, I was able to avoid this error by emulating the environment used here - only marginal changes from my existing environment (don’t ask to install pip, adding defaults to list of channels).

It’s simpler than that these days. I’m not sure why you are dealing with jupyter extension, postBuild, and five year old examples. I could provide more specific help if you actually shared the link to your repo, which is general good starting point for getting advice for use of MyBinder.

I just tested a launch from this repo using gitpuller to get the content from another source. You can try it yourself by clicking here. If you dig around further in your repo, you’ll see there is no need for use of postBuild as extensions don’t need separate enabling steps after installing in modern Jupyter. My environment.yml is constructed a bit different from that old reference you bring up. However, I don’t think there is any real difference between using pip vs conda for the install of nbgitpuller because this repo works as the source and only involves pip/requirements.txt. You can demonstrate that for yourself try using nbgitpuller with that repo as the environment basis with this link. It does seem a bit slower than usual at the end showing the notebook at the end but works with patience. Maybe it is my internet as I did reload that particular one after it seemed to be done but not displaying?

As to why you are seeing the issue now…
Do you mean you are seeing it this year as you are coming back to use it again for teaching? Or it was working last month or week and now isn’t? I’d have an idea about why you are seeing it now if you haven’t tried it in several months.

The former, definitively.

Your more recent example will likely be of great help to me. I realize that this post (and my approach) is quite old, and I will make an attempt to modernize following your example(s).

Best,

Peter

Ah yes. A lot has changed in the Jupyter ecosystem in the last year, and by extension in MyBinder land. (The bottom part of this post here may give you a better idea.) A lot of the legacy cruft and leftovers may be interfering with the newer jupyter server stuff that launched a few months ago. The good news is though that everything should be much easier to use. Saying goodbye to enabling extensions is one such example. So getting stuff up to date shouldn’t be too hard because usually it just means simplifying and letting the MyBinder infrastructure handle things as it wants.

Thanks so much for your quick response @fomightez.

That is incredibly helpful - I am hoping to use this for teaching starting Tuesday!

Does that mean that the target repo only needs to have a requirements.txt file, nothing else?

A requirements.txt can be sufficient in the repo specifying the environment that will be doing the pulling of the content. You can continue though to use environment.yml files, too.

Great, thanks.

OT question (which lead me to discover the bug in my code, so ultimately good): Can I use css to style the markdown in my jupyter notebooks hosted with binder? If so, where should the css file go?

This is… probably not a good idea for production work in 2024, where production means “users are paying for value from an un-funded community resource.”

While mybinder.org might have been working fine over the holidays, it will likely go back to not working reliably come Monday as more people are using it, which is an entirely frustrating experience.

Without writing fat checks to buy more mybinder capacity, there aren’t a lot of free-as-in-beer-and-as-in speech options for “give me a free (couple of) containers running a jupyter environment for XX people.”

About the best we can offer right now is JupyterLite, running on a free host such as GitHub/GitLab Pages or ReadTheDocs (my personal preference)… but try as we might, there are still a lot of pointy edges.

1 Like

I don’t know the answer to that. The point #1 here was asking along the lines of that but I don’t see an answer or solution.

1 Like