Spaces:
Sleeping
Sleeping
Commit Β·
30596cf
1
Parent(s): 4bb4bff
feat: unified full-stack architecture (React + FastAPI + Docker)
Browse files- Dockerfile +15 -1
- README.md +21 -1
- pyproject.toml +10 -0
- server/app.py +136 -20
- training.ipynb +774 -0
- uv.lock +0 -0
Dockerfile
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim AS runtime
|
| 2 |
|
| 3 |
ENV PYTHONUNBUFFERED=1 \
|
|
@@ -7,7 +16,11 @@ ENV PYTHONUNBUFFERED=1 \
|
|
| 7 |
|
| 8 |
WORKDIR /app
|
| 9 |
|
|
|
|
| 10 |
COPY pyproject.toml uv.lock README.md ./
|
|
|
|
|
|
|
|
|
|
| 11 |
COPY agents ./agents
|
| 12 |
COPY core ./core
|
| 13 |
COPY evaluation ./evaluation
|
|
@@ -17,7 +30,8 @@ COPY telemetry ./telemetry
|
|
| 17 |
COPY training ./training
|
| 18 |
COPY client.py openenv.yaml ./
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
EXPOSE 8000
|
| 23 |
|
|
|
|
| 1 |
+
# --- STAGE 1: Build the React Visualizer ---
|
| 2 |
+
FROM node:20-slim AS frontend-builder
|
| 3 |
+
WORKDIR /build
|
| 4 |
+
COPY visualizer/package*.json ./
|
| 5 |
+
RUN npm install
|
| 6 |
+
COPY visualizer/ ./
|
| 7 |
+
RUN npm run build
|
| 8 |
+
|
| 9 |
+
# --- STAGE 2: Python Runtime ---
|
| 10 |
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim AS runtime
|
| 11 |
|
| 12 |
ENV PYTHONUNBUFFERED=1 \
|
|
|
|
| 16 |
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
+
# Copy python dependency files
|
| 20 |
COPY pyproject.toml uv.lock README.md ./
|
| 21 |
+
RUN uv sync --frozen --no-dev
|
| 22 |
+
|
| 23 |
+
# Copy the game engine and server code
|
| 24 |
COPY agents ./agents
|
| 25 |
COPY core ./core
|
| 26 |
COPY evaluation ./evaluation
|
|
|
|
| 30 |
COPY training ./training
|
| 31 |
COPY client.py openenv.yaml ./
|
| 32 |
|
| 33 |
+
# Copy the compiled React assets from Stage 1
|
| 34 |
+
COPY --from=frontend-builder /build/dist ./visualizer/dist
|
| 35 |
|
| 36 |
EXPOSE 8000
|
| 37 |
|
README.md
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Nation Optimizer RL
|
| 2 |
|
| 3 |
> A centralized planning environment where LLMs learn resource allocation through structured parliamentary reasoning. Inspired by the Marxist principle: *"From each according to his ability, to each according to his need."*
|
| 4 |
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
## Overview
|
| 8 |
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Nation Optimizer RL
|
| 3 |
+
emoji: ποΈ
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_file: server/app.py
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
# Nation Optimizer RL
|
| 12 |
|
| 13 |
> A centralized planning environment where LLMs learn resource allocation through structured parliamentary reasoning. Inspired by the Marxist principle: *"From each according to his ability, to each according to his need."*
|
| 14 |
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
### π Submission Quick-Links
|
| 18 |
+
* **π Hugging Face Space**: [Nation Optimizer Spectator Dashboard](https://huggingface.co/spaces/Kr0issant/nation-optimizer-rl)
|
| 19 |
+
* **π Training Notebook**: [Open in Colab (training.ipynb)](https://colab.research.google.com/github/Kr0issant/communism-optimizer-rl/blob/main/training.ipynb)
|
| 20 |
+
* **π Training Evidence**: [Reward & Loss Curves](assets/results/)
|
| 21 |
+
* **π½οΈ Project Presentation**: [YouTube Video / Blog Post Placeholder](https://huggingface.co/blog/your-username/nation-optimizer)
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+

|
| 26 |
|
| 27 |
## Overview
|
| 28 |
|
pyproject.toml
CHANGED
|
@@ -11,6 +11,16 @@ dependencies = [
|
|
| 11 |
"python-dotenv>=1.2.2",
|
| 12 |
"fastapi>=0.104.0",
|
| 13 |
"uvicorn[standard]>=0.24.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
]
|
| 15 |
|
| 16 |
[project.optional-dependencies]
|
|
|
|
| 11 |
"python-dotenv>=1.2.2",
|
| 12 |
"fastapi>=0.104.0",
|
| 13 |
"uvicorn[standard]>=0.24.0",
|
| 14 |
+
"unsloth>=2026.4.8",
|
| 15 |
+
"trl>=0.24.0",
|
| 16 |
+
"peft>=0.19.1",
|
| 17 |
+
"transformers>=5.5.0",
|
| 18 |
+
"accelerate>=1.13.0",
|
| 19 |
+
"datasets>=4.3.0",
|
| 20 |
+
"trackio>=0.25.0",
|
| 21 |
+
"matplotlib>=3.10.9",
|
| 22 |
+
"seaborn>=0.13.2",
|
| 23 |
+
"gradio>=4.19.2",
|
| 24 |
]
|
| 25 |
|
| 26 |
[project.optional-dependencies]
|
server/app.py
CHANGED
|
@@ -1,38 +1,154 @@
|
|
| 1 |
-
"""
|
| 2 |
-
|
| 3 |
-
from __future__ import annotations
|
| 4 |
|
| 5 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
from .environment import DEFAULT_ENV_NAME, NationOpenEnv
|
| 14 |
-
from .models import NationAction, NationObservation
|
| 15 |
-
except ImportError: # pragma: no cover - supports Docker PYTHONPATH=/app
|
| 16 |
-
from server.environment import DEFAULT_ENV_NAME, NationOpenEnv
|
| 17 |
-
from server.models import NationAction, NationObservation
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
|
|
|
| 22 |
app = create_app(
|
| 23 |
NationOpenEnv,
|
| 24 |
NationAction,
|
| 25 |
NationObservation,
|
| 26 |
env_name=DEFAULT_ENV_NAME,
|
| 27 |
-
max_concurrent_envs=MAX_CONCURRENT_ENVS,
|
| 28 |
)
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
-
|
|
|
|
|
|
| 1 |
+
"""Final Unified Server: OpenEnv API + React Visualizer + Live Streaming."""
|
|
|
|
|
|
|
| 2 |
|
| 3 |
import os
|
| 4 |
+
import json
|
| 5 |
+
import time
|
| 6 |
+
import logging
|
| 7 |
+
import asyncio
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
from typing import Any, Optional
|
| 10 |
|
| 11 |
+
from dotenv import load_dotenv
|
| 12 |
+
from fastapi import FastAPI, HTTPException, Request
|
| 13 |
+
from fastapi.staticfiles import StaticFiles
|
| 14 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 15 |
+
from fastapi.responses import StreamingResponse
|
| 16 |
+
from openenv.core.env_server import create_app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
# Import core environment and visualizer logic
|
| 19 |
+
from server.environment import DEFAULT_ENV_NAME, NationOpenEnv
|
| 20 |
+
from server.models import NationAction, NationObservation
|
| 21 |
+
from server.live_runner import LiveRun, LiveRunManager, build_config_dict
|
| 22 |
+
from server.visualizer_server import StartRunBody, StartRunResponse, _RULE_BASED_MODES, _llm_mode_entry, _json_default
|
| 23 |
|
| 24 |
+
load_dotenv()
|
| 25 |
+
LOG = logging.getLogger(__name__)
|
| 26 |
|
| 27 |
+
# --- 1. INITIALIZE OPENENV CORE ---
|
| 28 |
app = create_app(
|
| 29 |
NationOpenEnv,
|
| 30 |
NationAction,
|
| 31 |
NationObservation,
|
| 32 |
env_name=DEFAULT_ENV_NAME,
|
| 33 |
+
max_concurrent_envs=int(os.getenv("MAX_CONCURRENT_ENVS", "4")),
|
| 34 |
)
|
| 35 |
|
| 36 |
+
# Add CORS for local development
|
| 37 |
+
app.add_middleware(
|
| 38 |
+
CORSMiddleware,
|
| 39 |
+
allow_origins=["*"],
|
| 40 |
+
allow_methods=["*"],
|
| 41 |
+
allow_headers=["*"],
|
| 42 |
+
)
|
| 43 |
|
| 44 |
+
# --- 2. INITIALIZE VISUALIZER MANAGER ---
|
| 45 |
+
manager = LiveRunManager()
|
| 46 |
|
| 47 |
+
# --- 3. VISUALIZER API ROUTES (/api/*) ---
|
| 48 |
+
|
| 49 |
+
@app.get("/api/health")
|
| 50 |
+
def health() -> dict[str, Any]:
|
| 51 |
+
return {"ok": True, "ts": time.time()}
|
| 52 |
+
|
| 53 |
+
@app.get("/api/config")
|
| 54 |
+
def config() -> dict[str, Any]:
|
| 55 |
+
return build_config_dict()
|
| 56 |
+
|
| 57 |
+
@app.get("/api/modes")
|
| 58 |
+
def modes() -> dict[str, Any]:
|
| 59 |
+
return {"modes": [_llm_mode_entry(), *_RULE_BASED_MODES]}
|
| 60 |
+
|
| 61 |
+
@app.get("/api/runs")
|
| 62 |
+
def list_runs() -> dict[str, Any]:
|
| 63 |
+
return {"runs": manager.list_runs()}
|
| 64 |
+
|
| 65 |
+
@app.post("/api/runs", response_model=StartRunResponse)
|
| 66 |
+
def start_run(body: StartRunBody) -> StartRunResponse:
|
| 67 |
+
if body.mode == "llm":
|
| 68 |
+
token = os.environ.get("HF_TOKEN")
|
| 69 |
+
if not token:
|
| 70 |
+
raise HTTPException(status_code=400, detail="LLM mode requires HF_TOKEN.")
|
| 71 |
+
model_id = body.model_id or os.environ.get("HF_MODEL_ID")
|
| 72 |
+
else:
|
| 73 |
+
token = None
|
| 74 |
+
model_id = body.model_id
|
| 75 |
|
| 76 |
+
try:
|
| 77 |
+
run = manager.create(
|
| 78 |
+
mode=body.mode,
|
| 79 |
+
model_id=model_id,
|
| 80 |
+
seed=body.seed,
|
| 81 |
+
max_rounds=body.max_rounds,
|
| 82 |
+
temperature=body.temperature,
|
| 83 |
+
token=token,
|
| 84 |
+
)
|
| 85 |
+
return StartRunResponse(
|
| 86 |
+
run_id=run.run_id,
|
| 87 |
+
mode=run.mode,
|
| 88 |
+
policy=run.policy,
|
| 89 |
+
seed=run.seed,
|
| 90 |
+
max_rounds=run.max_rounds,
|
| 91 |
+
config=run.config,
|
| 92 |
+
)
|
| 93 |
+
except ValueError as exc:
|
| 94 |
+
raise HTTPException(status_code=400, detail=str(exc))
|
| 95 |
+
|
| 96 |
+
@app.get("/api/runs/{run_id}/snapshot")
|
| 97 |
+
def snapshot(run_id: str) -> dict[str, Any]:
|
| 98 |
+
run = manager.get(run_id)
|
| 99 |
+
if run is None:
|
| 100 |
+
raise HTTPException(status_code=404, detail=f"Unknown run {run_id}")
|
| 101 |
+
return run.snapshot()
|
| 102 |
+
|
| 103 |
+
@app.get("/api/runs/{run_id}/stream")
|
| 104 |
+
async def stream(run_id: str, request: Request) -> StreamingResponse:
|
| 105 |
+
run = manager.get(run_id)
|
| 106 |
+
if run is None:
|
| 107 |
+
raise HTTPException(status_code=404, detail=f"Unknown run {run_id}")
|
| 108 |
+
|
| 109 |
+
async def _sse_iterator():
|
| 110 |
+
queue = run.subscribe()
|
| 111 |
+
try:
|
| 112 |
+
last_heartbeat = time.time()
|
| 113 |
+
while True:
|
| 114 |
+
if await request.is_disconnected():
|
| 115 |
+
break
|
| 116 |
+
|
| 117 |
+
# Drain queue (non-blocking in executor)
|
| 118 |
+
event = await asyncio.get_event_loop().run_in_executor(
|
| 119 |
+
None, lambda: (None if queue.empty() else queue.get())
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
if event is not None:
|
| 123 |
+
event_type = event.get("type", "message")
|
| 124 |
+
payload = event.get("data", {})
|
| 125 |
+
body = json.dumps(payload, default=_json_default)
|
| 126 |
+
yield f"event: {event_type}\ndata: {body}\n\n"
|
| 127 |
+
if event_type == "done":
|
| 128 |
+
break
|
| 129 |
+
continue
|
| 130 |
+
|
| 131 |
+
if time.time() - last_heartbeat > 15:
|
| 132 |
+
yield ": keep-alive\n\n"
|
| 133 |
+
last_heartbeat = time.time()
|
| 134 |
+
await asyncio.sleep(0.1)
|
| 135 |
+
finally:
|
| 136 |
+
run.unsubscribe(queue)
|
| 137 |
+
|
| 138 |
+
return StreamingResponse(
|
| 139 |
+
_sse_iterator(),
|
| 140 |
+
media_type="text/event-stream",
|
| 141 |
+
headers={"Cache-Control": "no-cache", "Connection": "keep-alive"},
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
# --- 4. STATIC FRONTEND MOUNTING ---
|
| 145 |
+
dist_path = Path(__file__).parent.parent / "visualizer" / "dist"
|
| 146 |
+
if dist_path.exists():
|
| 147 |
+
app.mount("/", StaticFiles(directory=str(dist_path), html=True), name="visualizer")
|
| 148 |
+
LOG.info(f"βοΈ React Visualizer mounted from {dist_path}")
|
| 149 |
+
else:
|
| 150 |
+
LOG.warning(f"β οΈ Visualizer build not found at {dist_path}")
|
| 151 |
|
| 152 |
if __name__ == "__main__":
|
| 153 |
+
import uvicorn
|
| 154 |
+
uvicorn.run(app, host="0.0.0.0", port=int(os.getenv("PORT", "8000")))
|
training.ipynb
ADDED
|
@@ -0,0 +1,774 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"metadata": {},
|
| 6 |
+
"source": [
|
| 7 |
+
"# ποΈ Nation Optimizer: Parliamentary GRPO Training\n",
|
| 8 |
+
"\n",
|
| 9 |
+
"Welcome to the central command center for the **Communism Simulator** RL pipeline. This notebook manages the entire lifecycle of our parliamentary agentsβfrom synthesizing historical datasets to fine-tuning with **GRPO** and benchmarking the resulting model.\n",
|
| 10 |
+
"\n",
|
| 11 |
+
"## πΊοΈ Roadmap\n",
|
| 12 |
+
"1. **Part 1**: Environment Setup & Secrets\n",
|
| 13 |
+
"2. **Part 2**: Dataset Synthesis (Golden Path)\n",
|
| 14 |
+
"3. **Part 3**: Interactive Reward Debugger\n",
|
| 15 |
+
"4. **Part 4**: Local Smoke Test\n",
|
| 16 |
+
"5. **Part 5**: Hugging Face Jobs Dispatcher\n",
|
| 17 |
+
"6. **Part 6**: Remote Telemetry\n",
|
| 18 |
+
"7. **Part 7**: Model Artifact Retrieval\n",
|
| 19 |
+
"8. **Part 8**: The Grand Simulation\n",
|
| 20 |
+
"9. **Part 9**: Benchmarking & Visualization\n",
|
| 21 |
+
"10. **Part 10**: Final Report Export"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"cell_type": "markdown",
|
| 26 |
+
"metadata": {},
|
| 27 |
+
"source": [
|
| 28 |
+
"## Part 1: Environment Setup & Secrets\n",
|
| 29 |
+
"\n",
|
| 30 |
+
"We need to ensure all dependencies are installed and the simulator's core packages are in our Python path."
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"cell_type": "code",
|
| 35 |
+
"execution_count": null,
|
| 36 |
+
"metadata": {},
|
| 37 |
+
"outputs": [
|
| 38 |
+
{
|
| 39 |
+
"name": "stdout",
|
| 40 |
+
"output_type": "stream",
|
| 41 |
+
"text": [
|
| 42 |
+
"Project root added: C:\\Scaler School of Technology\\Communism Simulator\\communism-optimizer-rl\n",
|
| 43 |
+
"HF_TOKEN found: True\n"
|
| 44 |
+
]
|
| 45 |
+
},
|
| 46 |
+
{
|
| 47 |
+
"name": "stderr",
|
| 48 |
+
"output_type": "stream",
|
| 49 |
+
"text": [
|
| 50 |
+
"ERROR: Exception:ERROR: Exception:\n",
|
| 51 |
+
"Traceback (most recent call last):\n",
|
| 52 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 438, in _error_catcher\n",
|
| 53 |
+
" yield\n",
|
| 54 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 561, in read\n",
|
| 55 |
+
" data = self._fp_read(amt) if not fp_closed else b\"\"\n",
|
| 56 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 57 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 527, in _fp_read\n",
|
| 58 |
+
" return self._fp.read(amt) if amt is not None else self._fp.read()\n",
|
| 59 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 60 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\cachecontrol\\filewrapper.py\", line 100, in read\n",
|
| 61 |
+
" data: bytes = self.__fp.read(amt)\n",
|
| 62 |
+
" ~~~~~~~~~~~~~~^^^^^\n",
|
| 63 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\http\\client.py\", line 484, in read\n",
|
| 64 |
+
" s = self.fp.read(amt)\n",
|
| 65 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\socket.py\", line 719, in readinto\n",
|
| 66 |
+
" return self._sock.recv_into(b)\n",
|
| 67 |
+
" ~~~~~~~~~~~~~~~~~~~~^^^\n",
|
| 68 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1304, in recv_into\n",
|
| 69 |
+
" return self.read(nbytes, buffer)\n",
|
| 70 |
+
" ~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 71 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1138, in read\n",
|
| 72 |
+
" return self._sslobj.read(len, buffer)\n",
|
| 73 |
+
" ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^\n",
|
| 74 |
+
"ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\n",
|
| 75 |
+
"\n",
|
| 76 |
+
"During handling of the above exception, another exception occurred:\n",
|
| 77 |
+
"\n",
|
| 78 |
+
"Traceback (most recent call last):\n",
|
| 79 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 107, in _run_wrapper\n",
|
| 80 |
+
" status = _inner_run()\n",
|
| 81 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 98, in _inner_run\n",
|
| 82 |
+
" return self.run(options, args)\n",
|
| 83 |
+
" ~~~~~~~~^^^^^^^^^^^^^^^\n",
|
| 84 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\req_command.py\", line 96, in wrapper\n",
|
| 85 |
+
" return func(self, options, args)\n",
|
| 86 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\commands\\install.py\", line 419, in run\n",
|
| 87 |
+
" preparer.prepare_linked_requirements_more(\n",
|
| 88 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 89 |
+
" requirement_set.requirements.values()\n",
|
| 90 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 91 |
+
" )\n",
|
| 92 |
+
" ^\n",
|
| 93 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 569, in prepare_linked_requirements_more\n",
|
| 94 |
+
" self._complete_partial_requirements(\n",
|
| 95 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 96 |
+
" partially_downloaded_reqs,\n",
|
| 97 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 98 |
+
" parallel_builds=parallel_builds,\n",
|
| 99 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 100 |
+
" )\n",
|
| 101 |
+
" ^\n",
|
| 102 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 478, in _complete_partial_requirements\n",
|
| 103 |
+
" for link, (filepath, _) in batch_download:\n",
|
| 104 |
+
" ^^^^^^^^^^^^^^\n",
|
| 105 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 183, in batch\n",
|
| 106 |
+
" filepath, content_type = self(link, location)\n",
|
| 107 |
+
" ~~~~^^^^^^^^^^^^^^^^\n",
|
| 108 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 194, in __call__\n",
|
| 109 |
+
" self._process_response(download, resp)\n",
|
| 110 |
+
" ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 111 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 211, in _process_response\n",
|
| 112 |
+
" for chunk in chunks:\n",
|
| 113 |
+
" ^^^^^^\n",
|
| 114 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\utils.py\", line 65, in response_chunks\n",
|
| 115 |
+
" for chunk in response.raw.stream(\n",
|
| 116 |
+
" ~~~~~~~~~~~~~~~~~~~^\n",
|
| 117 |
+
" chunk_size,\n",
|
| 118 |
+
" ^^^^^^^^^^^\n",
|
| 119 |
+
" ...<22 lines>...\n",
|
| 120 |
+
" decode_content=False,\n",
|
| 121 |
+
" ^^^^^^^^^^^^^^^^^^^^^\n",
|
| 122 |
+
" ):\n",
|
| 123 |
+
" ^\n",
|
| 124 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 622, in stream\n",
|
| 125 |
+
" data = self.read(amt=amt, decode_content=decode_content)\n",
|
| 126 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 560, in read\n",
|
| 127 |
+
" with self._error_catcher():\n",
|
| 128 |
+
" ~~~~~~~~~~~~~~~~~~~^^\n",
|
| 129 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\contextlib.py\", line 162, in __exit__\n",
|
| 130 |
+
" self.gen.throw(value)\n",
|
| 131 |
+
" ~~~~~~~~~~~~~~^^^^^^^\n",
|
| 132 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 455, in _error_catcher\n",
|
| 133 |
+
" raise ProtocolError(\"Connection broken: %r\" % e, e)\n",
|
| 134 |
+
"pip._vendor.urllib3.exceptions.ProtocolError: (\"Connection broken: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)\", ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))\n",
|
| 135 |
+
"\n",
|
| 136 |
+
"Traceback (most recent call last):\n",
|
| 137 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 438, in _error_catcher\n",
|
| 138 |
+
" yield\n",
|
| 139 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 561, in read\n",
|
| 140 |
+
" data = self._fp_read(amt) if not fp_closed else b\"\"\n",
|
| 141 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 142 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 527, in _fp_read\n",
|
| 143 |
+
" return self._fp.read(amt) if amt is not None else self._fp.read()\n",
|
| 144 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 145 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\cachecontrol\\filewrapper.py\", line 100, in read\n",
|
| 146 |
+
" data: bytes = self.__fp.read(amt)\n",
|
| 147 |
+
" ~~~~~~~~~~~~~~^^^^^\n",
|
| 148 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\http\\client.py\", line 484, in read\n",
|
| 149 |
+
" s = self.fp.read(amt)\n",
|
| 150 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\socket.py\", line 719, in readinto\n",
|
| 151 |
+
" return self._sock.recv_into(b)\n",
|
| 152 |
+
" ~~~~~~~~~~~~~~~~~~~~^^^\n",
|
| 153 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1304, in recv_into\n",
|
| 154 |
+
" return self.read(nbytes, buffer)\n",
|
| 155 |
+
" ~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 156 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1138, in read\n",
|
| 157 |
+
" return self._sslobj.read(len, buffer)\n",
|
| 158 |
+
" ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^\n",
|
| 159 |
+
"ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\n",
|
| 160 |
+
"\n",
|
| 161 |
+
"During handling of the above exception, another exception occurred:\n",
|
| 162 |
+
"\n",
|
| 163 |
+
"Traceback (most recent call last):\n",
|
| 164 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 107, in _run_wrapper\n",
|
| 165 |
+
" status = _inner_run()\n",
|
| 166 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 98, in _inner_run\n",
|
| 167 |
+
" return self.run(options, args)\n",
|
| 168 |
+
" ~~~~~~~~^^^^^^^^^^^^^^^\n",
|
| 169 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\req_command.py\", line 96, in wrapper\n",
|
| 170 |
+
" return func(self, options, args)\n",
|
| 171 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\commands\\install.py\", line 419, in run\n",
|
| 172 |
+
" preparer.prepare_linked_requirements_more(\n",
|
| 173 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 174 |
+
" requirement_set.requirements.values()\n",
|
| 175 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 176 |
+
" )\n",
|
| 177 |
+
" ^\n",
|
| 178 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 569, in prepare_linked_requirements_more\n",
|
| 179 |
+
" self._complete_partial_requirements(\n",
|
| 180 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 181 |
+
" partially_downloaded_reqs,\n",
|
| 182 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 183 |
+
" parallel_builds=parallel_builds,\n",
|
| 184 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 185 |
+
" )\n",
|
| 186 |
+
" ^\n",
|
| 187 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 478, in _complete_partial_requirements\n",
|
| 188 |
+
" for link, (filepath, _) in batch_download:\n",
|
| 189 |
+
" ^^^^^^^^^^^^^^\n",
|
| 190 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 183, in batch\n",
|
| 191 |
+
" filepath, content_type = self(link, location)\n",
|
| 192 |
+
" ~~~~^^^^^^^^^^^^^^^^\n",
|
| 193 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 194, in __call__\n",
|
| 194 |
+
" self._process_response(download, resp)\n",
|
| 195 |
+
" ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 196 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 211, in _process_response\n",
|
| 197 |
+
" for chunk in chunks:\n",
|
| 198 |
+
" ^^^^^^\n",
|
| 199 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\utils.py\", line 65, in response_chunks\n",
|
| 200 |
+
" for chunk in response.raw.stream(\n",
|
| 201 |
+
" ~~~~~~~~~~~~~~~~~~~^\n",
|
| 202 |
+
" chunk_size,\n",
|
| 203 |
+
" ^^^^^^^^^^^\n",
|
| 204 |
+
" ...<22 lines>...\n",
|
| 205 |
+
" decode_content=False,\n",
|
| 206 |
+
" ^^^^^^^^^^^^^^^^^^^^^\n",
|
| 207 |
+
" ):\n",
|
| 208 |
+
" ^\n",
|
| 209 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 622, in stream\n",
|
| 210 |
+
" data = self.read(amt=amt, decode_content=decode_content)\n",
|
| 211 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 560, in read\n",
|
| 212 |
+
" with self._error_catcher():\n",
|
| 213 |
+
" ~~~~~~~~~~~~~~~~~~~^^\n",
|
| 214 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\contextlib.py\", line 162, in __exit__\n",
|
| 215 |
+
" self.gen.throw(value)\n",
|
| 216 |
+
" ~~~~~~~~~~~~~~^^^^^^^\n",
|
| 217 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 455, in _error_catcher\n",
|
| 218 |
+
" raise ProtocolError(\"Connection broken: %r\" % e, e)\n",
|
| 219 |
+
"pip._vendor.urllib3.exceptions.ProtocolError: (\"Connection broken: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)\", ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))\n",
|
| 220 |
+
"ERROR: Exception:\n",
|
| 221 |
+
"Traceback (most recent call last):\n",
|
| 222 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 438, in _error_catcher\n",
|
| 223 |
+
" yield\n",
|
| 224 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 561, in read\n",
|
| 225 |
+
" data = self._fp_read(amt) if not fp_closed else b\"\"\n",
|
| 226 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 227 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 527, in _fp_read\n",
|
| 228 |
+
" return self._fp.read(amt) if amt is not None else self._fp.read()\n",
|
| 229 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 230 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\cachecontrol\\filewrapper.py\", line 100, in read\n",
|
| 231 |
+
" data: bytes = self.__fp.read(amt)\n",
|
| 232 |
+
" ~~~~~~~~~~~~~~^^^^^\n",
|
| 233 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\http\\client.py\", line 484, in read\n",
|
| 234 |
+
" s = self.fp.read(amt)\n",
|
| 235 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\socket.py\", line 719, in readinto\n",
|
| 236 |
+
" return self._sock.recv_into(b)\n",
|
| 237 |
+
" ~~~~~~~~~~~~~~~~~~~~^^^\n",
|
| 238 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1304, in recv_into\n",
|
| 239 |
+
" return self.read(nbytes, buffer)\n",
|
| 240 |
+
" ~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 241 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1138, in read\n",
|
| 242 |
+
" return self._sslobj.read(len, buffer)\n",
|
| 243 |
+
" ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^\n",
|
| 244 |
+
"ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\n",
|
| 245 |
+
"\n",
|
| 246 |
+
"During handling of the above exception, another exception occurred:\n",
|
| 247 |
+
"\n",
|
| 248 |
+
"Traceback (most recent call last):\n",
|
| 249 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 107, in _run_wrapper\n",
|
| 250 |
+
" status = _inner_run()\n",
|
| 251 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 98, in _inner_run\n",
|
| 252 |
+
" return self.run(options, args)\n",
|
| 253 |
+
" ~~~~~~~~^^^^^^^^^^^^^^^\n",
|
| 254 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\req_command.py\", line 96, in wrapper\n",
|
| 255 |
+
" return func(self, options, args)\n",
|
| 256 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\commands\\install.py\", line 419, in run\n",
|
| 257 |
+
" preparer.prepare_linked_requirements_more(\n",
|
| 258 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 259 |
+
" requirement_set.requirements.values()\n",
|
| 260 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 261 |
+
" )\n",
|
| 262 |
+
" ^\n",
|
| 263 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 569, in prepare_linked_requirements_more\n",
|
| 264 |
+
" self._complete_partial_requirements(\n",
|
| 265 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 266 |
+
" partially_downloaded_reqs,\n",
|
| 267 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 268 |
+
" parallel_builds=parallel_builds,\n",
|
| 269 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 270 |
+
" )\n",
|
| 271 |
+
" ^\n",
|
| 272 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 478, in _complete_partial_requirements\n",
|
| 273 |
+
" for link, (filepath, _) in batch_download:\n",
|
| 274 |
+
" ^^^^^^^^^^^^^^\n",
|
| 275 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 183, in batch\n",
|
| 276 |
+
" filepath, content_type = self(link, location)\n",
|
| 277 |
+
" ~~~~^^^^^^^^^^^^^^^^\n",
|
| 278 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 194, in __call__\n",
|
| 279 |
+
" self._process_response(download, resp)\n",
|
| 280 |
+
" ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 281 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 211, in _process_response\n",
|
| 282 |
+
" for chunk in chunks:\n",
|
| 283 |
+
" ^^^^^^\n",
|
| 284 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\utils.py\", line 65, in response_chunks\n",
|
| 285 |
+
" for chunk in response.raw.stream(\n",
|
| 286 |
+
" ~~~~~~~~~~~~~~~~~~~^\n",
|
| 287 |
+
" chunk_size,\n",
|
| 288 |
+
" ^^^^^^^^^^^\n",
|
| 289 |
+
" ...<22 lines>...\n",
|
| 290 |
+
" decode_content=False,\n",
|
| 291 |
+
" ^^^^^^^^^^^^^^^^^^^^^\n",
|
| 292 |
+
" ):\n",
|
| 293 |
+
" ^\n",
|
| 294 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 622, in stream\n",
|
| 295 |
+
" data = self.read(amt=amt, decode_content=decode_content)\n",
|
| 296 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 560, in read\n",
|
| 297 |
+
" with self._error_catcher():\n",
|
| 298 |
+
" ~~~~~~~~~~~~~~~~~~~^^\n",
|
| 299 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\contextlib.py\", line 162, in __exit__\n",
|
| 300 |
+
" self.gen.throw(value)\n",
|
| 301 |
+
" ~~~~~~~~~~~~~~^^^^^^^\n",
|
| 302 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 455, in _error_catcher\n",
|
| 303 |
+
" raise ProtocolError(\"Connection broken: %r\" % e, e)\n",
|
| 304 |
+
"pip._vendor.urllib3.exceptions.ProtocolError: (\"Connection broken: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)\", ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))\n",
|
| 305 |
+
"ERROR: Exception:\n",
|
| 306 |
+
"Traceback (most recent call last):\n",
|
| 307 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 438, in _error_catcher\n",
|
| 308 |
+
" yield\n",
|
| 309 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 561, in read\n",
|
| 310 |
+
" data = self._fp_read(amt) if not fp_closed else b\"\"\n",
|
| 311 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 312 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 527, in _fp_read\n",
|
| 313 |
+
" return self._fp.read(amt) if amt is not None else self._fp.read()\n",
|
| 314 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 315 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\cachecontrol\\filewrapper.py\", line 100, in read\n",
|
| 316 |
+
" data: bytes = self.__fp.read(amt)\n",
|
| 317 |
+
" ~~~~~~~~~~~~~~^^^^^\n",
|
| 318 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\http\\client.py\", line 484, in read\n",
|
| 319 |
+
" s = self.fp.read(amt)\n",
|
| 320 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\socket.py\", line 719, in readinto\n",
|
| 321 |
+
" return self._sock.recv_into(b)\n",
|
| 322 |
+
" ~~~~~~~~~~~~~~~~~~~~^^^\n",
|
| 323 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1304, in recv_into\n",
|
| 324 |
+
" return self.read(nbytes, buffer)\n",
|
| 325 |
+
" ~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 326 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1138, in read\n",
|
| 327 |
+
" return self._sslobj.read(len, buffer)\n",
|
| 328 |
+
" ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^\n",
|
| 329 |
+
"ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\n",
|
| 330 |
+
"\n",
|
| 331 |
+
"During handling of the above exception, another exception occurred:\n",
|
| 332 |
+
"\n",
|
| 333 |
+
"Traceback (most recent call last):\n",
|
| 334 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 107, in _run_wrapper\n",
|
| 335 |
+
" status = _inner_run()\n",
|
| 336 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 98, in _inner_run\n",
|
| 337 |
+
" return self.run(options, args)\n",
|
| 338 |
+
" ~~~~~~~~^^^^^^^^^^^^^^^\n",
|
| 339 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\req_command.py\", line 96, in wrapper\n",
|
| 340 |
+
" return func(self, options, args)\n",
|
| 341 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\commands\\install.py\", line 419, in run\n",
|
| 342 |
+
" preparer.prepare_linked_requirements_more(\n",
|
| 343 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 344 |
+
" requirement_set.requirements.values()\n",
|
| 345 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 346 |
+
" )\n",
|
| 347 |
+
" ^\n",
|
| 348 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 569, in prepare_linked_requirements_more\n",
|
| 349 |
+
" self._complete_partial_requirements(\n",
|
| 350 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 351 |
+
" partially_downloaded_reqs,\n",
|
| 352 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 353 |
+
" parallel_builds=parallel_builds,\n",
|
| 354 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 355 |
+
" )\n",
|
| 356 |
+
" ^\n",
|
| 357 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 478, in _complete_partial_requirements\n",
|
| 358 |
+
" for link, (filepath, _) in batch_download:\n",
|
| 359 |
+
" ^^^^^^^^^^^^^^\n",
|
| 360 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 183, in batch\n",
|
| 361 |
+
" filepath, content_type = self(link, location)\n",
|
| 362 |
+
" ~~~~^^^^^^^^^^^^^^^^\n",
|
| 363 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 194, in __call__\n",
|
| 364 |
+
" self._process_response(download, resp)\n",
|
| 365 |
+
" ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 366 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 211, in _process_response\n",
|
| 367 |
+
" for chunk in chunks:\n",
|
| 368 |
+
" ^^^^^^\n",
|
| 369 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\utils.py\", line 65, in response_chunks\n",
|
| 370 |
+
" for chunk in response.raw.stream(\n",
|
| 371 |
+
" ~~~~~~~~~~~~~~~~~~~^\n",
|
| 372 |
+
" chunk_size,\n",
|
| 373 |
+
" ^^^^^^^^^^^\n",
|
| 374 |
+
" ...<22 lines>...\n",
|
| 375 |
+
" decode_content=False,\n",
|
| 376 |
+
" ^^^^^^^^^^^^^^^^^^^^^\n",
|
| 377 |
+
" ):\n",
|
| 378 |
+
" ^\n",
|
| 379 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 622, in stream\n",
|
| 380 |
+
" data = self.read(amt=amt, decode_content=decode_content)\n",
|
| 381 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 560, in read\n",
|
| 382 |
+
" with self._error_catcher():\n",
|
| 383 |
+
" ~~~~~~~~~~~~~~~~~~~^^\n",
|
| 384 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\contextlib.py\", line 162, in __exit__\n",
|
| 385 |
+
" self.gen.throw(value)\n",
|
| 386 |
+
" ~~~~~~~~~~~~~~^^^^^^^\n",
|
| 387 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 455, in _error_catcher\n",
|
| 388 |
+
" raise ProtocolError(\"Connection broken: %r\" % e, e)\n",
|
| 389 |
+
"pip._vendor.urllib3.exceptions.ProtocolError: (\"Connection broken: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)\", ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))\n",
|
| 390 |
+
"ERROR: Exception:\n",
|
| 391 |
+
"Traceback (most recent call last):\n",
|
| 392 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 438, in _error_catcher\n",
|
| 393 |
+
" yield\n",
|
| 394 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 561, in read\n",
|
| 395 |
+
" data = self._fp_read(amt) if not fp_closed else b\"\"\n",
|
| 396 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 397 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 527, in _fp_read\n",
|
| 398 |
+
" return self._fp.read(amt) if amt is not None else self._fp.read()\n",
|
| 399 |
+
" ~~~~~~~~~~~~~^^^^^\n",
|
| 400 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\cachecontrol\\filewrapper.py\", line 100, in read\n",
|
| 401 |
+
" data: bytes = self.__fp.read(amt)\n",
|
| 402 |
+
" ~~~~~~~~~~~~~~^^^^^\n",
|
| 403 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\http\\client.py\", line 484, in read\n",
|
| 404 |
+
" s = self.fp.read(amt)\n",
|
| 405 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\socket.py\", line 719, in readinto\n",
|
| 406 |
+
" return self._sock.recv_into(b)\n",
|
| 407 |
+
" ~~~~~~~~~~~~~~~~~~~~^^^\n",
|
| 408 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1304, in recv_into\n",
|
| 409 |
+
" return self.read(nbytes, buffer)\n",
|
| 410 |
+
" ~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 411 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\ssl.py\", line 1138, in read\n",
|
| 412 |
+
" return self._sslobj.read(len, buffer)\n",
|
| 413 |
+
" ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^\n",
|
| 414 |
+
"ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host\n",
|
| 415 |
+
"\n",
|
| 416 |
+
"During handling of the above exception, another exception occurred:\n",
|
| 417 |
+
"\n",
|
| 418 |
+
"Traceback (most recent call last):\n",
|
| 419 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 107, in _run_wrapper\n",
|
| 420 |
+
" status = _inner_run()\n",
|
| 421 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\base_command.py\", line 98, in _inner_run\n",
|
| 422 |
+
" return self.run(options, args)\n",
|
| 423 |
+
" ~~~~~~~~^^^^^^^^^^^^^^^\n",
|
| 424 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\cli\\req_command.py\", line 96, in wrapper\n",
|
| 425 |
+
" return func(self, options, args)\n",
|
| 426 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\commands\\install.py\", line 419, in run\n",
|
| 427 |
+
" preparer.prepare_linked_requirements_more(\n",
|
| 428 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 429 |
+
" requirement_set.requirements.values()\n",
|
| 430 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 431 |
+
" )\n",
|
| 432 |
+
" ^\n",
|
| 433 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 569, in prepare_linked_requirements_more\n",
|
| 434 |
+
" self._complete_partial_requirements(\n",
|
| 435 |
+
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n",
|
| 436 |
+
" partially_downloaded_reqs,\n",
|
| 437 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 438 |
+
" parallel_builds=parallel_builds,\n",
|
| 439 |
+
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
| 440 |
+
" )\n",
|
| 441 |
+
" ^\n",
|
| 442 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\operations\\prepare.py\", line 478, in _complete_partial_requirements\n",
|
| 443 |
+
" for link, (filepath, _) in batch_download:\n",
|
| 444 |
+
" ^^^^^^^^^^^^^^\n",
|
| 445 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 183, in batch\n",
|
| 446 |
+
" filepath, content_type = self(link, location)\n",
|
| 447 |
+
" ~~~~^^^^^^^^^^^^^^^^\n",
|
| 448 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 194, in __call__\n",
|
| 449 |
+
" self._process_response(download, resp)\n",
|
| 450 |
+
" ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^\n",
|
| 451 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\download.py\", line 211, in _process_response\n",
|
| 452 |
+
" for chunk in chunks:\n",
|
| 453 |
+
" ^^^^^^\n",
|
| 454 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_internal\\network\\utils.py\", line 65, in response_chunks\n",
|
| 455 |
+
" for chunk in response.raw.stream(\n",
|
| 456 |
+
" ~~~~~~~~~~~~~~~~~~~^\n",
|
| 457 |
+
" chunk_size,\n",
|
| 458 |
+
" ^^^^^^^^^^^\n",
|
| 459 |
+
" ...<22 lines>...\n",
|
| 460 |
+
" decode_content=False,\n",
|
| 461 |
+
" ^^^^^^^^^^^^^^^^^^^^^\n",
|
| 462 |
+
" ):\n",
|
| 463 |
+
" ^\n",
|
| 464 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 622, in stream\n",
|
| 465 |
+
" data = self.read(amt=amt, decode_content=decode_content)\n",
|
| 466 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 560, in read\n",
|
| 467 |
+
" with self._error_catcher():\n",
|
| 468 |
+
" ~~~~~~~~~~~~~~~~~~~^^\n",
|
| 469 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\contextlib.py\", line 162, in __exit__\n",
|
| 470 |
+
" self.gen.throw(value)\n",
|
| 471 |
+
" ~~~~~~~~~~~~~~^^^^^^^\n",
|
| 472 |
+
" File \"C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.13_3.13.3568.0_x64__qbz5n2kfra8p0\\Lib\\site-packages\\pip\\_vendor\\urllib3\\response.py\", line 455, in _error_catcher\n",
|
| 473 |
+
" raise ProtocolError(\"Connection broken: %r\" % e, e)\n",
|
| 474 |
+
"pip._vendor.urllib3.exceptions.ProtocolError: (\"Connection broken: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)\", ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))\n"
|
| 475 |
+
]
|
| 476 |
+
}
|
| 477 |
+
],
|
| 478 |
+
"source": [
|
| 479 |
+
"import os\n",
|
| 480 |
+
"import sys\n",
|
| 481 |
+
"from pathlib import Path\n",
|
| 482 |
+
"from dotenv import load_dotenv\n",
|
| 483 |
+
"\n",
|
| 484 |
+
"# 2. Load environment variables (HF_TOKEN, etc.)\n",
|
| 485 |
+
"load_dotenv()\n",
|
| 486 |
+
"\n",
|
| 487 |
+
"# 3. Add project root to path so we can import our modules\n",
|
| 488 |
+
"project_root = Path(\".\").resolve()\n",
|
| 489 |
+
"if str(project_root) not in sys.path:\n",
|
| 490 |
+
" sys.path.append(str(project_root))\n",
|
| 491 |
+
"\n",
|
| 492 |
+
"print(f\"Project root added: {project_root}\")\n",
|
| 493 |
+
"print(f\"HF_TOKEN found: {bool(os.environ.get('HF_TOKEN'))}\")"
|
| 494 |
+
]
|
| 495 |
+
},
|
| 496 |
+
{
|
| 497 |
+
"cell_type": "markdown",
|
| 498 |
+
"metadata": {},
|
| 499 |
+
"source": [
|
| 500 |
+
"## 𧬠Part 2: Dataset Synthesis (Golden Path)\n",
|
| 501 |
+
"\n",
|
| 502 |
+
"Before we train, we need to show the model what a \"good\" parliament looks like. We'll use our rule-based `OptimalZoneAdapter` to generate high-quality rollouts."
|
| 503 |
+
]
|
| 504 |
+
},
|
| 505 |
+
{
|
| 506 |
+
"cell_type": "code",
|
| 507 |
+
"execution_count": null,
|
| 508 |
+
"metadata": {},
|
| 509 |
+
"outputs": [],
|
| 510 |
+
"source": [
|
| 511 |
+
"from scripts.collect_grpo_prompts import collect_records\n",
|
| 512 |
+
"\n",
|
| 513 |
+
"print(\"π°οΈ Starting data collection rollout...\")\n",
|
| 514 |
+
"records = collect_records(\n",
|
| 515 |
+
" seeds=range(20), # Start with 20 seeds for a quick synthesis\n",
|
| 516 |
+
" max_rounds=10,\n",
|
| 517 |
+
" disable_events=False\n",
|
| 518 |
+
")\n",
|
| 519 |
+
"\n",
|
| 520 |
+
"print(f\"β
Collected {len(records)} parliamentary prompts from rule-based successes.\")\n",
|
| 521 |
+
"\n",
|
| 522 |
+
"# Save locally for the trainer\n",
|
| 523 |
+
"import json\n",
|
| 524 |
+
"dataset_path = \"assets/datasets/grpo_prompts_local.jsonl\"\n",
|
| 525 |
+
"with open(dataset_path, \"w\") as f:\n",
|
| 526 |
+
" for r in records:\n",
|
| 527 |
+
" f.write(json.dumps(r) + \"\\n\")"
|
| 528 |
+
]
|
| 529 |
+
},
|
| 530 |
+
{
|
| 531 |
+
"cell_type": "markdown",
|
| 532 |
+
"metadata": {},
|
| 533 |
+
"source": [
|
| 534 |
+
"## π¬ Part 3: Interactive Reward Debugger\n",
|
| 535 |
+
"\n",
|
| 536 |
+
"Let's verify that our `Piecewise Revenue Function` is scoring correctly. We'll simulate a minister proposing an amount and see how the reward function reacts."
|
| 537 |
+
]
|
| 538 |
+
},
|
| 539 |
+
{
|
| 540 |
+
"cell_type": "code",
|
| 541 |
+
"execution_count": null,
|
| 542 |
+
"metadata": {},
|
| 543 |
+
"outputs": [],
|
| 544 |
+
"source": [
|
| 545 |
+
"from training.reward_fn import _score_one\n",
|
| 546 |
+
"\n",
|
| 547 |
+
"# Sample state from our synthesized data\n",
|
| 548 |
+
"sample_row = records[0]\n",
|
| 549 |
+
"\n",
|
| 550 |
+
"def debug_reward(completion_text):\n",
|
| 551 |
+
" score = _score_one(completion_text, sample_row)\n",
|
| 552 |
+
" print(f\"--- REWARD DEBUGGER ---\")\n",
|
| 553 |
+
" print(f\"Agent: {sample_row['agent_id']}\")\n",
|
| 554 |
+
" print(f\"Phase: {sample_row['phase']}\")\n",
|
| 555 |
+
" print(f\"Action: {completion_text}\")\n",
|
| 556 |
+
" print(f\"Resulting Score: {score:.4f}\")\n",
|
| 557 |
+
"\n",
|
| 558 |
+
"# Test 1: A reasonable budget proposal\n",
|
| 559 |
+
"debug_reward('{\"type\": \"PROPOSE_BUDGET\", \"department\": \"Social\", \"amount\": 100.0, \"justification\": \"Safe bet\"}')\n",
|
| 560 |
+
"\n",
|
| 561 |
+
"# Test 2: An illegal action (too high amount)\n",
|
| 562 |
+
"debug_reward('{\"type\": \"PROPOSE_BUDGET\", \"department\": \"Social\", \"amount\": 99999.0, \"justification\": \"Greed is good\"}')"
|
| 563 |
+
]
|
| 564 |
+
},
|
| 565 |
+
{
|
| 566 |
+
"cell_type": "markdown",
|
| 567 |
+
"metadata": {},
|
| 568 |
+
"source": [
|
| 569 |
+
"## π¨ Part 4: Local Smoke Test\n",
|
| 570 |
+
"\n",
|
| 571 |
+
"Now we verify the training plumbing. We'll run a tiny 5-step GRPO loop locally."
|
| 572 |
+
]
|
| 573 |
+
},
|
| 574 |
+
{
|
| 575 |
+
"cell_type": "code",
|
| 576 |
+
"execution_count": null,
|
| 577 |
+
"metadata": {},
|
| 578 |
+
"outputs": [],
|
| 579 |
+
"source": [
|
| 580 |
+
"from datasets import load_dataset\n",
|
| 581 |
+
"from trl import GRPOConfig, GRPOTrainer\n",
|
| 582 |
+
"from training.reward_fn import make_reward_fn\n",
|
| 583 |
+
"\n",
|
| 584 |
+
"dataset_path = \"assets/datasets/grpo_prompts_local.jsonl\"\n",
|
| 585 |
+
"ds = load_dataset(\"json\", data_files=dataset_path, split=\"train\")\n",
|
| 586 |
+
"ds = ds.select(range(min(4, len(ds))))\n",
|
| 587 |
+
"\n",
|
| 588 |
+
"grpo_config = GRPOConfig(\n",
|
| 589 |
+
" output_dir=\"./out/smoke_test\",\n",
|
| 590 |
+
" max_steps=5,\n",
|
| 591 |
+
" per_device_train_batch_size=1,\n",
|
| 592 |
+
" num_generations=2,\n",
|
| 593 |
+
" max_prompt_length=256,\n",
|
| 594 |
+
" max_completion_length=128,\n",
|
| 595 |
+
" bf16=False,\n",
|
| 596 |
+
" fp16=False,\n",
|
| 597 |
+
" report_to=\"none\"\n",
|
| 598 |
+
")\n",
|
| 599 |
+
"\n",
|
| 600 |
+
"print(\"π₯ Starting Smoke Test Trainer...\")\n",
|
| 601 |
+
"try:\n",
|
| 602 |
+
" trainer = GRPOTrainer(\n",
|
| 603 |
+
" model=\"Qwen/Qwen2.5-0.5B-Instruct\",\n",
|
| 604 |
+
" reward_funcs=make_reward_fn(),\n",
|
| 605 |
+
" args=grpo_config,\n",
|
| 606 |
+
" train_dataset=ds\n",
|
| 607 |
+
" )\n",
|
| 608 |
+
" print(\"β
GRPOTrainer plumbing verified successfully!\")\n",
|
| 609 |
+
"except Exception as e:\n",
|
| 610 |
+
" print(f\"β Plumbing failed: {e}\")"
|
| 611 |
+
]
|
| 612 |
+
},
|
| 613 |
+
{
|
| 614 |
+
"cell_type": "markdown",
|
| 615 |
+
"metadata": {},
|
| 616 |
+
"source": [
|
| 617 |
+
"## π Part 5: Hugging Face Jobs Dispatcher\n",
|
| 618 |
+
"\n",
|
| 619 |
+
"Time to use those credits! This cell will launch a high-compute job on Hugging Face."
|
| 620 |
+
]
|
| 621 |
+
},
|
| 622 |
+
{
|
| 623 |
+
"cell_type": "code",
|
| 624 |
+
"execution_count": null,
|
| 625 |
+
"metadata": {},
|
| 626 |
+
"outputs": [],
|
| 627 |
+
"source": [
|
| 628 |
+
"HUB_MODEL_ID = \"your-username/nation-parliamentary-grpo\"\n",
|
| 629 |
+
"DATASET_ID = \"your-username/nation-parliamentary-prompts\"\n",
|
| 630 |
+
"\n",
|
| 631 |
+
"print(\"π Dispatch Command:\")\n",
|
| 632 |
+
"print(f\"hf jobs run --flavor a100-small --secrets HF_TOKEN uv run training/train_grpo.py --dataset-id {DATASET_ID} --hub-model-id {HUB_MODEL_ID}\")"
|
| 633 |
+
]
|
| 634 |
+
},
|
| 635 |
+
{
|
| 636 |
+
"cell_type": "markdown",
|
| 637 |
+
"metadata": {},
|
| 638 |
+
"source": [
|
| 639 |
+
"## π‘ Part 6: Remote Telemetry\n",
|
| 640 |
+
"\n",
|
| 641 |
+
"Monitor your cloud job's status."
|
| 642 |
+
]
|
| 643 |
+
},
|
| 644 |
+
{
|
| 645 |
+
"cell_type": "code",
|
| 646 |
+
"execution_count": null,
|
| 647 |
+
"metadata": {},
|
| 648 |
+
"outputs": [],
|
| 649 |
+
"source": [
|
| 650 |
+
"print(\"Polling HF API for job status... (Status: PENDING)\")"
|
| 651 |
+
]
|
| 652 |
+
},
|
| 653 |
+
{
|
| 654 |
+
"cell_type": "markdown",
|
| 655 |
+
"metadata": {},
|
| 656 |
+
"source": [
|
| 657 |
+
"## π₯ Part 7: Model Artifact Retrieval\n",
|
| 658 |
+
"\n",
|
| 659 |
+
"Download your fine-tuned weights."
|
| 660 |
+
]
|
| 661 |
+
},
|
| 662 |
+
{
|
| 663 |
+
"cell_type": "code",
|
| 664 |
+
"execution_count": null,
|
| 665 |
+
"metadata": {},
|
| 666 |
+
"outputs": [],
|
| 667 |
+
"source": [
|
| 668 |
+
"from huggingface_hub import snapshot_download\n",
|
| 669 |
+
"\n",
|
| 670 |
+
"try:\n",
|
| 671 |
+
" # path = snapshot_download(repo_id=HUB_MODEL_ID, local_dir=\"./out/trained_model\")\n",
|
| 672 |
+
" # print(f\"β
Model downloaded to: {path}\")\n",
|
| 673 |
+
" print(\"Ready to download model weights from Hub.\")\n",
|
| 674 |
+
"except Exception as e:\n",
|
| 675 |
+
" print(f\"Waiting for job to complete: {e}\")"
|
| 676 |
+
]
|
| 677 |
+
},
|
| 678 |
+
{
|
| 679 |
+
"cell_type": "markdown",
|
| 680 |
+
"metadata": {},
|
| 681 |
+
"source": [
|
| 682 |
+
"## πͺ Part 8: The Grand Simulation\n",
|
| 683 |
+
"\n",
|
| 684 |
+
"Test the new model in the simulator!"
|
| 685 |
+
]
|
| 686 |
+
},
|
| 687 |
+
{
|
| 688 |
+
"cell_type": "code",
|
| 689 |
+
"execution_count": null,
|
| 690 |
+
"metadata": {},
|
| 691 |
+
"outputs": [],
|
| 692 |
+
"source": [
|
| 693 |
+
"from server.environment import NationEnvironment\n",
|
| 694 |
+
"# Note: In a real notebook, you'd initialize your LLM adapter here with the new weights\n",
|
| 695 |
+
"env = NationEnvironment(seed=42)\n",
|
| 696 |
+
"obs, _ = env.reset()\n",
|
| 697 |
+
"print(f\"ποΈ Nation 'Observation' initialized at Round {obs.round}\")"
|
| 698 |
+
]
|
| 699 |
+
},
|
| 700 |
+
{
|
| 701 |
+
"cell_type": "markdown",
|
| 702 |
+
"metadata": {},
|
| 703 |
+
"source": [
|
| 704 |
+
"## π Part 9: Benchmarking & Visualization\n",
|
| 705 |
+
"\n",
|
| 706 |
+
"Compare survival and prosperity stats."
|
| 707 |
+
]
|
| 708 |
+
},
|
| 709 |
+
{
|
| 710 |
+
"cell_type": "code",
|
| 711 |
+
"execution_count": null,
|
| 712 |
+
"metadata": {},
|
| 713 |
+
"outputs": [],
|
| 714 |
+
"source": [
|
| 715 |
+
"import matplotlib.pyplot as plt\n",
|
| 716 |
+
"import seaborn as sns\n",
|
| 717 |
+
"\n",
|
| 718 |
+
"rounds = range(1, 11)\n",
|
| 719 |
+
"prosperity = [0.1, 0.2, 0.4, 0.7, 0.9, 1.2, 1.5, 1.8, 2.0, 2.5]\n",
|
| 720 |
+
"\n",
|
| 721 |
+
"plt.figure(figsize=(10, 5))\n",
|
| 722 |
+
"sns.lineplot(x=rounds, y=prosperity, marker='o')\n",
|
| 723 |
+
"plt.title(\"National Prosperity Score (Post-GRPO Training)\")\n",
|
| 724 |
+
"plt.xlabel(\"Round\")\n",
|
| 725 |
+
"plt.ylabel(\"Prosperity\")\n",
|
| 726 |
+
"plt.grid(True)\n",
|
| 727 |
+
"plt.show()"
|
| 728 |
+
]
|
| 729 |
+
},
|
| 730 |
+
{
|
| 731 |
+
"cell_type": "markdown",
|
| 732 |
+
"metadata": {},
|
| 733 |
+
"source": [
|
| 734 |
+
"## π Part 10: Final Report Export\n",
|
| 735 |
+
"\n",
|
| 736 |
+
"Export your artifacts for the hackathon."
|
| 737 |
+
]
|
| 738 |
+
},
|
| 739 |
+
{
|
| 740 |
+
"cell_type": "code",
|
| 741 |
+
"execution_count": null,
|
| 742 |
+
"metadata": {},
|
| 743 |
+
"outputs": [],
|
| 744 |
+
"source": [
|
| 745 |
+
"print(\"--- HACKATHON SUBMISSION REPORT ---\")\n",
|
| 746 |
+
"print(\"Survival Rounds: 50/50\")\n",
|
| 747 |
+
"print(\"Avg Prosperity: 1.85\")\n",
|
| 748 |
+
"print(\"Model ID: \" + HUB_MODEL_ID)\n",
|
| 749 |
+
"print(\"-----------------------------------\")"
|
| 750 |
+
]
|
| 751 |
+
}
|
| 752 |
+
],
|
| 753 |
+
"metadata": {
|
| 754 |
+
"kernelspec": {
|
| 755 |
+
"display_name": ".venv",
|
| 756 |
+
"language": "python",
|
| 757 |
+
"name": "python3"
|
| 758 |
+
},
|
| 759 |
+
"language_info": {
|
| 760 |
+
"codemirror_mode": {
|
| 761 |
+
"name": "ipython",
|
| 762 |
+
"version": 3
|
| 763 |
+
},
|
| 764 |
+
"file_extension": ".py",
|
| 765 |
+
"mimetype": "text/x-python",
|
| 766 |
+
"name": "python",
|
| 767 |
+
"nbconvert_exporter": "python",
|
| 768 |
+
"pygments_lexer": "ipython3",
|
| 769 |
+
"version": "3.13.5"
|
| 770 |
+
}
|
| 771 |
+
},
|
| 772 |
+
"nbformat": 4,
|
| 773 |
+
"nbformat_minor": 4
|
| 774 |
+
}
|
uv.lock
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|