evalstate HF Staff commited on
Commit
2a07a4a
·
verified ·
1 Parent(s): e56fa6f

Publish Birch HTML benchmark browser

Browse files
Files changed (3) hide show
  1. Dockerfile +13 -0
  2. README.md +19 -5
  3. app.py +47 -0
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ ENV PYTHONDONTWRITEBYTECODE=1 \
4
+ PYTHONUNBUFFERED=1 \
5
+ SITE_ROOT=/data
6
+
7
+ RUN pip install --no-cache-dir fastapi "uvicorn[standard]"
8
+
9
+ WORKDIR /app
10
+ COPY app.py /app/app.py
11
+
12
+ EXPOSE 7860
13
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -1,10 +1,24 @@
1
  ---
2
- title: Birch Html
3
- emoji: 🏆
4
- colorFrom: gray
5
- colorTo: green
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Birch HTML
3
+ emoji: 🌿
4
+ colorFrom: green
5
+ colorTo: yellow
6
  sdk: docker
7
  pinned: false
8
+ short_description: Birch HTML benchmark browser
9
  ---
10
 
11
+ # Birch HTML Benchmark
12
+
13
+ This Space serves the static Birch HTML benchmark browser from the mounted
14
+ Hugging Face bucket:
15
+
16
+ ```text
17
+ hf://buckets/evalstate/birch-html -> /data
18
+ ```
19
+
20
+ Entry point:
21
+
22
+ ```text
23
+ /analysis/report.html
24
+ ```
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from pathlib import Path
5
+
6
+ from fastapi import FastAPI
7
+ from fastapi.responses import FileResponse, HTMLResponse, RedirectResponse
8
+ from fastapi.staticfiles import StaticFiles
9
+
10
+
11
+ SITE_ROOT = Path(os.environ.get("SITE_ROOT", "/data")).resolve()
12
+ REPORT = SITE_ROOT / "analysis" / "report.html"
13
+
14
+ app = FastAPI(title="Birch HTML Benchmark")
15
+
16
+
17
+ @app.get("/")
18
+ def root():
19
+ if REPORT.exists():
20
+ return RedirectResponse("/analysis/report.html", status_code=302)
21
+ return HTMLResponse(
22
+ "<!doctype html><title>Birch HTML Benchmark</title>"
23
+ "<h1>Birch HTML Benchmark</h1>"
24
+ f"<p>Report not found at <code>{REPORT}</code>. "
25
+ "Check that the bucket is mounted at <code>/data</code>.</p>",
26
+ status_code=503,
27
+ )
28
+
29
+
30
+ @app.get("/healthz")
31
+ def healthz():
32
+ return {
33
+ "ok": REPORT.exists(),
34
+ "site_root": str(SITE_ROOT),
35
+ "report": str(REPORT),
36
+ }
37
+
38
+
39
+ @app.get("/analysis/report.html")
40
+ def report():
41
+ if REPORT.exists():
42
+ return FileResponse(REPORT)
43
+ return root()
44
+
45
+
46
+ if SITE_ROOT.exists():
47
+ app.mount("/", StaticFiles(directory=SITE_ROOT, html=True), name="site")