A newer version of the Gradio SDK is available:
5.42.0
Hugging Face Deployment Guide for GAIA Agent
This guide provides detailed instructions for deploying the GAIA agent to Hugging Face Spaces. It covers cleaning the existing space, preparing the deployment package, uploading to Hugging Face, and verifying the deployment.
Prerequisites
Before you begin, make sure you have the following:
- A Hugging Face account
- The Hugging Face CLI installed and configured
- Access to the GAIA project repository
- Python 3.8+ installed
Installation of Required Tools
Install the Hugging Face CLI tool:
pip install huggingface_hub
Login to Hugging Face:
huggingface-cli login
Deployment Process
Step 1: Prepare the Deployment Package
The prepare_hf_deployment.py
script helps you create a clean deployment package with only the necessary files. You can run it with different options depending on your needs.
List Files That Would Be Included
To see which files would be included in the deployment package without actually creating it:
python src/gaia/scripts/prepare_hf_deployment.py --list-only
Create a Deployment Package
To create a deployment package (ZIP file) with all essential files:
python src/gaia/scripts/prepare_hf_deployment.py --create-package
By default, this will create a package in a deployment
directory. You can customize the output directory and package name:
python src/gaia/scripts/prepare_hf_deployment.py --create-package --output-dir custom_dir --package-name custom_package.zip
Step 2: Clean the Existing Hugging Face Space
Before uploading new files, you can clean the existing space to remove old files:
python src/gaia/scripts/prepare_hf_deployment.py --clean-remote
This will prompt for confirmation before deleting files. Use the --force
flag to skip confirmation:
python src/gaia/scripts/prepare_hf_deployment.py --clean-remote --force
Step 3: Upload to Hugging Face
To upload the prepared package to Hugging Face:
python src/gaia/scripts/prepare_hf_deployment.py --upload
You need to create a package first. You can combine the steps:
python src/gaia/scripts/prepare_hf_deployment.py --create-package --upload
Or perform the complete deployment process in one command:
python src/gaia/scripts/prepare_hf_deployment.py --create-package --clean-remote --upload
Step 4: Verify the Deployment
After uploading, verify that the deployment was successful:
- Visit your Hugging Face Space at
https://huggingface.co/spaces/JoachimVC/Final_Assignment_GAIAAgent
- Check that the app loads correctly and all essential functionality works
- Test the main features to ensure they're working as expected
Customizing File Selection
The script uses default inclusion and exclusion patterns, but you can customize them.
Using Custom Pattern Files
Create a file with patterns of files to include:
# include_patterns.txt
src/gaia/agent/**/*.py
src/gaia/config/**/*.py
src/gaia/tools/**/*.py
Create a file with patterns of files to exclude:
# exclude_patterns.txt
**/__pycache__/**
**/*.log
Then use these files with the script:
python src/gaia/scripts/prepare_hf_deployment.py --create-package --include-file include_patterns.txt --exclude-file exclude_patterns.txt
Deployment to a Different Space
By default, the script deploys to the JoachimVC/Final_Assignment_GAIAAgent
space. To deploy to a different space:
python src/gaia/scripts/prepare_hf_deployment.py --create-package --upload --space-id your-username/your-space-name
Troubleshooting
Authorization Issues
If you encounter authorization issues:
- Ensure you're logged in with
huggingface-cli login
- Verify you have write access to the Space
- Check your token hasn't expired (re-login if necessary)
File Size Limitations
If your deployment package is too large:
- Review the included files with
--list-only
- Add more exclusion patterns for large files
- Consider splitting the deployment into multiple steps
API Errors
If you encounter API errors:
- Check your internet connection
- Verify the Hugging Face API is operational
- Retry the operation after a few minutes
Best Practices
- Version your deployments: Add version tags or timestamps to your packages
- Test locally first: Ensure your app works locally before deploying
- Keep secrets out: Never include API keys or sensitive information in the deployment
- Use the .huggingnorefile: This helps exclude unnecessary files
- Regular cleanup: Periodically clean old files from your Space