Skip to content

Latest commit

 

History

History
198 lines (156 loc) · 3.48 KB

File metadata and controls

198 lines (156 loc) · 3.48 KB

🚀 Quick Start Guide - WebGenie Backend

Get the FastAPI backend running in minutes!

Option 1: Docker Compose (Recommended) ⭐

The simplest way to get everything running:

cd webgenie_api
docker-compose up -d

This starts:

Access:

Option 2: Local Development Setup

Prerequisites

  • Python 3.11+
  • Redis (local or Docker)

Setup

# Navigate to backend
cd webgenie_api

# Create virtual environment
python -m venv venv

# Activate it
source venv/bin/activate  # Linux/Mac
# or
venv\Scripts\activate  # Windows

# Install dependencies
pip install -r requirements.txt

# Copy environment file
cp .env.example .env

Start Services (3 terminals)

Terminal 1: Start Redis

docker run -d -p 6379:6379 redis:7-alpine

Terminal 2: FastAPI Server

cd webgenie_api
source venv/bin/activate
uvicorn app.main:app --reload --port 8000

Terminal 3: Celery Worker

cd webgenie_api
source venv/bin/activate
celery -A app.core.tasks worker --loglevel=info

Terminal 4 (optional): Celery Beat

cd webgenie_api
source venv/bin/activate
celery -A app.core.tasks beat --loglevel=info

Testing

# Run tests
pytest

# Run tests with coverage
pytest --cov=app

First API Call

Get Available Algorithms

curl http://localhost:8000/api/v1/algorithms

Register a Dataset

curl -X POST http://localhost:8000/api/v1/datasets/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Test Dataset",
    "description": "A test dataset",
    "species": "Human",
    "tissue": "Liver",
    "source": {
      "source_type": "local",
      "url": "/data/test.csv",
      "metadata": {}
    },
    "schema": {
      "gene_column": "Gene",
      "cell_column": "Cell",
      "expression_column": "Expression"
    }
  }'

Submit an Inference Job

curl -X POST http://localhost:8000/api/v1/jobs \
  -H "Content-Type: application/json" \
  -d '{
    "dataset_id": "test-dataset-xyz",
    "algorithm": "GRNBOOST2",
    "parameters": {
      "alpha": 0.5
    },
    "name": "My First Job"
  }'

Check Job Status

curl http://localhost:8000/api/v1/jobs/job-abc123

📚 Documentation

🔧 Configuration

Edit .env to configure:

# Server
DEBUG=False
LOG_LEVEL=INFO

# Redis
REDIS_URL=redis://localhost:6379/0

# Algorithms
USE_DOCKER=True
MAX_CONCURRENT_JOBS=4

🆘 Troubleshooting

Issue: Redis connection refused

# Start Redis
docker run -d -p 6379:6379 redis:7-alpine

Issue: Port already in use

# Change port in docker-compose.yml or .env
SERVER_PORT=8001

Issue: Module not found

# Reinstall dependencies
pip install -r requirements.txt --force-reinstall

📊 Monitoring

View Logs

docker-compose logs -f backend

Check Services

docker-compose ps

Stop All Services

docker-compose down