WB_Analyzer / deployment-guide.md
bakyt92's picture
first push
d80bf0f

A newer version of the Gradio SDK is available: 6.3.0

Upgrade

πŸš€ 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

  1. Go to Hugging Face Spaces
  2. Click "Create new Space"
  3. Configure your space:
    • Space name: wildberries-analytics (or your preferred name)
    • License: MIT
    • SDK: Gradio
    • Hardware: CPU Basic (free tier)
    • Visibility: Public or Private

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:

  1. Go to your Space page
  2. Click Settings tab
  3. Scroll to Repository secrets
  4. Add a new secret:
    • Name: WILDBERRIES_API_TOKEN
    • Value: Your Wildberries API token

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

  1. Get your token:

    • Log into your Wildberries seller account
    • Go to Settings β†’ Access to API
    • Generate token with permissions:
      • βœ… Analytics
      • βœ… Statistics
      • βœ… Marketplace
  2. 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.py contains demo data functions
  • Verify examples/sample_data.json exists

Checking Logs

  1. Go to your Space page
  2. Click Settings tab
  3. View Container logs for detailed error messages

Performance Optimization

For better performance:

  1. Upgrade to CPU Upgrade hardware ($0.03/hour)
  2. Use persistent storage for data caching
  3. 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

  1. Make changes locally
  2. Test with demo mode
  3. 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

  1. Hugging Face Community: discuss.huggingface.co
  2. Gradio Documentation: gradio.app/docs
  3. 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:

  1. Create new API client modules
  2. Update configuration for multiple tokens
  3. Add marketplace selection in UI

Data Persistence

For storing historical data:

  1. Upgrade to persistent storage
  2. Implement database integration
  3. Add data export features

Real-time Updates

For live dashboard updates:

  1. Implement WebSocket connections
  2. Add auto-refresh functionality
  3. 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