Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup a Jupyter-notebook with calysto-processing to run in Binder?

I have jupyter-notebook running on my own Mac with the caylsto-processing library plugged in so I can run processing scripts in a notebook in a browser tab. But I am trying to be able to run this all in binder, so that I can share my processing scripts with students during class. I created a Github repository and have it linked to a binder, and the binder builds and launches, but the only kernel available is python 3.

I have read that I can include a bunch of configuration files, but I'm new to these and I don't see any examples that bring in the calysto-processing kernel, so I'm unsure on how to proceed.

Screenshot of my binder with the jupyter-notebook with a processing script - but when you click on kernels, the only kernel it shows is python: Screenshot of my binder with the jupyter-notebook with a processing script - but when you click on kernels, the only kernel it shows is python

Any help would be appreciated.

like image 681
Celine Latulipe Avatar asked Jul 13 '19 17:07

Celine Latulipe


People also ask

What is calysto scheme?

Calysto Scheme is a real Scheme programming language, with full support for continuations, including call/cc. It can also use all Python libraries. Also has some extensions that make it more useful (stepper-debugger, choose/fail, stack traces), or make it better integrated with Python.

What is Jupyter Nbviewer?

What is nbviewer? nbviewer is a web application that lets you enter the URL of a Jupyter Notebook file, renders that notebook as a static HTML web page, and gives you a stable link to that page which you can share with others.

What is binder Python?

BinderHub is a web application that allows users to create sharable, interactive, reproducible environments from code repositories. It uses repo2docker to generate Docker images for each environment, and JupyterHub to provide interactive user sessions from those images.


1 Answers

Very good question. Ayman suggestion is good.

I've just installed calysto_processing and noticed 3 things are necessary:

  1. installing the calysto_processing package via pip,
  2. running install on the calysto_processing package.
  3. installing Processing.

First point should be easy with requirements.txt.

I'm unsure what the best option is for the second step (maybe a custom setup.py ?).

Step 3 feels the trickiest.

Installing Processing currently isn't supported with apt-get so Dockerfile might be way forward (even through mybinder recommend that only as a last resort).

Let's assume a Dockerfile would contain all the steps to manually download/install processing (and I'm not super experienced with Docker at the moment btw), it will need to be executed which will require a windowing system to render the Processing window. I don't know how well that plays with Docker, sounds like it's getting into virtual machine territory.

That being said, looking at the source code right here:

  1. Processing is used only to validate the sketch, and pull syntax errors to display them otherwise.
  2. ProcessingJS is used to actually render the processing code in a <canvas/> element within the Jupyter Notebook

I'm not sure what the easiest way to run the current calysto_processing in mybinder as is.

My pragmatic (even hacky if you will) suggestion is to:

  1. fork the project and remove the processing-java dependency (which means might loose error checking)
  2. install the cloned/tweaked version via pip/requirements.txt (pip can install a package from a github repo)

Update I have tried the above: you can run test kernel here

ProcessingJS in mybinder online shared Jupyter Notebook

The source is here and the module is installed from this fork which simply comments out the processing-java part.

In terms of the mybinder configuration it boils down to:

  • create a binder folder in the repo containing the notebook
  • add requirements.txt which points to the tweaked version of calysto_processing stripped off the processing-java dependency: git+https://github.com/orgicus/calysto_processing.git@hotfix/PJS-only-test
  • add postBuild file which runs install on the calysto_processing module: python -m calysto_processing install --user

Notes

  • With this workaround java error checking is gone
  • Although Processing syntax is used it's execute as javascript and rendered in <canvas/> using ProcessingJS: this means no processing-java libraries, no threads or other java specific features,(buggy or no 3D),etc. just basic Processing drawing sketches
  • It might be worth looking at replacing ProcessingJS with p5.js and checking out other JS notebooks ? (e.g. Observable or IJavascript)
like image 109
George Profenza Avatar answered Nov 10 '22 21:11

George Profenza