Skip to content

Commit

Permalink
docs: jaqpot docker models section (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
alarv authored Jan 30, 2025
1 parent b0dfb1b commit 7b9ca32
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 2 deletions.
51 changes: 51 additions & 0 deletions docusaurus/docs/docker-models/deploy-your-model.md
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.
78 changes: 78 additions & 0 deletions docusaurus/docs/docker-models/implementing-your-model.md
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.
29 changes: 29 additions & 0 deletions docusaurus/docs/docker-models/index.mdx
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 />
4 changes: 2 additions & 2 deletions docusaurus/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ const config: Config = {
},
algolia: {
// The application ID provided by Algolia
appId: process.env.ALGOLIA_APP_ID,
appId: process.env.ALGOLIA_APP_ID || 'local',

// Public API key: it is safe to commit it
apiKey: process.env.ALGOLIA_SEARCH_API_KEY,
apiKey: process.env.ALGOLIA_SEARCH_API_KEY || 'local',

indexName: 'jaqpot',

Expand Down

0 comments on commit 7b9ca32

Please sign in to comment.