-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonny Browning
committed
Jul 27, 2023
1 parent
5abfa36
commit 15b4c98
Showing
15 changed files
with
1,065 additions
and
295 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
File renamed without changes.
Large diffs are not rendered by default.
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,5 +1,5 @@ | ||
[tool.poetry] | ||
name = "training" | ||
name = "model" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Your Name <[email protected]>"] | ||
|
@@ -12,6 +12,11 @@ xgboost = "^1.7.6" | |
pandas = "^2.0.3" | ||
|
||
|
||
[tool.poetry.group.serving.dependencies] | ||
fastapi = {extras = ["uvicorn"], version = "^0.100.0"} | ||
uvicorn = "^0.23.1" | ||
google-cloud-storage = "^2.10.0" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
File renamed without changes.
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,10 @@ | ||
FROM python:3.9.16-slim | ||
ENV PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
PIP_DEFAULT_TIMEOUT=100 | ||
|
||
COPY requirements.txt requirements.txt | ||
RUN pip install -r requirements.txt | ||
COPY main.py main.py | ||
|
||
CMD exec uvicorn main:app --host "0.0.0.0" --port "$AIP_HTTP_PORT" |
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,29 @@ | ||
import joblib | ||
import os | ||
|
||
import pandas as pd | ||
from fastapi import FastAPI, Request | ||
from google.cloud import storage | ||
|
||
app = FastAPI() | ||
client = storage.Client() | ||
|
||
with open("model.joblib", "wb") as f: | ||
client.download_blob_to_file(f"{os.environ['AIP_STORAGE_URI']}/model.joblib", f) | ||
_model = joblib.load("model.joblib") | ||
|
||
|
||
@app.get(os.environ.get("AIP_HEALTH_ROUTE", "/healthz")) | ||
def health(): | ||
return {} | ||
|
||
|
||
@app.post(os.environ.get("AIP_PREDICT_ROUTE", "/predict")) | ||
async def predict(request: Request): | ||
body = await request.json() | ||
|
||
instances = body["instances"] | ||
inputs_df = pd.DataFrame(instances) | ||
outputs = _model.predict(inputs_df).tolist() | ||
|
||
return {"predictions": outputs} |
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,2 @@ | ||
.venv | ||
.DS_Store |
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
File renamed without changes.
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
Oops, something went wrong.