Spaces:
Sleeping
Sleeping
| from __future__ import annotations | |
| import json | |
| from fastapi import FastAPI | |
| from fastapi.responses import HTMLResponse | |
| from pydantic import BaseModel | |
| from env.environment import GPUInferenceSchedulingEnv | |
| from env.models import SchedulingAction, SchedulingObservation, SchedulingStepResult | |
| class ResetRequest(BaseModel): | |
| seed: int | None = None | |
| scenario_id: str | None = None | |
| app = FastAPI(title="GPU Inference Scheduling Copilot") | |
| ENV = GPUInferenceSchedulingEnv() | |
| def health() -> dict[str, str]: | |
| return {"status": "ok"} | |
| def reset(request: ResetRequest) -> SchedulingObservation: | |
| return ENV.reset(seed=request.seed, scenario_id=request.scenario_id) | |
| def state() -> SchedulingObservation: | |
| return ENV.state() | |
| def step(action: SchedulingAction) -> SchedulingStepResult: | |
| return ENV.step(action) | |
| def web() -> str: | |
| state_json = json.dumps(ENV.state().model_dump(mode="json"), indent=2) | |
| return f""" | |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>GPU Inference Scheduling Copilot</title> | |
| <style> | |
| :root {{ | |
| --bg: #f4efe4; | |
| --panel: #fffaf0; | |
| --ink: #1f1b16; | |
| --accent: #0d6b5d; | |
| --border: #d5cab7; | |
| }} | |
| body {{ | |
| margin: 0; | |
| font-family: Georgia, "Times New Roman", serif; | |
| background: radial-gradient(circle at top, #fff8ec 0%, var(--bg) 50%, #ebe2d3 100%); | |
| color: var(--ink); | |
| }} | |
| main {{ | |
| max-width: 1100px; | |
| margin: 0 auto; | |
| padding: 32px 20px 48px; | |
| }} | |
| .hero, .panel {{ | |
| background: var(--panel); | |
| border: 1px solid var(--border); | |
| border-radius: 18px; | |
| box-shadow: 0 18px 36px rgba(31,27,22,0.08); | |
| }} | |
| .hero {{ | |
| padding: 24px; | |
| background: linear-gradient(135deg, rgba(13,107,93,0.14), rgba(255,250,240,0.98)); | |
| }} | |
| .grid {{ | |
| display: grid; | |
| grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); | |
| gap: 16px; | |
| margin-top: 20px; | |
| }} | |
| .panel {{ | |
| padding: 18px; | |
| }} | |
| pre {{ | |
| white-space: pre-wrap; | |
| word-break: break-word; | |
| background: #f8f4eb; | |
| padding: 14px; | |
| border-radius: 12px; | |
| border: 1px solid var(--border); | |
| }} | |
| </style> | |
| </head> | |
| <body> | |
| <main> | |
| <section class="hero"> | |
| <h1>GPU Inference Scheduling Copilot</h1> | |
| <p>A contest-first benchmark for VRAM-aware, deadline-aware scheduling decisions.</p> | |
| </section> | |
| <section class="grid"> | |
| <article class="panel"> | |
| <h2>API</h2> | |
| <p>Use <code>/reset</code>, <code>/step</code>, and <code>/state</code> for environment control.</p> | |
| <p>The same reset-step-state loop is what OpenEnv expects at the environment layer.</p> | |
| </article> | |
| <article class="panel"> | |
| <h2>Current State</h2> | |
| <pre>{state_json}</pre> | |
| </article> | |
| </section> | |
| </main> | |
| </body> | |
| </html> | |
| """ | |