Spaces:
Running
Running
File size: 5,135 Bytes
8029b17 |
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 |
version: '3'
vars:
REGISTRY: '{{.REGISTRY | default "ghcr.io"}}'
IMAGE_NAME: '{{.IMAGE_NAME | default "hf-builder"}}'
tasks:
default:
desc: Show available tasks
cmds:
- task --list
# Development
dev:
desc: Run builder locally for development
env:
FLASK_DEBUG: "1"
LOG_FORMAT: text
cmds:
- python app.py
dev:watch:
desc: Run with auto-reload on file changes
deps: [check:deps]
cmds:
- watchmedo auto-restart --patterns="*.py" --recursive -- python app.py
# Testing
test:
desc: Run all tests
cmds:
- pytest tests/ -v
test:unit:
desc: Run unit tests only
cmds:
- pytest tests/unit/ -v
test:integration:
desc: Run integration tests (requires Docker)
cmds:
- pytest tests/integration/ -v
lint:
desc: Run linting
cmds:
- ruff check .
- ruff format --check .
lint:fix:
desc: Fix linting issues
cmds:
- ruff check --fix .
- ruff format .
# Docker
docker:build:
desc: Build Docker image locally
cmds:
- docker build -t {{.IMAGE_NAME}}:local .
docker:run:
desc: Run Docker image locally
deps: [docker:build]
env:
REGISTRY_URL: '{{.REGISTRY}}'
cmds:
- |
docker run --rm -it \
-p 7860:7860 \
-e REGISTRY_URL=$REGISTRY_URL \
-e REGISTRY_USER=$REGISTRY_USER \
-e REGISTRY_PASSWORD=$REGISTRY_PASSWORD \
{{.IMAGE_NAME}}:local
# Deployment
deploy:hf:
desc: Deploy to HuggingFace Space
vars:
SPACE: '{{.SPACE | default "drengskapur/hf-builder"}}'
cmds:
- echo "Deploying to {{.SPACE}}..."
- git push hf main
# Hivemind Integration
hivemind:register:
desc: Register this builder with hivemind controller
vars:
CONTROLLER_URL: '{{.CONTROLLER_URL | default "http://localhost:7860"}}'
BUILDER_ID: '{{.BUILDER_ID | default "builder-1"}}'
cmds:
- |
curl -X POST {{.CONTROLLER_URL}}/api/register \
-H "Content-Type: application/json" \
-d '{"worker_id": "{{.BUILDER_ID}}", "name": "Builder {{.BUILDER_ID}}", "capabilities": ["build"]}'
hivemind:heartbeat:
desc: Send heartbeat to hivemind controller
vars:
CONTROLLER_URL: '{{.CONTROLLER_URL | default "http://localhost:7860"}}'
BUILDER_ID: '{{.BUILDER_ID | default "builder-1"}}'
cmds:
- |
curl -X POST {{.CONTROLLER_URL}}/api/heartbeat \
-H "Content-Type: application/json" \
-d '{"worker_id": "{{.BUILDER_ID}}", "status": "idle"}'
# Health checks
health:
desc: Check builder health
vars:
URL: '{{.URL | default "http://localhost:7860"}}'
cmds:
- curl -s {{.URL}}/health | jq .
status:
desc: Get builder status
vars:
URL: '{{.URL | default "http://localhost:7860"}}'
cmds:
- curl -s {{.URL}}/api/status | jq .
metrics:
desc: Get Prometheus metrics
vars:
URL: '{{.URL | default "http://localhost:7860"}}'
cmds:
- curl -s {{.URL}}/api/metrics
history:
desc: Get build history
vars:
URL: '{{.URL | default "http://localhost:7860"}}'
cmds:
- curl -s {{.URL}}/api/history | jq .
logs:
desc: Get recent logs
vars:
URL: '{{.URL | default "http://localhost:7860"}}'
cmds:
- curl -s {{.URL}}/api/logs | jq -r '.logs[]'
# Build triggers
build:
desc: Trigger a build via API
vars:
URL: '{{.URL | default "http://localhost:7860"}}'
requires:
vars: [REPO_URL, IMAGE]
cmds:
- |
curl -X POST {{.URL}}/api/build \
-H "Content-Type: application/json" \
-d '{
"repo_url": "{{.REPO_URL}}",
"image_name": "{{.IMAGE}}",
"branch": "{{.BRANCH | default "main"}}",
"tags": ["{{.TAG | default "latest"}}"]
}'
build:cancel:
desc: Cancel a running build
vars:
URL: '{{.URL | default "http://localhost:7860"}}'
requires:
vars: [BUILD_ID]
cmds:
- curl -X POST {{.URL}}/api/build/{{.BUILD_ID}}/cancel
# Webhook testing
webhook:test:
desc: Send a test webhook
vars:
URL: '{{.URL | default "http://localhost:7860"}}'
requires:
vars: [REPO_URL, IMAGE]
cmds:
- |
curl -X POST {{.URL}}/webhook/test \
-H "Content-Type: application/json" \
-d '{
"repo_url": "{{.REPO_URL}}",
"image_name": "{{.IMAGE}}",
"branch": "{{.BRANCH | default "main"}}"
}'
# Dependency management
deps:
desc: Install dependencies
cmds:
- pip install -r requirements.txt
deps:dev:
desc: Install dev dependencies
cmds:
- pip install -r requirements.txt pytest ruff watchdog
check:deps:
desc: Check if dependencies are installed
cmds:
- python -c "import flask; import git; import requests"
silent: true
# Cleanup
clean:
desc: Clean up temporary files
cmds:
- rm -rf __pycache__ .pytest_cache .ruff_cache
- find . -name "*.pyc" -delete
|