Spaces:
Sleeping
Sleeping
π― Deployment Summary: HF Dataset Integration
β What Changed
π Major Update: File Storage β HF Dataset
Before:
- Used local
devices.json
file - Data lost on Space restart
- Permission issues in Docker container
After:
- Uses Hugging Face Dataset for persistent storage
- Data survives Space restarts
- No file permission issues
- Automatic fallback to in-memory storage
π New Files Added
hf-dataset.js
- HF Dataset manager classHF-DATASET-SETUP.md
- Setup documentationDEPLOYMENT-SUMMARY.md
- This summary
π§ Configuration Required
Required Secrets in HF Space:
FIREBASE_SERVICE_ACCOUNT = {your firebase config JSON}
HF_TOKEN = hf_your_write_token_here
Optional Secrets:
HF_DATASET_ID = Detomo/houzou-devices
π How to Configure
1. Generate HF Token
- Go to https://huggingface.co/settings/tokens
- Create new token with Write permissions
- Copy the token
2. Add to Space Secrets
- Go to Space Settings β Secrets and variables
- Add
HF_TOKEN
with your token value
3. Deploy
- Changes are already pushed
- Space will rebuild automatically
- Dataset will be created automatically
π Features
β Automatic Dataset Management
- Creates
Detomo/houzou-devices
dataset if not exists - Handles permissions automatically
- Stores device tokens in
devices.json
β Robust Error Handling
- Graceful fallback to in-memory storage
- Detailed logging for troubleshooting
- Continues operation even if HF API fails
β Persistent Storage
- Device tokens survive Space restarts
- Automatic backup to HF dataset
- Version control for device data
π Verification Steps
1. Check Space Status
curl https://detomo-houzou-notification-server.hf.space/
Should show:
{
"hfDataset": {
"enabled": true,
"datasetId": "Detomo/houzou-devices",
"hasToken": true
}
}
2. Check Dataset
- Go to: https://huggingface.co/datasets/Detomo/houzou-devices
- Should see
devices.json
with your device data
3. Test Device Registration
curl -X POST https://detomo-houzou-notification-server.hf.space/register-token \
-H "Content-Type: application/json" \
-d '{
"token": "test-token",
"deviceId": "test-device",
"platform": "test"
}'
π Troubleshooting
Dataset Not Working?
- Check
HF_TOKEN
is set correctly - Verify token has Write permissions
- Check Space logs for errors
- Server will fall back to in-memory storage
Common Issues:
403 Forbidden: Token lacks write permissions 404 Not Found: Dataset will be auto-created Rate Limiting: HF API limits, server will retry
π― Benefits
- β Persistent: Data survives restarts
- β Reliable: Automatic fallback mechanisms
- β Scalable: No file permission issues
- β Traceable: Version history in dataset
- β Secure: Tokens stored in HF infrastructure
π Migration Status
- β Code updated to use HF Dataset
- β Automatic dataset creation
- β Error handling implemented
- β Documentation provided
- β Changes deployed to Space
π Next Steps
- Configure HF Token (required)
- Verify deployment works
- Test device registration from Flutter app
- Monitor dataset for device data
Status: Ready for production! π
The server now uses HF Dataset for persistent storage and will automatically handle device tokens across Space restarts.