Open discussions on specific topics selected by the Software Working Group and selected from the list of SWG Topics For Discussion.

Round Table Discussion Flask & FAST API, moderated by Yong Wook Kim

Python is a widely used language and popular for deep learning, scripting, or API development. Flask and FastAPI are python web development frameworks that are used for developing websites and applications. They are the collection of modules, libraries, classes, and functions that help web app developers write applications. In this round table discussion, we would like to compare these two applications, so we can help people to apply a more suitable one based on the case or situation.






Recording: 

Slides:


Attendees:

Yong Wook KIm

Jong Lee

Luigi Marini

Max Burnette

Rob Kooper

Marcos Frenkel

Wendy Shan

Chen Wang

Sara Lambert

Rebecca Eveland

Jeff Terstreip

Visu Monaharajan

Michael Shapiro

Minu Mathew

Mike Bobak

Jonathan Kim

Galen Arnold

Sandeep Puthanveetil Satheesan

Ya-Lan Yang

Chris Navarro

Rashmil Panchani

Bing Zhang

Lisa Yanello



Discussion:

  • Max notes that he's used Flask and Fast API. There are a lot of plug ins for Flask, and it requires a lot of manual work.  In Django and Fast API use their out of the box models.  Fast API is being used in Clowder, but there were some configurations that needed to be made.  Once it is all set up, it seems to work very well.
  • Pydantic required you to use Fast API and requires Starlet, using Python iSync.  Flask has this support now, but it was an add on, not built from the ground up.
  • ONe of the reasons we picked Fast API is because Django did not allow Mongo to be used. We wanted to use Django because it supported GIS.
  • Look at what data you will be using and what dependencies you will need. If the dependency does not support the next upgrade of Python, you have to re-write.
  • Kastan notes The Clowder team was and is concerned that FastAPI is maintained by a single person: https://github.com/tiangolo… and he’s been tweeting about job listings recently.
    I’ve been using Railway for simple free hosting of Flask https://railway.app/. It’s like the ⭐Vercel⭐ of the Python world.  Clowder2 stack as discussed here: 
    https://github.com/tiangolo/fastapi
    https://docs.pydantic.dev/latest/
    https://github.com/roman-right/beanie
    https://www.starlette.io/
  • There is a plug in for Python for Flask.  Flask has a good plug in architecture.
  • Sara notes Another possible option alternative, Workbench V2 uses Connexion: https://connexion.readthedocs.io/en/latest/ :).  They assume you have a swagger spec but it will create one for you.
  • If you're building a new application, Fast API is nice because it generates from your code. 
  • You need to know exactly how and what you want to do before choosing Flask, Connexion, Fast API, etc.
  • Mike Bobak notes https://www.turing.com/kb/fastapi-vs-flask-a-detailed-comparison

Performance Based on Experience

Scalability

  • Technical discussion re: Mongo and Montor.
  • Scalability can cause issues when files are too large. Is the library a bottleneck? In IN-CORE .io is the bottleneck.
  • The bottlenecks are not caused by Flask or Fast API.

Third Party Extensions Integration and Ecosystem

  • Flask has a larger number of third party extensions and has a mature ecosystem
  • Fast API is relatively newer, but is gaining popularity.
  • Sandeep did some performance runs and felt the backend worked will with Flask for Rokwire, but most of the language is in Go.

Asynchronous Programming

  • FastAPI is built on top of Starlette, and an asynchronous web framwork
  • Flask is not asynchronous by default but can be integrated.

Type Hints and Static Typings

Starlette has useful features and support. You can create manipulations to do certain tasks in a specific order

So which one should we use?  It's a use case decision.  Both have strengths and weaknesses.

a


Functions


Comments




Links mentioned in this Round Table:


Best Practices Handbook: https://github.com/ncsa/software-development-handbook





If you are interested in contributing to a Round Table, please see these links:

Round Table Google Sheet: https://docs.google.com/spreadsheets/d/1kbgO6sIb_4eLugfSVKQNCTXdaKp1R6m0RDczPTsUAoQ/edit#gid=0  Every one should have edit permission.

Round Table Discussions

SWG Topics For Discussion




  • No labels