-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added model deployment docker template, fixed typos.
- Loading branch information
Showing
7 changed files
with
69 additions
and
11 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 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,13 @@ | ||
# Use an official Python runtime as a parent image | ||
FROM python:3.10 | ||
|
||
WORKDIR /app | ||
|
||
# Install any needed packages specified in requirements.txt, append your dependencies to requirements.txt | ||
RUN pip install requirements.txt | ||
|
||
ADD . /app | ||
EXPOSE 8000 | ||
|
||
# Run api-endpoint.py with uvicorn when the container launches | ||
CMD ["uvicorn", "api-endpoint:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4", "--limit-concurrency", "8000", "--log-level", "error", "--backlog", "8000"] |
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,35 @@ | ||
from typing import List | ||
from fastapi import FastAPI | ||
import os | ||
import mlflow | ||
|
||
# Add your own imports and functions here | ||
|
||
app = FastAPI() | ||
|
||
# SEMR's model store endpoint, CHANGE THIS TO YOUR OWN IP | ||
os.environ['MLFLOW_TRACKING_URI'] = 'http://<SEMR_IP>:31007' | ||
|
||
# Read the model version from the os variable (Defined in the helm charts) | ||
model_version = os.getenv('MODEL_VERSION', "latest") | ||
|
||
# Modify the model_uri to point to the correct model name | ||
model_uri = f"models:/<model_name>/{model_version}" | ||
|
||
# Modify the MLflow loading function https://mlflow.org/docs/2.10.2/index.html | ||
model = mlflow.pytorch.load_model(model_uri) | ||
model.eval() | ||
print("Model loaded!") | ||
|
||
@app.post("/") | ||
async def echo(data: List[List[List[float]]]): | ||
# Data transformations | ||
# tensor_data = torch.tensor(data) | ||
# tensor_data = tensor_data.unsqueeze(0) | ||
|
||
# Inference | ||
# cnn_labels_array = cnn_predict(tensor_data, model) | ||
# counts = Counter(cnn_labels_array) | ||
|
||
return {"prediction": str(counts)} | ||
|
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 @@ | ||
# Requirements by model deplyoment template | ||
fastapi | ||
uvicorn | ||
python-multipart | ||
mlflow==2.10.2 | ||
|
||
# Add your own dependencies for model inference and data preprocessing | ||
# numpy | ||
# torch | ||
# torch_geometric | ||
# torchvision |
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,7 @@ | ||
# Start from the rayproject/2.10.0-py310-aarch64 image for raspberry pi | ||
|
||
FROM rayproject/ray:2.10.0-py310 | ||
|
||
# Install dependencies from requirements.txt | ||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt |
File renamed without changes.