Skip to content

Latest commit

 

History

History
182 lines (131 loc) · 3.28 KB

File metadata and controls

182 lines (131 loc) · 3.28 KB

Quick Start Guide

Get up and running in 5 minutes!

🚀 Fastest Way to Start

Option 1: Docker (Recommended)

# 1. Build and run
docker-compose up -d

# 2. Check health
curl http://localhost:8000/api/v1/health

# 3. Test prediction
curl -X POST "http://localhost:8000/api/v1/predict/forecast" \
  -H "Content-Type: application/json" \
  -d '{"periods": 7, "freq": "D"}'

# 4. View docs
open http://localhost:8000/docs

Option 2: Local Python

# 1. Setup (Windows)
scripts\setup.bat

# Setup (Linux/Mac)
chmod +x scripts/setup.sh
./scripts/setup.sh

# 2. Run
python run.py

# 3. Test
curl http://localhost:8000/api/v1/health

📝 Adding Your First Model

1. Create Model File

Create app/models/mymodel.py:

from app.models.base import BaseMLModel

class MymodelModel(BaseMLModel):
    def __init__(self):
        super().__init__(model_name="mymodel", version="1.0")
    
    async def load_model(self):
        # Load your model here
        # self.model = joblib.load("model_storage/mymodel.pkl")
        self.is_loaded = True
    
    async def predict(self, input_data):
        # Your prediction logic
        return {
            "prediction": "result",
            "model": self.model_name,
            "version": self.version
        }

2. Register Model

Edit .env:

MODEL_REGISTRY={"forecast": "forecast.py", "classifier": "classifier.py", "mymodel": "mymodel.py"}

3. Restart & Test

# Restart
docker-compose restart

# Or if running locally
# Ctrl+C and python run.py

# Test
curl -X POST "http://localhost:8000/api/v1/predict/mymodel" \
  -H "Content-Type: application/json" \
  -d '{"your": "input"}'

🧪 Testing Examples

Forecast Model

curl -X POST "http://localhost:8000/api/v1/predict/forecast" \
  -H "Content-Type: application/json" \
  -d '{
    "periods": 30,
    "freq": "D"
  }'

Classifier Model

curl -X POST "http://localhost:8000/api/v1/predict/classifier" \
  -H "Content-Type: application/json" \
  -d '{
    "features": [1.2, 3.4, 5.6, 7.8]
  }'

With Python Requests

import requests

# Forecast
response = requests.post(
    "http://localhost:8000/api/v1/predict/forecast",
    json={"periods": 7, "freq": "D"}
)
print(response.json())

# Classifier
response = requests.post(
    "http://localhost:8000/api/v1/predict/classifier",
    json={"features": [1.0, 2.0, 3.0, 4.0]}
)
print(response.json())

🎯 Next Steps

  1. ✅ API is running
  2. 📖 Read full README.md
  3. 🔧 Customize for your models
  4. 🚀 Deploy to production

🆘 Troubleshooting

Port Already in Use

# Change port in .env
PORT=8001

# Or in docker-compose.yml
ports:
  - "8001:8000"

Models Not Loading

  1. Check .env file exists
  2. Verify MODEL_REGISTRY format
  3. Check model file names match registry
  4. View logs: docker-compose logs

Import Errors

# Reinstall dependencies
pip install -r requirements.txt

# Or rebuild Docker
docker-compose build --no-cache

📚 Resources


Need more help? Check the full README.md