Spaces:
Sleeping
Sleeping
Commit ·
556e10f
1
Parent(s): cdaafcb
chore: prepare validator app for Hugging Face Spaces deployment
Browse files- README.md +36 -0
- app.py +5 -1
- docs/spaces/projects.sample.json +14 -0
- docs/spaces/user_access.sample.json +12 -0
- requirements.txt +2 -0
README.md
CHANGED
|
@@ -133,6 +133,42 @@ Yes. The validation flow uses optimistic concurrency checks to detect and handle
|
|
| 133 |
|
| 134 |
Yes. The project is designed for Gradio deployment on Hugging Face Spaces.
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
## Troubleshooting
|
| 137 |
|
| 138 |
### The app does not start locally
|
|
|
|
| 133 |
|
| 134 |
Yes. The project is designed for Gradio deployment on Hugging Face Spaces.
|
| 135 |
|
| 136 |
+
## Deploy on Hugging Face Spaces
|
| 137 |
+
|
| 138 |
+
1. Create a new Space with:
|
| 139 |
+
- SDK: `Gradio`
|
| 140 |
+
- Python: `3.11`
|
| 141 |
+
|
| 142 |
+
2. Push this repository to the Space.
|
| 143 |
+
|
| 144 |
+
3. Configure Variables/Secrets in the Space settings.
|
| 145 |
+
|
| 146 |
+
Required for production bootstrap:
|
| 147 |
+
- `BIRDNET_PROJECTS_FILE` (example: `docs/spaces/projects.sample.json`)
|
| 148 |
+
- `BIRDNET_USER_ACCESS_FILE` (example: `docs/spaces/user_access.sample.json`)
|
| 149 |
+
|
| 150 |
+
Optional runtime settings:
|
| 151 |
+
- `BIRDNET_DETECTIONS_FILE` (seed detections JSON)
|
| 152 |
+
- `BIRDNET_VALIDATIONS_DIR` (default uses temp directory)
|
| 153 |
+
- `BIRDNET_PAGE_SIZE` (default `25`)
|
| 154 |
+
- `BIRDNET_ENABLE_DEMO_BOOTSTRAP` (`false` in production)
|
| 155 |
+
|
| 156 |
+
4. For first smoke test only, you may temporarily set:
|
| 157 |
+
- `BIRDNET_ENABLE_DEMO_BOOTSTRAP=true`
|
| 158 |
+
|
| 159 |
+
Then log in with one of the demo users:
|
| 160 |
+
- `admin_user`
|
| 161 |
+
- `demo_user`
|
| 162 |
+
- `validator_demo`
|
| 163 |
+
|
| 164 |
+
5. After validation, switch to production bootstrap:
|
| 165 |
+
- Set `BIRDNET_ENABLE_DEMO_BOOTSTRAP=false`
|
| 166 |
+
- Provide real `BIRDNET_PROJECTS_FILE` and `BIRDNET_USER_ACCESS_FILE`
|
| 167 |
+
|
| 168 |
+
Notes:
|
| 169 |
+
- The app entrypoint reads `PORT` automatically in Spaces.
|
| 170 |
+
- Keep user/project bootstrap files private if they contain sensitive assignments.
|
| 171 |
+
|
| 172 |
## Troubleshooting
|
| 173 |
|
| 174 |
### The app does not start locally
|
app.py
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
|
|
|
|
|
| 1 |
from src.ui.app_factory import create_app
|
| 2 |
|
| 3 |
|
| 4 |
if __name__ == "__main__":
|
| 5 |
app = create_app()
|
| 6 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
|
| 3 |
from src.ui.app_factory import create_app
|
| 4 |
|
| 5 |
|
| 6 |
if __name__ == "__main__":
|
| 7 |
app = create_app()
|
| 8 |
+
port = int(os.getenv("PORT") or os.getenv("BIRDNET_VALIDATOR_PORT") or "7860")
|
| 9 |
+
host = os.getenv("BIRDNET_VALIDATOR_HOST") or "0.0.0.0"
|
| 10 |
+
app.launch(server_name=host, server_port=port)
|
docs/spaces/projects.sample.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"project_slug": "kenya-2024",
|
| 4 |
+
"name": "Kenya Survey 2024",
|
| 5 |
+
"dataset_repo_id": "org/kenya-2024-dataset",
|
| 6 |
+
"active": true
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"project_slug": "birds-local",
|
| 10 |
+
"name": "Birds Local Validation",
|
| 11 |
+
"dataset_repo_id": "org/birds-local-dataset",
|
| 12 |
+
"active": true
|
| 13 |
+
}
|
| 14 |
+
]
|
docs/spaces/user_access.sample.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"admin_user": {
|
| 3 |
+
"kenya-2024": "admin",
|
| 4 |
+
"birds-local": "admin"
|
| 5 |
+
},
|
| 6 |
+
"validator_a": {
|
| 7 |
+
"kenya-2024": "validator"
|
| 8 |
+
},
|
| 9 |
+
"validator_b": {
|
| 10 |
+
"birds-local": "validator"
|
| 11 |
+
}
|
| 12 |
+
}
|
requirements.txt
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
gradio>=5.0.0
|
| 2 |
huggingface_hub>=0.30.0
|
|
|
|
|
|
|
| 3 |
pydantic>=2.8.0
|
| 4 |
pytest>=8.3.0
|
|
|
|
| 1 |
gradio>=5.0.0
|
| 2 |
huggingface_hub>=0.30.0
|
| 3 |
+
numpy>=2.0.0
|
| 4 |
+
Pillow>=10.4.0
|
| 5 |
pydantic>=2.8.0
|
| 6 |
pytest>=8.3.0
|