-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: jaqpot docker models section (#40)
- Loading branch information
Showing
4 changed files
with
160 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# Deployment | ||
|
||
This guide explains how to deploy your Docker model to Jaqpot. | ||
|
||
## Creating the model configuration | ||
|
||
First, you need to register your model with Jaqpot by sending a configuration to the `/v1/models` endpoint: | ||
|
||
```json | ||
{ | ||
"name": "Your model name", | ||
"type": "DOCKER", | ||
"description": "model description", | ||
"independentFeatures": [ | ||
{ | ||
"key": "input", | ||
"name": "Input", | ||
"featureType": "TEXT" | ||
} | ||
], | ||
"dependentFeatures": [ | ||
{ | ||
"key": "output", | ||
"name": "Output", | ||
"featureType": "TEXT" | ||
} | ||
], | ||
"task": "BINARY_CLASSIFICATION", | ||
"visibility": "PUBLIC", | ||
"dockerConfig": { | ||
"appName": "your-app-name" | ||
} | ||
} | ||
``` | ||
|
||
The `appName` in the configuration is a unique identifier for your model in the Jaqpot system. | ||
|
||
## Deploying your Docker image | ||
|
||
After registering your model configuration: | ||
|
||
1. Build your Docker image using the provided Dockerfile | ||
2. Push the image to a Docker registry | ||
3. Share your Docker image name with us | ||
4. We will host your image and connect it to Jaqpot using your specified `appName` | ||
|
||
Once deployed, your model will be available through the standard Jaqpot prediction endpoints. |
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,78 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Implementing your model | ||
|
||
This guide explains how to implement your custom model for Jaqpot using Docker. | ||
|
||
## Getting started | ||
|
||
First, fork our template repository: https://github.com/ntua-unit-of-control-and-informatics/jaqpot-model-with-docker-template | ||
|
||
The template includes: | ||
- A training script (`train.py`) | ||
- A FastAPI server implementation (`main.py`) | ||
- Prediction request/response models | ||
- A Dockerfile for deployment | ||
|
||
## Training your model | ||
|
||
The `train.py` file is where you implement your model's training logic: | ||
|
||
```python | ||
# train.py | ||
import pandas as pd | ||
from sklearn.datasets import make_classification | ||
from sklearn.ensemble import RandomForestClassifier | ||
import joblib | ||
|
||
# Generate sample data | ||
X, y = make_classification(n_samples=1000, n_features=4, n_informative=2, n_redundant=0) | ||
|
||
df = pd.DataFrame(X, columns=["X1", "X2", "X3", "X4"]) | ||
|
||
# Train a sample model | ||
model = RandomForestClassifier(n_estimators=100) | ||
model.fit(df, y) | ||
|
||
# Save the model | ||
joblib.dump(model, 'model.pkl') | ||
``` | ||
|
||
This creates a `model.pkl` file that will be loaded by your prediction service. | ||
|
||
## Implementing the prediction endpoint | ||
|
||
Your main task is implementing the `/infer` endpoint. Here's a basic example: | ||
|
||
```python | ||
from fastapi import FastAPI | ||
import pickle | ||
from app.models import PredictionRequest, PredictionResponse | ||
|
||
app = FastAPI() | ||
|
||
# Load the trained model | ||
with open('model.pkl', 'rb') as f: | ||
model = pickle.load(f) | ||
|
||
@app.post("/infer", response_model=PredictionResponse) | ||
async def predict(request: PredictionRequest): | ||
result = model.predict(request.data) | ||
return PredictionResponse(status=200, data=result) | ||
``` | ||
|
||
## Testing locally | ||
|
||
1. Train your model: | ||
```bash | ||
python train.py | ||
``` | ||
|
||
2. Run the FastAPI server: | ||
```bash | ||
uvicorn app.main:app --reload | ||
``` | ||
|
||
Your model is now ready for Docker deployment on Jaqpot. |
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 @@ | ||
--- | ||
sidebar_position: 5 | ||
title: Docker models | ||
--- | ||
|
||
import DocCardList from '@theme/DocCardList'; | ||
|
||
# Docker models on Jaqpot | ||
|
||
Jaqpot supports deploying custom models using Docker containers. This lets you run any model, regardless of its framework or dependencies, as long as you package it correctly. | ||
|
||
### Important note about deployment | ||
|
||
The deployment process for Docker models is manually managed by our team to ensure security and proper integration. Before deployment: | ||
|
||
1. Contact us at [email protected] with your model details | ||
2. We will review your requirements and provide specific instructions | ||
3. Once approved, we will help you integrate your model into our infrastructure | ||
|
||
### How it works: | ||
|
||
1. Create a model configuration with Docker settings | ||
2. Implement your model using our template | ||
3. Build and test your Docker image locally | ||
4. Contact us for deployment review and instructions | ||
5. After approval, we'll host your model on Jaqpot | ||
|
||
The following sections will guide you through the technical implementation. Remember to reach out to us before starting the deployment process. | ||
<DocCardList /> |
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