Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit ·
8d69cc6
1
Parent(s): 2348d3e
feat: add HF Space landing page, revert to 2 reward functions
Browse files- Add HTML landing page at / showing task, constraints, and API docs
- Revert notebook to format + environment reward (env already decomposes
feasibility and objective internally via _compute_reward)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- server/app.py +75 -0
server/app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
|
|
|
| 3 |
from openenv.core import create_fastapi_app
|
| 4 |
|
| 5 |
from fusion_lab.models import StellaratorAction, StellaratorObservation
|
|
@@ -13,6 +14,80 @@ app = create_fastapi_app(
|
|
| 13 |
)
|
| 14 |
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
@app.get("/task")
|
| 17 |
def task_summary() -> dict[str, object]:
|
| 18 |
return {
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
+
from fastapi.responses import HTMLResponse
|
| 4 |
from openenv.core import create_fastapi_app
|
| 5 |
|
| 6 |
from fusion_lab.models import StellaratorAction, StellaratorObservation
|
|
|
|
| 14 |
)
|
| 15 |
|
| 16 |
|
| 17 |
+
@app.get("/", response_class=HTMLResponse)
|
| 18 |
+
def landing_page() -> str:
|
| 19 |
+
return """<!DOCTYPE html>
|
| 20 |
+
<html lang="en">
|
| 21 |
+
<head>
|
| 22 |
+
<meta charset="utf-8">
|
| 23 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 24 |
+
<title>Fusion Design Lab</title>
|
| 25 |
+
<style>
|
| 26 |
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
| 27 |
+
body { font-family: system-ui, -apple-system, sans-serif; background: #0a0e1a; color: #e0e0e0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
|
| 28 |
+
.container { max-width: 720px; padding: 3rem 2rem; }
|
| 29 |
+
h1 { font-size: 2.2rem; font-weight: 700; margin-bottom: 0.5rem; background: linear-gradient(135deg, #60a5fa, #a78bfa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
| 30 |
+
.subtitle { color: #94a3b8; font-size: 1.1rem; margin-bottom: 2rem; }
|
| 31 |
+
.card { background: #141926; border: 1px solid #1e293b; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.2rem; }
|
| 32 |
+
.card h2 { font-size: 1rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.8rem; }
|
| 33 |
+
.constraint { display: flex; justify-content: space-between; padding: 0.3rem 0; border-bottom: 1px solid #1e293b; }
|
| 34 |
+
.constraint:last-child { border: none; }
|
| 35 |
+
.constraint .name { color: #60a5fa; font-family: monospace; }
|
| 36 |
+
.constraint .bound { color: #e0e0e0; font-family: monospace; }
|
| 37 |
+
.endpoints { list-style: none; }
|
| 38 |
+
.endpoints li { padding: 0.4rem 0; }
|
| 39 |
+
.endpoints code { background: #1e293b; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.9rem; color: #a78bfa; }
|
| 40 |
+
.endpoints .method { color: #4ade80; font-weight: 600; font-family: monospace; margin-right: 0.3rem; }
|
| 41 |
+
.meta { display: flex; gap: 2rem; flex-wrap: wrap; }
|
| 42 |
+
.meta-item { flex: 1; min-width: 140px; }
|
| 43 |
+
.meta-item .value { font-size: 1.8rem; font-weight: 700; color: #60a5fa; }
|
| 44 |
+
.meta-item .label { color: #64748b; font-size: 0.85rem; }
|
| 45 |
+
a { color: #a78bfa; text-decoration: none; }
|
| 46 |
+
a:hover { text-decoration: underline; }
|
| 47 |
+
.footer { margin-top: 2rem; color: #475569; font-size: 0.85rem; text-align: center; }
|
| 48 |
+
</style>
|
| 49 |
+
</head>
|
| 50 |
+
<body>
|
| 51 |
+
<div class="container">
|
| 52 |
+
<h1>Fusion Design Lab</h1>
|
| 53 |
+
<p class="subtitle">OpenEnv P1 stellarator optimization environment powered by <code>constellaration</code></p>
|
| 54 |
+
|
| 55 |
+
<div class="card">
|
| 56 |
+
<h2>Task</h2>
|
| 57 |
+
<p style="margin-bottom:1rem;">Minimize <strong>max elongation</strong> of a stellarator boundary using 4 geometric knobs, subject to physics constraints.</p>
|
| 58 |
+
<div class="meta">
|
| 59 |
+
<div class="meta-item"><div class="value">6</div><div class="label">evaluation budget</div></div>
|
| 60 |
+
<div class="meta-item"><div class="value">26</div><div class="label">discrete actions</div></div>
|
| 61 |
+
<div class="meta-item"><div class="value">3</div><div class="label">field periods</div></div>
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
|
| 65 |
+
<div class="card">
|
| 66 |
+
<h2>Constraints</h2>
|
| 67 |
+
<div class="constraint"><span class="name">aspect_ratio</span><span class="bound">≤ 4.0</span></div>
|
| 68 |
+
<div class="constraint"><span class="name">average_triangularity</span><span class="bound">≤ −0.5</span></div>
|
| 69 |
+
<div class="constraint"><span class="name">edge_iota_over_nfp</span><span class="bound">≥ 0.3</span></div>
|
| 70 |
+
</div>
|
| 71 |
+
|
| 72 |
+
<div class="card">
|
| 73 |
+
<h2>API Endpoints</h2>
|
| 74 |
+
<ul class="endpoints">
|
| 75 |
+
<li><span class="method">GET</span> <code>/health</code> — liveness check</li>
|
| 76 |
+
<li><span class="method">GET</span> <code>/task</code> — task specification</li>
|
| 77 |
+
<li><span class="method">POST</span> <code>/reset</code> — start a new episode</li>
|
| 78 |
+
<li><span class="method">POST</span> <code>/step</code> — execute an action</li>
|
| 79 |
+
</ul>
|
| 80 |
+
</div>
|
| 81 |
+
|
| 82 |
+
<div class="footer">
|
| 83 |
+
<a href="https://github.com/jungdaesuh/fusion-design-lab">GitHub</a>
|
| 84 |
+
· OpenEnv Hackathon 2026
|
| 85 |
+
</div>
|
| 86 |
+
</div>
|
| 87 |
+
</body>
|
| 88 |
+
</html>"""
|
| 89 |
+
|
| 90 |
+
|
| 91 |
@app.get("/task")
|
| 92 |
def task_summary() -> dict[str, object]:
|
| 93 |
return {
|