Google Colab as a basic front end for cadCAD models

A couple of weeks ago, the BlockScience and the Commons Stack teams were discussing alternatives for hosting the conviction voting cadCAD model in a way that would allow users to play with some of its parameters, and we came across Google Colab as possible solution.

Not only can you install cadCAD in a temp environment in Google’s servers and run a simulation, but you can also make use of its forms feature to provide users with a UI that’s quite close to what you would get by hosting your own solution.

Here’s a proof of concept I built from part 1 of the Robot and Marbles tutorial.
com-video-to-gif
Line 1: Jupyter “cell magic” to avoid the outputs of that cell being printed
Line 2: download scripts.py from github
Line 3: install cadCAD

The rest of the code is hidden behind the form (double click the form to see it) - it calls a function in scripts.py that runs the simulation and plots a chart.

I later realized you don’t even need to download a separate python file, because you can hide a large chunk of code behind the form. So if you prefer to keep all of the code in the notebook, that’s ok too. See this example.

5 Likes

This is amazing @markusbkoch!!!

Thank you!! Let’s see how the Commons Stack’s Community Project evolves… We have a call tomorrow at 1pm NYC time, 7pm Berlin time at https://meet.jit.si/Commons-dev to go over whether or not we will go the form route and which inputs and outputs we like the best for the user to play with for Conviction Voting Google Collab

I am excited to see what the crew thinks!

2 Likes