Spaces:
Running
A newer version of the Gradio SDK is available:
6.3.0
π Deployment Guide for Hugging Face Spaces
This guide explains how to deploy the updated Wildberries Analytics Dashboard to Hugging Face Spaces.
π Prerequisites
- Hugging Face account
- Wildberries API token (optional for demo mode)
- Git installed locally
π οΈ Step-by-Step Deployment
1. Create a New Space
- Go to Hugging Face Spaces
- Click "Create new Space"
- Configure your space:
- Space name:
wildberries-analytics(or your preferred name) - License: MIT
- SDK: Gradio
- Hardware: CPU Basic (free tier)
- Visibility: Public or Private
- Space name:
2. Clone Your Space
git clone https://huggingface.co/spaces/YOUR_USERNAME/wildberries-analytics
cd wildberries-analytics
3. Add Project Files
Copy all the updated project files to your space directory:
wildberries-analytics/
βββ app.py # Main application
βββ requirements.txt # Dependencies
βββ README.md # Space documentation
βββ config.py # Configuration management
βββ wildberries_client.py # API client
βββ forecasting.py # Forecasting algorithms
βββ dashboard.py # Visualization components
βββ utils.py # Utilities and demo data
βββ .gitignore # Git ignore patterns
βββ examples/
βββ sample_data.json # Sample data for demo
4. Configure Environment Variables (Optional)
If you have a Wildberries API token:
- Go to your Space page
- Click Settings tab
- Scroll to Repository secrets
- Add a new secret:
- Name:
WILDBERRIES_API_TOKEN - Value: Your Wildberries API token
- Name:
5. Commit and Push
git add .
git commit -m "Initial deployment of Wildberries Analytics Dashboard"
git push
6. Wait for Build
- Hugging Face will automatically build your space
- Check the Logs tab to monitor the build process
- Build typically takes 2-5 minutes
βοΈ Configuration Options
Environment Variables
| Variable | Required | Description |
|---|---|---|
WILDBERRIES_API_TOKEN |
No | Your Wildberries API token for real data |
DEBUG |
No | Set to true for debug mode |
GRADIO_THEME |
No | Gradio theme (soft, default, etc.) |
Wildberries API Token Setup
Get your token:
- Log into your Wildberries seller account
- Go to Settings β Access to API
- Generate token with permissions:
- β Analytics
- β Statistics
- β Marketplace
Token permissions needed:
Bit 2: Access to Analytics Bit 5: Access to Statistics Bit 4: Access to Marketplace
π§ Customization
Changing the Theme
Edit app.py line with gr.themes.Soft():
# Available themes:
gr.themes.Default()
gr.themes.Soft()
gr.themes.Monochrome()
gr.themes.Glass()
Adding More Languages
Update the README.md metadata:
language:
- en
- ru
Custom Domain (Pro Feature)
For custom domains, upgrade to a Pro space and configure in Settings.
π¨ Troubleshooting
Common Issues
1. Build Fails with Dependencies
# Check requirements.txt for version conflicts
# Pin specific versions if needed
gradio==5.7.1
pandas>=2.0.3
2. Import Errors
# Ensure all modules are in the same directory
# Check for typos in import statements
3. API Connection Issues
- Verify token is correctly set in Spaces secrets
- Check token permissions in Wildberries dashboard
- Review API rate limits (300 requests/minute)
4. Demo Mode Not Working
- Check if
utils.pycontains demo data functions - Verify
examples/sample_data.jsonexists
Checking Logs
- Go to your Space page
- Click Settings tab
- View Container logs for detailed error messages
Performance Optimization
For better performance:
- Upgrade to CPU Upgrade hardware ($0.03/hour)
- Use persistent storage for data caching
- Optimize data processing in batch operations
π Monitoring Usage
Space Analytics
- View usage statistics in Space settings
- Monitor monthly compute costs
- Track user interactions
API Rate Limiting
The dashboard automatically handles Wildberries API rate limits:
- 300 requests per minute maximum
- Exponential backoff on 429 errors
- Graceful fallback to demo mode
π Updates and Maintenance
Updating the Application
- Make changes locally
- Test with demo mode
- Commit and push to update Space:
git add .
git commit -m "Update: description of changes"
git push
Monitoring API Changes
- Subscribe to Wildberries API updates
- Test regularly with your API token
- Update error handling as needed
π Support
Getting Help
- Hugging Face Community: discuss.huggingface.co
- Gradio Documentation: gradio.app/docs
- Wildberries API Docs: dev.wildberries.ru
Community Resources
- Example Spaces: Browse similar analytics dashboards
- Gradio Components: Explore advanced UI components
- API Integration Patterns: Study other marketplace integrations
π Advanced Features
Adding More Marketplaces
Extend the dashboard to support additional marketplaces:
- Create new API client modules
- Update configuration for multiple tokens
- Add marketplace selection in UI
Data Persistence
For storing historical data:
- Upgrade to persistent storage
- Implement database integration
- Add data export features
Real-time Updates
For live dashboard updates:
- Implement WebSocket connections
- Add auto-refresh functionality
- Use Gradio's live update features
π Congratulations! Your Wildberries Analytics Dashboard is now live on Hugging Face Spaces!
Visit your space URL to start analyzing your marketplace data: https://huggingface.co/spaces/YOUR_USERNAME/wildberries-analytics