• Classes
  • 07 - Lambda Functions
  • Part 3

APS 03

In this assignment, we are going to create a new version of the work from the API class.

Accept assignment

All assignments delivery will be made using Git repositories. Access the link below to accept the invitation and start working on the third assignment.

Invitation link

Clone repository

Clone your private repository:

Question 1

Create a .gitignore and make sure the .env is in it!

Start working!

Our goal is to transform the predict route from class 02 into a lambda function. In other words, assume the model is already trained and that the model pickle can be embedded in the Docker image.

Important!

Realize that we will no longer be using FastAPI. We will create a lambda function that has a handler for predict, then we will create an API Gateway that exposes the lambda function.

Question 2

Create the .py file with the function handler.

Question 3

Create the requirements.txt file with the dependencies.

Question 4

Create the Dockerfile

Tip! 1

In order to install lightgbm, you will need to install some dependencies on the system. So, before RUN pip install -r requirements.txt you can add:

# Install system dependencies
RUN yum install -y libstdc++ cmake gcc-c++ && \
    yum clean all && \
    rm -rf /var/cache/yum

# Install the specified packages
RUN pip install -r requirements.txt

Question 5

Create the Docker image

Question 6

Test the Docker image locally

Question 7

Create a new repository aps03_<INSPER_USERNAME> in ECR

Question 8

Tag and push your image to the ECR repository

Question 9

Create a lambda function associated with your image

Question 10

Test the lambda function

Question 11

Create an API Gateway and test it.

Leave in the README an example of how to test your API Gateway (curl command or Python code).

Question 12

Commit and push: mission accomplished!