Spaces:
Sleeping
Sleeping
File size: 1,930 Bytes
f676206 | 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 | """scripts/hello_space.py - Day-0 deployment-substrate placeholder app.
This is the *minimal* FastAPI app you push to your Hugging Face Space the
night before the hackathon to prove the deployment substrate works:
Step 1: Create a public HF Space called e.g. ``qubit-medic-hello``
Step 2: Push our slim Dockerfile + this file (rename to ``app.py``)
Step 3: Hit ``/healthz`` from your browser -> proves networking works
Step 4: Hit ``/healthz`` from a Colab cell -> proves Colab can reach it
Once all four pass, replace this file with the real env (the real
:mod:`qubit_medic.server.app` already implements the same ``/healthz``
endpoint, so the Day-0 contract carries forward).
Run locally::
python -m scripts.hello_space # listens on :7860
"""
from __future__ import annotations
import os
import sys
import stim
from fastapi import FastAPI
app = FastAPI(
title="Qubit-Medic - Hello Space",
description="Day-0 deployment-substrate placeholder. Proves Stim imports "
"and the HTTP server is reachable. Replace with the real env "
"once Section 2 of the plan passes local validation.",
version="0.0.1-placeholder",
)
@app.get("/")
def root() -> dict:
return {
"service": "qubit-medic-hello",
"status": "placeholder live",
"next": "POST /reset and /step will become available once the real "
"DecoderEnvironment is pushed.",
}
@app.get("/healthz")
def healthz() -> dict:
return {
"ok": True,
"stim_version": stim.__version__,
"python_version": sys.version.split()[0],
"service": "qubit-medic-hello",
}
def _main() -> None:
import uvicorn
uvicorn.run(
"scripts.hello_space:app",
host=os.getenv("HOST", "0.0.0.0"),
port=int(os.getenv("PORT", "7860")),
log_level="info",
)
if __name__ == "__main__":
_main()
|