Built and tested on WSL2 Ubuntu 20.04
- Python v3.8
- Docker (Tested on WSL2)
- AWS CLI (install instructions)
- Model artifacts from the NLP repo (link here)
- Create a python virtual envionment
<project-root>$ python -m venv .venv
<project-root>$ source .venv/bin/activate
(.venv) <project-root>$ pip install -r requirements-dev.txt
- Go to
./layersand build & extract the spaCy dependency layer.
(.venv) ../layers$ docker build -t spacy-layer .
(.venv) ../layers$ docker run -d -it --name spacy spacy-layer
(.venv) ../layers$ docker cp spacy:/spacy/spacy-layer.zip .
This will copy the spacy.zip file from the container to host.
-
Ensure that the
model_artifacts.zipfrom the NLP repo is placed in the project root. -
Run
aws configureand add AWS Access, Secret Keys, and select your default region and response format (json). Learn how to create AWS Access & Secret Keys. -
From project root directory:
sam deploy --guided
After deployment, SAM will print the API endpoint URL. It accepts a query parameter q with the text as input.
GET /predict?q=<input-text-here>
Sentiment: Positive/Negative
Score: Between 0 & 1
{
"sentiment": "Positive",
"score": 0.9999545812606812
}
{
"error": "Please provide input text"
}