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.
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.