Skip to content

Repository files navigation

Gemma Garage Backend

REST API backend for Gemma Garage, built with FastAPI and deployed on Google Cloud Run.

Overview

The backend serves as the orchestration layer between the frontend and various Google Cloud services. It handles dataset management, training job submission, model downloads, and HuggingFace integration.

Architecture

Frontend --> Backend (FastAPI) --> Cloud Run Jobs (GPU Training)
                |                        |
                +--> GCS (Storage)       +--> Cloud Logging
                +--> Gemini API
                +--> HuggingFace Hub

Endpoints

Route Purpose
/dataset/* Upload, preview, import, and augment datasets
/finetune/* Submit supervised fine-tuning jobs and fetch logs
/rl_finetune/* Submit reinforcement learning training jobs
/download/* Generate signed URLs for model weight downloads
/huggingface/* OAuth authentication and model upload to HF Hub
/ingest/* Extract and process GitHub repositories
/model/* Model selection

Key Features

  • Dataset Augmentation: Uses Gemini API to generate synthetic QA pairs from uploaded documents
  • Training Orchestration: Submits jobs to Cloud Run with GPU support and tracks progress via Cloud Logging
  • HuggingFace Integration: OAuth flow for authenticating users and uploading trained models
  • Signed URLs: Secure, time-limited download links for trained model weights

Tech Stack

  • Framework: FastAPI 0.115
  • Server: Uvicorn (ASGI)
  • Cloud Services: GCS, Cloud Run, Cloud Logging, Vertex AI
  • External APIs: Gemini, HuggingFace Hub

Local Development

# Install dependencies
pip install -r requirements.txt

# Set environment variables
export GEMINI_API_KEY=your_key
export NEW_DATA_BUCKET=gs://your-bucket

# Run server
uvicorn main:app --reload --port 8080

Deployment

The service is automatically deployed to Cloud Run via GitHub Actions on push to main.

# Manual deployment
gcloud run deploy gemma-garage-backend \
  --source . \
  --region us-central1

Testing

pip install -r requirements-test.txt
pytest tests/ -v

Environment Variables

Variable Description
NEW_DATA_BUCKET GCS bucket for datasets
NEW_MODEL_OUTPUT_BUCKET GCS bucket for trained models
GEMINI_API_KEY API key for Gemini
HUGGINGFACE_CLIENT_ID HuggingFace OAuth client ID
HUGGINGFACE_CLIENT_SECRET HuggingFace OAuth client secret

About

Backend for Gemma Garage - Deployed through Cloud Run

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages