OpenFisca in Google Colab

Jason Morris
Rules as Code Diary
2 min readNov 30, 2021

I blogged recently about the opportunity to use s(CASP) inside SWISH, the web-based development environment for SWI-Prolog.

Screenshot of a Google Colab notebook implementing OpenFisca code to calculate eligibility for a benefit

Today it is another web-based development environment for Rules as Code, OpenFisca inside Google Colab.

What is OpenFisca?

OpenFisca is probably the world’s most popular open source tool for Rules as Code. It is used extensively in France, and is spreading around the world.

What is Google Colab(oratory)?

Google Colab is a web-based implementation of Jupyter notebooks — a “literate programming” tool for the Python programming language — and Google’s cloud services. A Python development environment as a (free) service.

Less Memo, More Memo

I could explain how it works, here, but nah.

Just go try it yourself.

Trust me, you won’t regret the click.

Upshot

I really like the result, because it provides a good literate programming environment to do encoding beside the text of legislation, in any approach that is implemented in Python.

It also democratizes access to OpenFisca, eliminating the need to know how to set up a development environment, or even the need for a computer on which Python can be installed. Interestingly, that makes it realistic for a wider variety of public servants to be able to explore, which in turn will make the technology more trustworthy, and more trusted.

OpenFisca is not my favourite approach for Rules as Code. Imperative programming is fundamentally limited for encoding rules, and OpenFisca’s design is focused on the quality of the outputs — high speed, high accuracy micro-simulations of the effects of legislation — not on the qualities of the inputs. But those concerns are academic, like preferring emacs to Word. OpenFisca is popular, open source, and feasible to deploy in places many of my preferred approaches are not. It also has a growing ecosystem of tools and extensions, as demonstrated at PolicyEngine.org.

Democratizing access to OpenFisca can only help the Rules as Code movement, and I am 100% here for that.

Adding Colab to the mix, in addition to democratizing access, gives OpenFisca a lot of great interface features. And with very little overhead for the developer. That means the distance between being able to encode a Law, and being able to demonstrate the usefulness of that encoding, has been reduced to nearly zero. And zero is where it should ideally be.

--

--

Jason Morris
Rules as Code Diary

Rules as Code Director at Service Canada, CEO Lexpedite.ca. Previous: Lawyer; ABA Innovation Fellow; Sessional Instructor; Computational Law Researcher