Building Data Science Applications with FastAPI
eBook - ePub

Building Data Science Applications with FastAPI

Francois Voron

Buch teilen
  1. 426 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Building Data Science Applications with FastAPI

Francois Voron

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Get well-versed with FastAPI features and best practices for testing, monitoring, and deployment to run high-quality and robust data science applicationsKey Features• Cover the concepts of the FastAPI framework, including aspects relating to asynchronous programming, type hinting, and dependency injection• Develop efficient RESTful APIs for data science with modern Python• Build, test, and deploy high performing data science and machine learning systems with FastAPIBook DescriptionFastAPI is a web framework for building APIs with Python 3.6 and its later versions based on standard Python-type hints. With this book, you'll be able to create fast and reliable data science API backends using practical examples.This book starts with the basics of the FastAPI framework and associated modern Python programming language concepts. You'll be taken through all the aspects of the framework, including its powerful dependency injection system and how you can use it to communicate with databases, implement authentication and integrate machine learning models. Later, you'll cover best practices relating to testing and deployment to run a high-quality and robust application. You'll also be introduced to the extensive ecosystem of Python data science packages. As you progress, you'll learn how to build data science applications in Python using FastAPI. The book also demonstrates how to develop fast and efficient machine learning prediction backends and test them to achieve the best performance. Finally, you'll see how to implement a real-time face detection system using WebSockets and a web browser as a client.By the end of this FastAPI book, you'll have not only learned how to implement Python in data science projects but also how to maintain and design them to meet high programming standards with the help of FastAPI.What you will learn• Explore the basics of modern Python and async I/O programming• Get to grips with basic and advanced concepts of the FastAPI framework• Implement a FastAPI dependency to efficiently run a machine learning model• Integrate a simple face detection algorithm in a FastAPI backend• Integrate common Python data science libraries in a web backend• Deploy a performant and reliable web backend for a data science applicationWho this book is forThis Python data science book is for data scientists and software developers interested in gaining knowledge of FastAPI and its ecosystem to build data science applications. Basic knowledge of data science and machine learning concepts and how to apply them in Python is recommended.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Building Data Science Applications with FastAPI als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Building Data Science Applications with FastAPI von Francois Voron im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Computer Science & Web Services & APIs. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2021
ISBN
9781801074186

Section 1: Introduction to Python and FastAPI

After setting up the development environment, we’ll introduce the specificities of Python before starting to explore the basic features of FastAPI and running our first REST API.
This section comprises the following chapters:
  • Chapter 1, Python Development Environment Setup
  • Chapter 2, Python Programming Specificities
  • Chapter 3, Developing a RESTful API with FastAPI
  • Chapter 4, Managing pydantic Data Models in FastAPI
  • Chapter 5, Dependency Injections in FastAPI

Chapter 1: Python Development Environment Setup

Before we can get started on our FastAPI journey, we need to configure a clean and efficient Python environment. This chapter will show you the best practices and conventions that Python developers use daily to run their projects.
By the end of this chapter, you'll be able to run Python projects and install third-party dependencies in a contained environment that won't raise conflicts if you happen to work on another project that uses different versions of the Python language or different dependencies.
In this chapter, we're going to cover the following main topics:
  • Installing a Python distribution using pyenv
  • Creating a Python virtual environment
  • Installing Python packages with pip
  • Installing the HTTPie command-line utility

Technical requirements

Throughout this book, we'll assume you have access to a Unix-based environment, such as a Linux distribution or macOS.
If they haven't done so already, macOS users should install the Homebrew package (https://brew.sh), which helps a lot in installing command-line tools.
If you are a Windows user, you should enable Windows Subsystem for Linux (https://docs.microsoft.com/windows/wsl/install-win10), WSL, and install a Linux distribution (such as Ubuntu) that will run alongside the Windows environment, which should give you access to all the required tools. There are currently two versions of WSL, WSL and WSL2. Depending on your Windows version, you might not be able to install the newest version. However, we do recommend using WSL2 if your Windows installation supports it.

Installing a Python distribution using pyenv

Python is already bundled with most Unix environments. To ensure this is the case, you can run this command in a command line to show the version of the currently installed Python:
$ python3 --version
The output version displayed will vary depending on your system. You may think that this is enough to get started, but it poses an important issue: you can't choose the Python version for your project. Each Python version introduces new features and breaking changes. Thus, it's important to be able to switch to a recent version for new projects to take advantage of the new features but still be able to run older projects that may not be compatible. This is why we need pyenv.
pyenv (https://github.com/pyenv/pyenv) is a tool that helps you manage and switch between multiple Python versions on your system. It allows you to set a default Python version for your whole system but also per project.
Beforehand, you need to install several build dependencies on your system to allow pyenv to compile Python on your system. The official documentation provides clear guidance on this (https://github.com/pyenv/pyenv/wiki#suggested-build-environment), but here are the commands you should run:
  1. Install the build dependencies:
    • macOS users, use this:
      $ brew install openssl readline sqlite3 xz zlib
    • Ubuntu users, use this:
      $ sudo apt-get update; sudo apt-get install --no-install-recommends make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
      Package managers
      Brew and APT are what are commonly known as package managers. Their role is to automate the installation and management of software on your system. Thus, you don't have to worry about where to download them and how to install and uninstall them. The commands just tell the package manager to update its internal package index and then install the list of required packages.
  2. Install pyenv:
    $ curl https://pyenv.run | bash
    Tip
    If you are a macOS user, you can also install it with Homebrew: brew install pyenv.
  3. This will download and execute an installation script that will handle everything for you. At the end, it'll prompt you with some instructions to add some lines to your shell scripts so that pyenv is discovered properly by your shell:
    a. Open your ~/.profile script in nano, a simple command-line text edito...

Inhaltsverzeichnis