cv-bot / DEPLOYMENT.md
alextododev's picture
Upload folder using huggingface_hub
77932b1 verified

A newer version of the Gradio SDK is available: 6.1.0

Upgrade

Hugging Face Spaces Deployment Guide

Files Created for Deployment

  1. app.py (root) - Main application file configured for Hugging Face Spaces
  2. requirements.txt - Minimal dependencies needed for the app
  3. README.md - Space metadata and description

Deployment Steps

1. Prepare Your Repository

The current file structure should work. The app.py in the root will automatically detect files in src/ or root directories.

2. Create a Hugging Face Space

  1. Go to Hugging Face Spaces
  2. Click "Create new Space"
  3. Choose:
    • SDK: Gradio
    • Python version: 3.10 or higher
    • Hardware: CPU (or GPU if needed)
    • Visibility: Public or Private

3. Push Your Code

You can either:

Option A: Using Git

# Initialize git if not already done
git init
git add app.py requirements.txt README.md src/
git commit -m "Deploy to Hugging Face Spaces"
git remote add origin https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
git push -u origin main

Option B: Using Hugging Face CLI

pip install huggingface_hub
huggingface-cli login
# Then upload files through the web interface or use the API

4. Set Environment Variables

  1. Go to your Space settings
  2. Navigate to "Variables and secrets"
  3. Add a new secret:
    • Name: OPENAI_API_KEY
    • Value: Your OpenAI API key

5. Verify File Structure

Make sure these files/folders are in your Space:

β”œβ”€β”€ app.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
└── src/
    β”œβ”€β”€ cv/
    β”‚   β”œβ”€β”€ me.txt
    β”‚   └── avatar.jpeg
    └── projects_images/
        β”œβ”€β”€ s_up.jpeg
        β”œβ”€β”€ llm.jpeg
        β”œβ”€β”€ bi.png
        └── robot.png

6. Wait for Build

The Space will automatically build and deploy. You can monitor the build logs in the Space interface.

Troubleshooting

  • File not found errors: Make sure all files in src/ are committed and pushed
  • API key errors: Verify OPENAI_API_KEY is set as a secret (not a variable)
  • Import errors: Check that requirements.txt includes all necessary packages

Notes

  • The app.py automatically detects file paths (works with both src/ and root-level files)
  • Make sure .env file is NOT committed (it's in .gitignore)
  • The app uses Hugging Face Space secrets for the API key