-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.1.0 release
- Loading branch information
Showing
148 changed files
with
546 additions
and
5,018 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Building, running, and pushing image | ||
``` | ||
# From root folder of repository: | ||
docker build -t <model_name> -f demo_api/<model_name>/Dockerfile demo_api/ | ||
docker run -p 8000:8000 <model_name> | ||
E.g. | ||
docker build -t lsr -f demo_api/lsr/Dockerfile demo_api/ | ||
docker run -p 8000:8000 lsr | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import logging | ||
import json | ||
from flask import Flask, jsonify, make_response | ||
|
||
|
||
def create_api(app_name, model_card_path, model_usage_path="usage.py"): | ||
app = Flask(app_name) | ||
|
||
# setup gunicorn logging | ||
gunicorn_logger = logging.getLogger('gunicorn.error') | ||
app.logger.handlers = gunicorn_logger.handlers | ||
app.logger.setLevel(gunicorn_logger.level) | ||
|
||
# Common routes | ||
@app.route("/model-card", methods=["GET"]) | ||
def get_model_card(): | ||
"""GET method for model card | ||
Returns: | ||
json: model card in json format | ||
""" | ||
with open(model_card_path) as f: | ||
model_card = json.load(f) | ||
return jsonify(**model_card) | ||
|
||
@app.route("/model-usage", methods=["GET"]) | ||
def get_model_usage(): | ||
try: | ||
with open(model_usage_path) as f: | ||
model_usage = f.read() | ||
return jsonify(usage=model_usage) | ||
except FileNotFoundError: | ||
return make_response("Model usage not available.", 404) | ||
|
||
# Kubernetes health check endpoint | ||
@app.route("/healthz", methods=["GET"]) | ||
def healthz(): | ||
return make_response(jsonify({"healthy": True}), 200) | ||
|
||
return app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
FROM python:3.8-buster | ||
|
||
COPY . /emotion_entailment | ||
COPY . /demo_api | ||
|
||
WORKDIR /emotion_entailment | ||
WORKDIR /demo_api/emotion_entailment | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
RUN python -m download_pretrained | ||
|
||
CMD gunicorn --bind 0.0.0.0:8000 wsgi:app --timeout 180 | ||
CMD PYTHONPATH=../../ gunicorn -c ../gunicorn.conf.py |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ transformers==4.4.2 | |
tokenizers==0.10.1 | ||
flask | ||
gunicorn | ||
sgnlp==0.0.1 | ||
sgnlp==0.1.0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
bind = "0.0.0.0:8000" | ||
wsgi_app = "api:app" | ||
timeout = 180 | ||
workers = 4 | ||
preload_app = True | ||
raw_env = ["PYTHONPATH=../../", "TOKENIZERS_PARALLELISM=false"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
FROM python:3.8-buster | ||
|
||
COPY . /lif_3way_ap/ | ||
COPY . /demo_api | ||
|
||
WORKDIR /lif_3way_ap | ||
WORKDIR /demo_api/lif_3way_ap | ||
|
||
RUN pip install -r requirements.txt | ||
RUN python -m spacy download en_core_web_sm | ||
RUN python -m download_pretrained | ||
|
||
CMD gunicorn --bind 0.0.0.0:8000 wsgi:app --timeout 180 | ||
CMD PYTHONPATH=../../ gunicorn -c ../gunicorn.conf.py |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
FROM python:3.8-buster | ||
|
||
COPY . /lsr/ | ||
COPY . /demo_api | ||
|
||
WORKDIR /lsr | ||
WORKDIR /demo_api/lsr | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
RUN python -m download_pretrained | ||
|
||
CMD gunicorn --bind 0.0.0.0:8000 wsgi:app --timeout 180 | ||
CMD PYTHONPATH=../../ gunicorn -c ../gunicorn.conf.py |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ transformers | |
textdistance==4.2.1 | ||
flask | ||
gunicorn | ||
sgnlp==0.0.1 | ||
sgnlp==0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.