Skip to content

sigma21/PredictingFlightDelays

PredictingFlightDelays

Instructions and Setup Guide

Containerize the application using Docker

  1. Build the Docker Image
$ docker build  -t fastapi-ml .
  1. Start the container:
$ docker run -p 80:80 fastapi-ml
  1. Test the Docker container with an example request:
  • Option 1: Using the web browser.

    Visit http://0.0.0.0:80/docs. You will see a /predict endpoint:

You can click on "Try it now" which will let you modify the input request. Click on "Execute" to see the model prediction response from the web server.

  • Option 2: Using the command line:
$ curl -X 'POST' \
'http://0.0.0.0/predict' \
-H 'Content-Type: application/json' \
-d '{
    "DepartureDateTime": "12/12/2022 15:15:15",
    "Origin":"JFK",
    "Destination":"ATL"
    }'

Local testing & examining logs

  1. Find out the container id of the running container:
$ docker ps

This will return a response like the following:

CONTAINER ID   IMAGE                COMMAND                  CREATED         STATUS         PORTS                NAMES
f9b59902e94f   fastapi-ml   "uvicorn main:app --…"   10 minutes ago   Up 10 minutes   0.0.0.0:80->80/tcp   brave_liskov
  1. SSH into the container using the container id from above:
$ docker exec -it <container id> /bin/sh
  1. Tail the logs:
$ tail -f ../data/logs.out
  1. Now when you send any request to the web server (from the browser, or another tab in the command line), you can see the log output coming through in logs. Test the web server with these requests and make sure you can see the outputs in logs:
{
    "DepartureDateTime": "24/12/2023 19:15:00",
    "Origin":"JFK",
    "Destination":"ATL"
}
{
    "DepartureDateTime": "01/01/2023 15:15:00",
    "Origin":"DTW",
    "Destination":"JFK"
}
{
    "DepartureDateTime": "04/07/2022 09:15:00",
    "Origin":"SEA",
    "Destination":"ATL"
}
{
    "DepartureDateTime": "12/12/2022 22:30:00",
    "Origin":"DTW",
    "Destination":"MSP"
}

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors