File size: 9,905 Bytes
eebf5c4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# π Gradio Dashboard for Crypto Data Sources
## Overview
Comprehensive Gradio-based monitoring dashboard that provides real-time health checking, force testing, and auto-healing capabilities for all crypto data sources in the project.
## β¨ Features
### 1. **System Overview Dashboard**
- Real-time status of FastAPI backend
- HF Data Engine health monitoring
- Loaded resources statistics
- System uptime tracking
### 2. **Force Testing**
- Test ALL 200+ data sources with retries
- Detailed latency measurements
- Success/failure tracking
- Automatic retry on failures
### 3. **Resource Explorer**
- Browse all API resources
- Detailed configuration view
- Force test results per resource
- JSON configuration display
### 4. **FastAPI Endpoint Monitor**
- Test all backend endpoints
- Response time tracking
- Status code monitoring
- Automatic health checks
### 5. **HF Data Engine Monitor**
- Test OHLCV endpoints
- Price feed monitoring
- Sentiment analysis checks
- Cache statistics
### 6. **Custom API Testing**
- Test any URL with custom headers
- Configurable retry attempts
- Multiple HTTP methods (GET, POST, PUT, DELETE)
- Detailed response analysis
### 7. **Analytics Dashboard**
- Resource statistics by category
- Source file breakdowns
- Performance metrics
- Success rate tracking
### 8. **Auto-Healing**
- Automatic retry with different strategies
- Header modification attempts
- Timeout adjustments
- Redirect following
## π Quick Start
### Option 1: Using Startup Script
```bash
# Make script executable (first time only)
chmod +x start_gradio_dashboard.sh
# Start dashboard
./start_gradio_dashboard.sh
```
### Option 2: Manual Start
```bash
# Install requirements
pip install -r requirements_gradio.txt
# Start dashboard
python gradio_ultimate_dashboard.py
```
### Option 3: Direct Python
```bash
python3 gradio_ultimate_dashboard.py
```
## π Access
Once started, the dashboard is available at:
**URL:** http://localhost:7861
You can also access it from other devices on your network using your machine's IP address:
**Network URL:** http://YOUR_IP:7861
## π Dashboard Tabs
### π Dashboard
- System overview
- Core systems status (FastAPI, HF Engine)
- Resource statistics
- Quick health summary
### π§ͺ Force Test
- Comprehensive testing of ALL sources
- Multiple retry attempts per source
- Detailed success/failure tracking
- Performance metrics
**How to use:**
1. Click "β‘ START FORCE TEST" button
2. Wait for completion (may take 2-5 minutes for all sources)
3. Review results table
4. Check individual resource details
### π Resource Explorer
- Search and explore all API resources
- View complete configuration
- See force test results
- Analyze individual sources
**How to use:**
1. Select resource from dropdown
2. View detailed configuration
3. Check test results
4. Copy configuration if needed
### β‘ FastAPI Status
- Monitor main backend server
- Test all API endpoints
- Check response times
- Verify functionality
**Tested Endpoints:**
- `/health` - Health check
- `/api/status` - System status
- `/api/providers` - Provider list
- `/api/pools` - Pool management
- `/api/hf/health` - HuggingFace health
- `/api/feature-flags` - Feature flags
- `/api/data/market` - Market data
- `/api/data/news` - News data
### π€ HF Data Engine
- Monitor HuggingFace Data Engine
- Test all data endpoints
- Check provider status
- Verify cache performance
**Tested Endpoints:**
- `/api/health` - Engine health
- `/api/prices` - Price data
- `/api/ohlcv` - Candlestick data
- `/api/sentiment` - Market sentiment
- `/api/market/overview` - Market overview
- `/api/cache/stats` - Cache statistics
### π― Custom Test
- Test any API endpoint
- Custom headers support
- Configurable retries
- All HTTP methods
**Features:**
- URL input
- Method selection (GET, POST, PUT, DELETE)
- Custom headers (JSON format)
- Retry attempts (1-5)
- Detailed response display
### π Analytics
- Comprehensive resource statistics
- Category breakdowns
- Source file analysis
- Performance metrics
## π§ Configuration
### Enable Auto-Heal
Toggle the "π§ Enable Auto-Heal" checkbox at the top of the dashboard to enable automatic retry with different strategies when a source fails.
**Auto-Heal Strategies:**
1. Add custom headers (User-Agent, etc.)
2. Increase timeout duration
3. Follow redirects automatically
### Enable Real-Time Monitoring
Toggle "π‘ Enable Real-Time Monitoring" to activate continuous background monitoring (coming in future update).
## π Files
### Main Dashboard Files
- `gradio_ultimate_dashboard.py` - Advanced dashboard with all features
- `gradio_dashboard.py` - Basic dashboard (simpler version)
### Configuration
- `requirements_gradio.txt` - Python dependencies
- `start_gradio_dashboard.sh` - Startup script
### Data Sources
- `api-resources/crypto_resources_unified_2025-11-11.json` - Unified resources (200+ sources)
- `api-resources/ultimate_crypto_pipeline_2025_NZasinich.json` - Pipeline resources (162 sources)
- `all_apis_merged_2025.json` - Merged APIs
- `providers_config_extended.json` - Extended provider configs
- `providers_config_ultimate.json` - Ultimate provider configs
## π§ͺ Testing Workflow
### Complete System Test
1. **Start All Services:**
```bash
# Terminal 1: Main FastAPI backend
python app.py
# Terminal 2: HF Data Engine
cd hf-data-engine && python main.py
# Terminal 3: Gradio Dashboard
./start_gradio_dashboard.sh
```
2. **Verify Systems:**
- Open dashboard: http://localhost:7861
- Check Dashboard tab for system status
- Verify both FastAPI and HF Engine show "β
ONLINE"
3. **Run Force Test:**
- Go to "π§ͺ Force Test" tab
- Click "β‘ START FORCE TEST"
- Wait for completion
- Review results
4. **Test Individual Endpoints:**
- Go to "β‘ FastAPI Status" tab
- Click "π§ͺ Test All Endpoints"
- Check all endpoints are working
5. **Test HF Engine:**
- Go to "π€ HF Data Engine" tab
- Click "π§ͺ Test All Endpoints"
- Verify data is returned
6. **Explore Resources:**
- Go to "π Resource Explorer" tab
- Browse different data sources
- View configurations
7. **Check Analytics:**
- Go to "π Analytics" tab
- Review statistics
- Check resource distribution
## π¨ Troubleshooting
### Dashboard won't start
**Problem:** Import errors
**Solution:**
```bash
pip install -r requirements_gradio.txt
```
### Can't connect to FastAPI/HF Engine
**Problem:** Services not running
**Solution:**
```bash
# Check if services are running
curl http://localhost:7860/health
curl http://localhost:8000/api/health
# Start if needed
python app.py # FastAPI
cd hf-data-engine && python main.py # HF Engine
```
### Force test shows all offline
**Problem:** Network/firewall issues or services not started
**Solution:**
1. Verify services are running (see above)
2. Check if you're behind a restrictive firewall
3. Try testing individual endpoints first
4. Enable auto-heal for retry attempts
### Slow performance
**Problem:** Testing too many sources
**Solution:**
- Test only specific categories instead of all
- Increase timeout values
- Test during off-peak hours
- Use caching for repeated tests
## π‘ Tips & Best Practices
### 1. Test Incrementally
Don't run force test on all sources at once during development. Start with:
- FastAPI endpoints only
- HF Engine endpoints only
- Small subset of resources
### 2. Use Auto-Heal Wisely
Enable auto-heal when testing external APIs that might have temporary issues. Disable for internal services.
### 3. Monitor Regularly
Schedule regular health checks:
- Every hour: FastAPI and HF Engine
- Every 6 hours: All external sources
- Daily: Full force test
### 4. Export Results
After force testing, export results for:
- Historical tracking
- Performance analysis
- Downtime investigation
### 5. Custom Testing
Use the custom test tab to:
- Debug specific endpoints
- Test new APIs before adding to system
- Verify authentication
- Test with different headers
## π Metrics & KPIs
The dashboard tracks:
- **Uptime:** Percentage of time services are available
- **Response Time:** Average latency for requests
- **Success Rate:** Percentage of successful requests
- **Error Rate:** Percentage of failed requests
- **Resource Coverage:** Number of working vs total resources
## π Integration
### With Existing Systems
The dashboard integrates with:
1. **FastAPI Backend** (app.py)
- Monitors all endpoints
- Tests provider health
- Checks feature flags
2. **HF Data Engine** (hf-data-engine/)
- Tests all data endpoints
- Monitors provider status
- Checks cache performance
3. **API Resources** (api-resources/)
- Loads all resource configurations
- Tests each resource
- Tracks availability
### API Endpoints Used
The dashboard calls these endpoints:
**FastAPI:**
- `GET /health`
- `GET /api/status`
- `GET /api/providers`
- `GET /api/hf/health`
**HF Engine:**
- `GET /api/health`
- `GET /api/prices`
- `GET /api/ohlcv`
- `GET /api/sentiment`
## π Future Enhancements
Planned features:
- [ ] Real-time monitoring with auto-refresh
- [ ] Alert system for downtimes
- [ ] Historical data tracking
- [ ] Performance graphs and charts
- [ ] Email notifications
- [ ] Slack/Discord integration
- [ ] Automated daily reports
- [ ] Resource availability heatmap
- [ ] Comparative analytics
- [ ] Export to multiple formats (PDF, Excel)
## π€ Contributing
To add new features:
1. Fork the dashboard code
2. Add new tab or functionality
3. Test thoroughly
4. Submit pull request
## π License
Same as main project
## π Acknowledgments
Built using:
- **Gradio** - UI framework
- **httpx** - HTTP client
- **pandas** - Data analysis
- **FastAPI** - Backend server
---
**Version:** 2.0
**Last Updated:** 2024-11-14
**Status:** β
Production Ready
|