Spaces:
Runtime error
title: Celery Space
emoji: 🐳
colorFrom: blue
colorTo: gray
sdk: docker
app_port: 7860
startup_duration_timeout: 3h
pinned: false
Celery Docker Space
This Space is configured as a Docker-based Hugging Face Space.
The container installs FastAPI, Uvicorn, and websocket-client. app.py is a
small entrypoint; the worker code lives in space_worker/. During ASGI import,
it starts a Supabase Realtime worker thread and then intentionally blocks so the
Space stays in the Starting state instead of binding to port 7860.
The Space also expects the Hugging Face bucket
admincybers2/protexa-model-space to be mounted at /models. The current
instruction model path is /models/protexa_instruction, populated from
admincybers2/protexa_instruction.
Layout
app.py
space_worker/
config.py
http.py
logging_setup.py
messages.py
model_store.py
runtime.py
supabase.py
worker.py
Flow
- Space A connects to Supabase Realtime.
- Space A subscribes to
SUPABASE_SPACE_INBOX_TOPIC, defaultspace-a. - User
ABCsends a broadcast to channelspace-a. - Space A receives the message, builds
Hello ABC, and broadcasts it touser-ABC. - User
ABCreceives the response from their own channel.
Model Bucket
The uploader in this package can mount:
hf://buckets/admincybers2/protexa-model-space:/models
Runtime variables:
MODEL_BUCKET_ID=admincybers2/protexa-model-space
MODEL_BUCKET_MOUNT_PATH=/models
PROTEXA_INSTRUCTION_REPO_ID=admincybers2/protexa_instruction
PROTEXA_INSTRUCTION_MODEL_DIR=/models/protexa_instruction
When the Space starts, space_worker.model_store.ModelStore checks the mount
and logs whether these expected files exist under /models/protexa_instruction:
.gitattributes
README.md
checkpoint_best.pt
instruction_audit.json
metrics_history.jsonl
tokenizer_map.json
train.txt
User Request
The user sends this to channel space-a. By default the worker accepts any
broadcast event name with SUPABASE_REQUEST_EVENTS=*, including the Inspector
default Test message.
{
"user_id": "ABC",
"message": "hello",
"correlation_id": "request_uuid"
}
Space Response
Space A sends this to channel user-ABC, event message:
{
"type": "space.response",
"ok": true,
"user_id": "ABC",
"session_id": null,
"correlation_id": "request_uuid",
"request": {
"message": "hello"
},
"message": "Hello ABC",
"created_at": "2026-06-26T00:00:00+00:00"
}
JavaScript Client Sketch
const userId = 'ABC'
const inbox = supabase.channel('space-a', {
config: { private: true, broadcast: { ack: true } },
})
const replies = supabase.channel(`user-${userId}`, {
config: { private: true },
})
replies.on('broadcast', { event: 'message' }, ({ payload }) => {
console.log(payload.message)
})
await replies.subscribe()
await inbox.subscribe()
await inbox.send({
type: 'broadcast',
event: 'message',
payload: {
user_id: userId,
message: 'hello',
correlation_id: crypto.randomUUID(),
},
})
Private channels require Supabase Realtime authorization policies. For a quick
Realtime Inspector test, you can temporarily set both private flags to false,
then switch them back to true for real users.