Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/paulescu/taxi-data-api-python

Build and deploy a REST API for taxi trip data πŸš•
https://github.com/paulescu/taxi-data-api-python

docker fastapi kubernetes python

Last synced: 3 days ago
JSON representation

Build and deploy a REST API for taxi trip data πŸš•

Awesome Lists containing this project

README

        


Real-World ML


Build and deploy a professional REST API to Kubernetes with Gimlet πŸš€





Deploy to Kubernetes with Gimlet

Click here to watch the video 🎬



#### Table of contents
* [Our goal 🎯](#our-goal)
* [How to run the API locally? πŸƒ](#how-to-run-the-api-locally)
* [How to deploy the API to Kubernetes with Gimlet? πŸš€](#how-to-deploy-the-api-to-kubernetes-with-gimlet)
* [How to monitor our API with Elasticsearch and Kibana? πŸ”Ž](#how-to-monitor-our-api-with-elasticsearch-and-kibana)
* [See it in action 🎬](#see-it-in-action)
* [Wanna learn more real-world ML? 🧠](#wanna-learn-more-real-world-ml)

## Our goal

Let’s **build** and **deploy** a production-ready REST API that can serve data on historical taxi rides in NYC.

The original data is stored in one-month parquet files [on this website](https://www.nyc.gov/site/tlc/about/tlc-trip-record-data.page), and our goal is to make it easily accessible to the WORLD through a REST API.

## How to run the API locally?

Git clone this repository, cd into the root directory of the project and then run the following commands using make.

1. Install [Python Poetry](https://python-poetry.org/docs/#installation) (if necessary)
and create an isolated virtual environmnet for development purposes.
```
$ make install
```

2. Test, build and run the dockerized REST API with
```
$ make all
```

3. Check the API is up and running locally, and that you can connect to it
```
$ make health-check-local
```

4. Send a sample request to the local API
```
$ make sample-request-local
```

Good job. The API is up and running locally. However, until you don’t deploy it to a production environment, and make it accessible to

* your clients πŸ’πŸ»β€β™€οΈ
* your colleagues πŸ‘¨πŸ»β€πŸ’Ό
* or the whole world 🌏

your real-world impact is **ZERO**.

Let me show you how to deploy this API to a production Kubernetes cluster.

> **What is Kubernetes? β˜ΈπŸ“¦**
>
> Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of your Dockerized apps
>
> It is currently the most widely used container orchestration platform in the world, and it has become the de facto standard due to its robust features, large community support, and backing from major tech companies.

## How to deploy the API to Kubernetes with Gimlet?

[Gimlet](https://gimlet.io/) is a tool that helps you quickly deploy your apps to ANY Kubernetes cluster.

- You can do it entirely from the Gimlet UI, as explained in this article.

or

- You can adjust the [gimlet manifest in this repository](https://github.com/Paulescu/taxi-data-api-python/blob/main/.gimlet/electric-paper-taxi-data-api-python.yaml), to automatically deploy your code changes to the main branch.

## How to monitor our API with Elasticsearch and Kibana?

These are the steps:

1. Spin up Elasticsearch and Kibana with the docker compose
2. Add middleware to FastAPI app
3. Build a dashboard with Kibana

## See it in action

[πŸ‘‰πŸ½ Click here to try the API](https://paulescu-taxi-data-api-python-ayolbhnl.gimlet.app/trips?from_ms=1674561817000&n_results=100)

## Wanna learn more real-world ML?

Join more than 19k builders to the [**Real-World ML Newsletter**](https://www.realworldml.net/subscribe). Every Saturday morning.

### [πŸ‘‰πŸ½ Click here to subscribe for FREE](https://www.realworldml.net/subscribe)

### [**πŸ‘‰πŸ½ My live courses on Real World ML**](https://www.realworldml.net/courses)