Options for Building Python Web Apps

Tags: , , ,

By: Gordon Fleetwood – ODSC data science team contributor

One of the ways that R’s ecosystem outperforms Python’s with regard to Data Science is the existence of Shiny. It is the premier platform for data-driven web apps in the field. Shiny is already mature and is evolving steadily as seen at the recent inaugural iteration of the Shiny Developers Conference. One speaker at the event was Joe Cheng, CTO of RStudio, the company behind Shiny. He will also be speaking at ODSC East at the end of May. In the Python sphere, there is no Shiny equivalent. Instead, users have to leverage other frameworks and integrate aspect of data analysis into them.

The most preferred option is to use one of Python’s web frameworks. Django and Flask are the most popular options. The latter is generally preferred due to its lightweight nature, modularity, and ease of use. On the other hand, Django requires a lot of boilerplate material to construct even simple apps, and the underlying components are not as customizable as with Flask.

Using established web frameworks is a consequence of Python’s origins as a general purpose language rather than one built for data analysis. As Python has become an entrenched part of Data Science, there have been attempts to construct a Python equivalent to Shiny. One of these is Adam Hajari’s spyre, built on top of the Python web framework cherrypy. The influence of Shiny is obvious in spyre’s structure, where the use of input and outputs ids to control the flow of objects from the backend to the front end was replicated. Mr. Hajari’s work has gained enough attention that he has spoken about it at conferences, but the library hasn’t been adopted by the Python community.

The other high profile attempt to build Shiny for Python is pyxley, a framework developed by the team at Stitch Fix. It is built on top of Flask and uses PyReact to leverage the power that Javascript has to offer through React.js. Its interface is noticeably different from spyre and there are a number of Javascript dependencies. Like spyre, however, it has so far failed to make many waves in the Python community.

Another option which is very much in the early stage of development is Jupyter notebook extensions. Both the declarative widgets and dashboards extensions allow for a web app or dashboard to be constructed inside a Jupyter notebook, downloaded, and then deployed. The examples provided are quite exciting, and being attached to the ubiquitous Jupyter notebook means that it already has a huge boost when it comes to adoption by the wider community. However, a potential barrier for use is its heavy reliance on Javascript – much more so than pyxley.

As the situation stands, all Python users have at the moment are shadows of what Shiny is capable of. When or if such a platform finally arrives, it will be another monumental step for Python in its use for Data Science.