This repository contains the code for the room-match API project. In this guide, you will learn how to set up and run the API using Docker locally, as well as how to test it using the api_request-payload.py
script.
room-match/
│
├── main.py
├── api-request-payload.py
├── requirements.txt
├── dockerfile
├── Cupid_API.postman_collection.json
├── model-creation.ipynb
├── room_match_model.pkl
├── tests/
│ ├── __init__.py
│ ├── test_unit.py
│ ├── test_integration.py
│ └── test_api.py
├── ex-nuitee
└── README.md
main.py
: The main Python script of the project.api-request-payload.py
: Script for sending a request to the API.requirements.txt
: Contains the project dependencies.Dockerfile
: The Docker configuration file to containerize the application.Cupid_API.postman_collection.json
: Postman collection with all the endpoints and expected formats.model-creation.ipnynb
: is a code sample of some key functions for features generation, model training, end so on. It's just ilustrative. Note that the API itself has been hardcoded to emulate the Cupid API.room_match_model.pkl
: is the suposed trained model.tests/
: Directory containing unit and integration tests.__init__.py
: Marks the directory as a package.test_unit.py
: Unit tests for individual components.test_integration.py
: Tests for the integration of various components.test_api.py
: Tests specifically for the API.
ex-nuitee
: virtual environmentREADME.md
: This file, which provides instructions for the project.
Before proceeding, ensure you have the following installed:
- Docker
- Git
- Python 3.x (for running the test script)
To copy the code from the GitHub repository to your local machine:
-
Open your terminal or command prompt.
-
Navigate to the directory where you want to clone the repository.
-
Run the following command to clone the repository:
git clone https://github.com/magic-gon/room-match.git
-
Navigate into the cloned repository directory:
cd room-match
Next, you'll need to build the Docker image for the API.
-
Make sure you're in the root directory of the cloned repository.
-
Open Docker Desktop.
-
Build the Docker image by running the following command:
docker build -t api-image .
This command will read the Dockerfile in the repository and build an image named api-image.
Once the image is built, run the API inside a Docker container.
-
Run the following command to start the container:
docker run -p 5000:5000 api-image
This will start the API on port 5000 inside the Docker container and map it to port 5000 on your local machine.
- The API will now be accessible at http://localhost:5000.
To test the API, you can use the api_request-payload.py script provided in the repository.
-
Open a new terminal window or tab and navigate to the cloned repository directory.
-
Run the following command to execute the script:
python api_request-payload.py
Once you're done testing, you can stop the Docker container and clean up:
-
To stop the running container, use the following command:
docker stop <container_id>
-
To remove the container (optional), run:
docker rm <container_id>
-
To remove the image (optional), run:
docker rmi api-image