Using Julia in Binder: interactive web environment for running your code


#1

Today I’ve been introduced to Binder. I found a few references to this tool on Discourse but not a topic on its own devoted to Binder, so I thought that it could be useful for some people to explain what it is and how to use Julia with it.

Introduction

Binder is a website where you can run an interactive environment (basically a Jupyter server) created out of a repository. Under the hood, it creates for you a Docker image of your repository that you can use remotely. This is meant to be as a tool to deliver reproducible research.

HOWTO

Binder workflow

You only need to create a repository (e.g., on GitHub, but probably any other public source hosting website should work) with your code. The REQUIRE lets Binder know that you want to use Julia. I’m not sure what exactly is the syntax expected by Binder, for example it doesn’t seem to need a julia line (I tried to use it but it failed to create the environment, not sure this was the problem but didn’t try again because it’d have taken too long).

Once you create a repository with your code, go to https://mybinder.org/, insert the information about your repository and click on the “launch” button. And wait. That’s all.

Very simple example

I’ve created an almost useless example here: https://github.com/giordano/my-first-binder/tree/julia. The Binder is at https://mybinder.org/v2/gh/giordano/my-first-binder/julia A Jupyter server will be opened. From there, you can either open a terminal where to run the code (well, the hello.jl does very little) or create a new notebook.

Personal comments

First of all, following the current documentation (2019-03-12) I was able to run only Julia v0.6.4 with Binder. I see that support for Julia v1+ is coming, hopefully quite soon. This should include also support for the new Project.toml and Manifest.toml files. Probably there is already something in place but the documentation needs to be updated?

One of the main goals of Binder is to create a fixed environment where to run your code in a reproducible way. This is achieved by enforcing the use of REQUIRE file for Julia or the requirements.txt file for Python. Julia v1 already does a great job at creating fixed environments with the use of the TOML files which are truly part of code loading, contrary to, e.g., requirements.txt for Python. However, the nice feature of Binder is to provide an interactive environment where to run the code remotely.

Note that this service comes free of charge, so do expect occasionally long waiting times, especially when creating for the first time an image for a given revision of you repository, this operation can take several minutes (more than 10). Open the log when loading a Binder environment, at least you can see what’s happening.

Despite some annoying issues with slow creation of the image, Binder looks like a great option for sharing your code with other people and let them play with it, even without having to install Julia themselves. With full Julia v1 support this can be a great resource for doing reproducible research.

Further reading

You can find Binder documentation at https://mybinder.readthedocs.io/en/latest/. Several examples of Binder repository are at https://github.com/binder-examples


#2

There are a few tools like this now. I am tempted to test all of them out and write up something. But I got hands full for the next year or so. But the others I found interesting are

  • Kaggle kernel
  • Google colab
  • Nextjournal
  • repl.it
  • binder
  • juliabox.com

#3

Does anyone know if the binder architecture might support a custom system build (a la https://github.com/JuliaLang/PackageCompiler.jl)?


#4

@NHDaly, the incredibly awesome jupyter binder team and I recently got the whole julia 1.0 story pretty much figured out and merged for binder (https://github.com/jupyter/repo2docker/pull/595). There are still a few minor things we are ironing out right now (mostly waiting for https://github.com/JuliaLang/IJulia.jl/pull/820 to merge so that we can adopt that model for binder as well), and then we were going to deploy it on the public binder infrastructure and I was going to make a big announcement :slight_smile:

I think I would actually recommend that folks don’t adopt binder at this stage using REQUIRE files, but instead just wait a few more days/weeks until we have the proper Project.toml/Manifest.toml story deployed. That will be much more robust, in particular when it comes to reproducability.

Docs for the new Project.toml support are all written, but I think they will only deploy when the software is also deployed to the public binder infrastructure.

https://github.com/jupyter/repo2docker/issues/601. I don’t see any reason why this shouldn’t work, assuming that PackageCompiler.jl is stable enough.


#5

Hooray for Project.toml! Hooray for reproducability! Hooray for free notebook hosting!

And hooray for your imminent announcment!! :smile: Thanks again for all your awesome work on that @davidanthoff! I think it’ll be really useful!

Thanks also to @kristoffer.carlsson for reviewing a lot of the julia 1.0 stuff in the binder PRs.


#6

Yeah, I saw great activity in the repo2docker repository about support for Julia, thank you so much! I’m happy to see that Julia v1 is landing on Binder.