Hirata @JesseTetsuya ———————————————————————————————————————————————————————————————————————————————— Software Engineer at an EdTech company based in Tokyo. I mostly work in both data science and engineering. PyCon 2021 talk at !
and FastAPI for REST API development 1. Variety of functions and extensions 2. Performance(Speed and Stability) 3. Flexibility of REST API Architecture 4. Learning Cost @JesseTetsuya
May 2021 - Nested Blueprint - Async/Await - Type Hinting - 15x speed up of multipart/form-body - Routing shortcut - etc. @JesseTetsuya 'MBTLSFMFTFOPUFIUUQTqBTLQBMMFUTQSPKFDUTDPNFOYDIBOHFT
type annotations. -> Pydantic have good match with data class, type hint, mypy, and OpenAPI. OpenAPI: - Swagger Editor - API document editor which has preview function - Swagger UI - Browsing the api documentation based on schemas written on yaml or json - OpenAPI Generator - Generate automatically the client server stub code based on the yaml or json -> Sphinx and JSON schema is recommended, specially in AI/ML projects. Request/Application Context: - Request context keeps track of the request-level data (URL, HTTP method, headers, request data, session info) and allows us to access them by using proxies such as request and session. - Application context keeps track of the application-level data (configuration variables, logger, database connection) allows us to access them by using proxies such as current_app and g. -> Next Slide @JesseTetsuya 1. Variety of functions and extensions
implemented by werkzeug.local.LocalStack "QQMJDBUJPO$POUFYU 4UBDL XFSL[FVHMPDBM-PDBM4UBDL 3FRVFTU $POUFYU4UBDL XFSL[FVHMPDBM-PDBM4UBDL (MPCBM $SFBUFUISFBET UISFBE@ DPOUFYU VOJRVFBDDFTT YYYQZ UISFBE@ DPOUFYU VOJRVFBDDFTT UISFBE@ DPOUFYU VOJRVFBDDFTT "DDFTTEBUB $POUFYU-PDBMT ʜ ʜ GSPNXFSL[FVHMPDBMJNQPSU-PDBM1SPYZ GSPNXFSL[FVHMPDBMJNQPSU-PDBM4UBDL ʜ ʜ ʜ DPOUFYUMPDBMT @SFRVFTU@DUY@TUBDL-PDBM4UBDL @BQQ@DUY@TUBDL-PDBM4UBDL DVSSFOU@BQQ'MBTL-PDBM1SPYZ @pOE@BQQ UZQFJHOPSF SFRVFTU3FRVFTU-PDBM1SPYZ QBSUJBM @MPPLVQ@SFR@PCKFDU SFRVFTU UZQFJHOPSF TFTTJPO4FTTJPO.JYJO-PDBM1SPYZ UZQFJHOPSF QBSUJBM @MPPLVQ@SFR@PCKFDU TFTTJPO H@"QQ$UY(MPCBMT-PDBM1SPYZ QBSUJBM @MPPLVQ@BQQ@PCKFDU H UZQFJHOPSF qBTLTSDqBTLHMPCBMQZ - The right picture means that a unique werkzeug.local.LocalStack object has multiple unique threads - The data need to be stored in a way that only one worker(thread) can retrieve back, which means the data get back their own specific data that’s unique to each worker(thread).
%VSBUJPO<UPUBM BUUBDL XBJU>T T T -BUFODJFT<NJO NFBO NBY>NT T T T T T T #ZUFT*O<UPUBM NFBO> #ZUFT0VU<UPUBM NFBO> 4VDDFTT<SBUJP> 4UBUVT$PEFT<DPEFDPVOU> &SSPS4FU 3FRVFTUT<UPUBM SBUF UISPVHIQVU> %VSBUJPO<UPUBM BUUBDL XBJU>T T NT -BUFODJFT<NJO NFBO NBY>NT NT NT NT NT NT NT #ZUFT*O<UPUBM NFBO> #ZUFT0VU<UPUBM NFBO> 4VDDFTT<SBUJP> 4UBUVT$PEFT<DPEFDPVOU> &SSPS4FU @JesseTetsuya 2. Performance(Speed and Stability)
%VSBUJPO<UPUBM BUUBDL XBJU>T T T -BUFODJFT<NJO NFBO NBY>NT T T T T T T #ZUFT*O<UPUBM NFBO> #ZUFT0VU<UPUBM NFBO> 4VDDFTT<SBUJP> 4UBUVT$PEFT<DPEFDPVOU> &SSPS4FU 3FRVFTUT<UPUBM SBUF UISPVHIQVU> %VSBUJPO<UPUBM BUUBDL XBJU>T T NT -BUFODJFT<NJO NFBO NBY>NT NT NT NT NT NT NT #ZUFT*O<UPUBM NFBO> #ZUFT0VU<UPUBM NFBO> 4VDDFTT<SBUJP> 4UBUVT$PEFT<DPEFDPVOU> &SSPS4FU @JesseTetsuya 2. Performance(Speed and Stability)
not know and categorize the type of knowledge: Capture the whole picture by reviewing movies, personally recommend python conference archives. 2. Acquire Declarative Knowledge: Google ambiguous terms, link word with meaning, and make relations between a term and a term. Indexes in this previous slides can be useful. 3. Acquire Procedural Knowledge: Focus on writing the code and develop a small application based on tutorial materials or primers.
experience 1. Miguel Grinberg Asynchronous Python for the Complete Beginner PyCon 2017 (https://youtu.be/iG6fr81xHKA) 2. An introduction to ASGI, Asynchronous Server Gateway Interface - Philip Jones - PyLondinium19(https://youtu.be/t3gCK9QqXWU) 3. asyncio — Asynchronous I/O (https://docs.python.org/3/library/ asyncio.html)
experience 1. Modern Python through FastAPI and friends. Sebastián Ramírez. (https://youtu.be/37CcB2GBdlY) 2. Tutorial - User Guide - Intro (https://fastapi.tiangolo.com/tutorial/#tutorial-user-guide-intro) 3. Talks # 8: Sebastián Ramírez; Build a machine learning API from scratch with FastAPI (https://youtu.be/1zMQBe0l1bM)
experience 1. Armin Ronacher, "Flask for Fun and Profit", PyBay2016 (https://youtu.be/1ByQhAM5c1I) 2. CS50 2020 - Lecture 9 - Flask, Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. (https://www.youtube.com/watch?v=x_c8pTW8ZUc) 3. Tutorial: (https://flask.palletsprojects.com/en/2.0.x/tutorial/index.html)
There are still many unknown practices of architecture patterns including anti-patterns. The amount of experiences and practices can influence framework selection. - Japanese books of Flask and FastAPI are very rare for us to find them in bookstore. This influences the number of learners and the community size.
company based in Tokyo. I mostly work in both data science and engineering. If you have an interest in the EdTech domain or in what our team is doing, reach out to me !!