Spaces:
Runtime error
Runtime error
A newer version of the Gradio SDK is available:
6.2.0
Development Guidelines
Build & Test Commands
# Install dependencies
pip install -r requirements.txt
pip install -r requirements-test.txt
# Run linting
python -m ruff check .
# Run formatting
python -m ruff format .
# Type checking
python -m mypy .
# Run a specific test
python -m pytest test_e2e.py -v
# Run a specific test function
python -m pytest test_e2e.py::test_end_to_end -v
# Deploy to Cloud Run
./deploy_rag.sh --project=YOUR_PROJECT_ID --region=YOUR_REGION
# Local development
python app.py
Code Style
- Line Length: 100 characters max (defined in pyproject.toml)
- Docstrings: Google style docstrings required (follow existing patterns)
- Type Hints: Required for all function parameters and return values
- Imports: Group standard lib, third-party, then local imports with blank lines between
- Error Handling: Use specific exception types with logging
- Linters: Ruff for linting (F, E, W, D, N, C, B, Q, A rules)
- Naming: snake_case for variables/functions, CamelCase for classes
- Environment Variables: Use os.environ.get() with defaults when appropriate
Architecture
- Flask web application for serving RAG queries
- Google Cloud services: BigQuery, Vertex AI, DocumentAI, Cloud Storage
- Cloud Functions triggered by GCS events
- Cloud Run for serving the web application
Hugging Face Implementation Plan
Repository Link
Migration Steps
- Create a new Hugging Face Space with Docker SDK
- Enable Dev Mode for VS Code access
- Clone the GitHub repository
- Set up environment variables for secrets
- Configure persistent storage (20GB purchased)
Running on Hugging Face
- Configure Space to always stay running (persistent execution)
- Use "Secrets" in Space settings for API keys and credentials
- Set up scheduled tasks with GitHub Actions for:
- Processing files (daily)
- Backing up code (every 6 hours)
Implementation Details
File Storage:
- Store input files in Hugging Face's persistent storage
- Use Hugging Face Datasets for managing processed data
Process Automation:
- For "under the hood" processing:
- Configure Space to run continuously
- Set up GitHub Actions for scheduled tasks
- Use Docker health checks to ensure service stays alive
- For "under the hood" processing:
Deployment Architecture:
- Hugging Face Space = Cloud Run equivalent
- Space will run the server continuously
- Configure autoscaling in the Dockerfile settings
Key Files
auto_process_bucket.py: Batch file processorprocess_text.py: Individual file processorrag_query.py: Query interfaceapp.py: Web applicationauto_backup.sh: GitHub backup scriptsetup_all.sh: Complete setup script
Required Environment Variables
GOOGLE_APPLICATION_CREDENTIALS: Google Cloud credentialsPROJECT_ID: Google Cloud project IDBUCKET_NAME: GCS bucket nameGITHUB_TOKEN: For GitHub accessHF_TOKEN: For Hugging Face API access
Hugging Face Specific Updates
- Update Dockerfile for Hugging Face compatibility
- Create Space UI in
app.pyusing Gradio or Streamlit - Use Hugging Face Datasets API in addition to BigQuery
Project Goal
Create an automated RAG system that:
- Automatically processes text/PDF files
- Runs continuously "under the hood"
- Provides a simple query interface
- Backs up all code and data
- Requires minimal maintenance