adityss commited on
Commit
cda28c0
·
1 Parent(s): dd83f0d

refactor: update Dockerfile and pyproject.toml for dependency management; remove FastAPI server implementation

Browse files
Files changed (4) hide show
  1. Dockerfile +1 -1
  2. pyproject.toml +1 -2
  3. server/app.py +0 -84
  4. test_suite_results.json +307 -0
Dockerfile CHANGED
@@ -20,7 +20,7 @@ RUN apt-get update && apt-get install -y supervisor && rm -rf /var/lib/apt/lists
20
  # Install Python dependencies
21
  COPY python/requirements.txt ./requirements.txt
22
  RUN pip install --no-cache-dir -r requirements.txt || \
23
- pip install --no-cache-dir openai fastapi uvicorn httpx pydantic "pydantic>=2.0.0" requests
24
 
25
  # Copy Go binary
26
  COPY --from=builder /app/gridmind-server /usr/local/bin/gridmind-server
 
20
  # Install Python dependencies
21
  COPY python/requirements.txt ./requirements.txt
22
  RUN pip install --no-cache-dir -r requirements.txt || \
23
+ pip install --no-cache-dir openai httpx pydantic "pydantic>=2.0.0" requests
24
 
25
  # Copy Go binary
26
  COPY --from=builder /app/gridmind-server /usr/local/bin/gridmind-server
pyproject.toml CHANGED
@@ -54,8 +54,7 @@ Repository = "https://github.com/meta-pytorch/OpenEnv"
54
  Documentation = "https://github.com/meta-pytorch/OpenEnv"
55
 
56
  [project.scripts]
57
- server = "server.app:main"
58
- gridmind-server = "server.app:main"
59
 
60
  [tool.setuptools]
61
  packages = ["python", "server"]
 
54
  Documentation = "https://github.com/meta-pytorch/OpenEnv"
55
 
56
  [project.scripts]
57
+ gridmind-eval = "python.inference:main"
 
58
 
59
  [tool.setuptools]
60
  packages = ["python", "server"]
server/app.py DELETED
@@ -1,84 +0,0 @@
1
- """
2
- GridMind-RL FastAPI Server Wrapper
3
- Proxies requests to the Go environment server (or provides fallback endpoints)
4
- """
5
-
6
- from fastapi import FastAPI
7
- from fastapi.responses import JSONResponse
8
- import os
9
- import httpx
10
-
11
- app = FastAPI(title="GridMind-RL", version="1.0.0")
12
-
13
- # Go server address (set via environment or default)
14
- GO_SERVER_URL = os.getenv("GO_SERVER_URL", "http://localhost:8000")
15
-
16
- # Timeout for Go server calls
17
- TIMEOUT = 30
18
-
19
-
20
- @app.get("/health")
21
- async def health():
22
- """Health check endpoint."""
23
- try:
24
- async with httpx.AsyncClient(timeout=TIMEOUT) as client:
25
- resp = await client.get(f"{GO_SERVER_URL}/health")
26
- return resp.json()
27
- except Exception:
28
- # Fallback response if Go server unreachable
29
- return {"status": "ok", "mode": "python"}
30
-
31
-
32
- @app.get("/state")
33
- async def get_state():
34
- """Get environment state."""
35
- try:
36
- async with httpx.AsyncClient(timeout=TIMEOUT) as client:
37
- resp = await client.get(f"{GO_SERVER_URL}/state")
38
- return resp.json()
39
- except Exception as e:
40
- return JSONResponse({"error": str(e)}, status_code=503)
41
-
42
-
43
- @app.post("/reset")
44
- async def reset(request: dict):
45
- """Reset environment."""
46
- try:
47
- async with httpx.AsyncClient(timeout=TIMEOUT) as client:
48
- resp = await client.post(f"{GO_SERVER_URL}/reset", json=request)
49
- return resp.json()
50
- except Exception as e:
51
- return JSONResponse({"error": str(e)}, status_code=503)
52
-
53
-
54
- @app.post("/step")
55
- async def step(request: dict):
56
- """Step environment."""
57
- try:
58
- async with httpx.AsyncClient(timeout=TIMEOUT) as client:
59
- resp = await client.post(f"{GO_SERVER_URL}/step", json=request)
60
- return resp.json()
61
- except Exception as e:
62
- return JSONResponse({"error": str(e)}, status_code=503)
63
-
64
-
65
- @app.get("/grade")
66
- async def grade():
67
- """Grade environment."""
68
- try:
69
- async with httpx.AsyncClient(timeout=TIMEOUT) as client:
70
- resp = await client.get(f"{GO_SERVER_URL}/grade")
71
- return resp.json()
72
- except Exception as e:
73
- return JSONResponse({"error": str(e)}, status_code=503)
74
-
75
-
76
- def main():
77
- """Entry point for server."""
78
- import uvicorn
79
- port = int(os.getenv("PORT", 7860))
80
- uvicorn.run(app, host="0.0.0.0", port=port)
81
-
82
-
83
- if __name__ == "__main__":
84
- main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_suite_results.json ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "passed": 50,
3
+ "failed": 0,
4
+ "warnings": 0,
5
+ "details": [
6
+ {
7
+ "id": "B1",
8
+ "description": "API_BASE_URL has default",
9
+ "status": "PASS",
10
+ "details": "https://openrouter.ai/api/v1"
11
+ },
12
+ {
13
+ "id": "B2",
14
+ "description": "MODEL_NAME has default",
15
+ "status": "PASS",
16
+ "details": "meta-llama/llama-3.3-70b-instruct:free"
17
+ },
18
+ {
19
+ "id": "B3",
20
+ "description": "HF_TOKEN is mandatory (raises ValueError)",
21
+ "status": "PASS",
22
+ "details": "checked in python/inference.py line 57-58"
23
+ },
24
+ {
25
+ "id": "B4",
26
+ "description": "OpenAI client initialized",
27
+ "status": "PASS",
28
+ "details": "base_url and api_key from env vars"
29
+ },
30
+ {
31
+ "id": "B5",
32
+ "description": "HF_TOKEN is PRIMARY key",
33
+ "status": "PASS",
34
+ "details": "OPENAI_API_KEY is fallback only"
35
+ },
36
+ {
37
+ "id": "C1",
38
+ "description": "[START] format exists",
39
+ "status": "PASS",
40
+ "details": ""
41
+ },
42
+ {
43
+ "id": "C2",
44
+ "description": "[STEP] format exists",
45
+ "status": "PASS",
46
+ "details": ""
47
+ },
48
+ {
49
+ "id": "C3",
50
+ "description": "[END] format exists",
51
+ "status": "PASS",
52
+ "details": ""
53
+ },
54
+ {
55
+ "id": "C4",
56
+ "description": "Reward formatted to 2 decimal places",
57
+ "status": "PASS",
58
+ "details": ""
59
+ },
60
+ {
61
+ "id": "C5",
62
+ "description": "Lowercase booleans (true/false)",
63
+ "status": "PASS",
64
+ "details": ""
65
+ },
66
+ {
67
+ "id": "C6",
68
+ "description": "error field uses null",
69
+ "status": "PASS",
70
+ "details": ""
71
+ },
72
+ {
73
+ "id": "D1",
74
+ "description": "OpenEnv spec structure valid, name=gridmind-rl",
75
+ "status": "PASS",
76
+ "details": ""
77
+ },
78
+ {
79
+ "id": "D1b",
80
+ "description": "Port is 7860: 7860",
81
+ "status": "PASS",
82
+ "details": ""
83
+ },
84
+ {
85
+ "id": "D1c",
86
+ "description": "Has 3 tasks: 3",
87
+ "status": "PASS",
88
+ "details": ""
89
+ },
90
+ {
91
+ "id": "D2",
92
+ "description": "All OpenEnv endpoints declared: 6/6",
93
+ "status": "PASS",
94
+ "details": ""
95
+ },
96
+ {
97
+ "id": "E1",
98
+ "description": "Exactly 3 tasks: 3",
99
+ "status": "PASS",
100
+ "details": ""
101
+ },
102
+ {
103
+ "id": "E1.1",
104
+ "description": "Task 1 difficulty is easy",
105
+ "status": "PASS",
106
+ "details": "expected easy"
107
+ },
108
+ {
109
+ "id": "E1.2",
110
+ "description": "Task 2 difficulty is medium",
111
+ "status": "PASS",
112
+ "details": "expected medium"
113
+ },
114
+ {
115
+ "id": "E1.3",
116
+ "description": "Task 3 difficulty is hard",
117
+ "status": "PASS",
118
+ "details": "expected hard"
119
+ },
120
+ {
121
+ "id": "E2",
122
+ "description": "Task 1 grader exists",
123
+ "status": "PASS",
124
+ "details": ""
125
+ },
126
+ {
127
+ "id": "E2",
128
+ "description": "Task 2 grader exists",
129
+ "status": "PASS",
130
+ "details": ""
131
+ },
132
+ {
133
+ "id": "E2",
134
+ "description": "Task 3 grader exists",
135
+ "status": "PASS",
136
+ "details": ""
137
+ },
138
+ {
139
+ "id": "E5",
140
+ "description": "Exploit detection exists",
141
+ "status": "PASS",
142
+ "details": ""
143
+ },
144
+ {
145
+ "id": "E6.1",
146
+ "description": "Task 1 weights sum: 1.00",
147
+ "status": "PASS",
148
+ "details": ""
149
+ },
150
+ {
151
+ "id": "E6.2",
152
+ "description": "Task 2 weights sum: 1.00",
153
+ "status": "PASS",
154
+ "details": ""
155
+ },
156
+ {
157
+ "id": "E6.3",
158
+ "description": "Task 3 weights sum: 1.00",
159
+ "status": "PASS",
160
+ "details": ""
161
+ },
162
+ {
163
+ "id": "F1",
164
+ "description": "All 7 reward components exist: 7/7",
165
+ "status": "PASS",
166
+ "details": ""
167
+ },
168
+ {
169
+ "id": "F2",
170
+ "description": "Reward computed every step",
171
+ "status": "PASS",
172
+ "details": ""
173
+ },
174
+ {
175
+ "id": "F3",
176
+ "description": "Penalties for bad behaviors",
177
+ "status": "PASS",
178
+ "details": ""
179
+ },
180
+ {
181
+ "id": "F4",
182
+ "description": "Reward aggregated properly",
183
+ "status": "PASS",
184
+ "details": ""
185
+ },
186
+ {
187
+ "id": "G1",
188
+ "description": "Multi-stage build (Go builder + Python runtime)",
189
+ "status": "PASS",
190
+ "details": ""
191
+ },
192
+ {
193
+ "id": "G2",
194
+ "description": "Go server compiled",
195
+ "status": "PASS",
196
+ "details": ""
197
+ },
198
+ {
199
+ "id": "G3",
200
+ "description": "supervisord manages processes",
201
+ "status": "PASS",
202
+ "details": ""
203
+ },
204
+ {
205
+ "id": "G4",
206
+ "description": "Go server on port 7860",
207
+ "status": "PASS",
208
+ "details": ""
209
+ },
210
+ {
211
+ "id": "G5",
212
+ "description": "Dashboard on port 7861",
213
+ "status": "PASS",
214
+ "details": ""
215
+ },
216
+ {
217
+ "id": "G7",
218
+ "description": "Both ports exposed",
219
+ "status": "PASS",
220
+ "details": ""
221
+ },
222
+ {
223
+ "id": "G8",
224
+ "description": "Dockerfile syntax valid",
225
+ "status": "PASS",
226
+ "details": ""
227
+ },
228
+ {
229
+ "id": "H1",
230
+ "description": "README has Overview/Motivation",
231
+ "status": "PASS",
232
+ "details": ""
233
+ },
234
+ {
235
+ "id": "H2",
236
+ "description": "README documents Observation Space",
237
+ "status": "PASS",
238
+ "details": ""
239
+ },
240
+ {
241
+ "id": "H3",
242
+ "description": "README documents Action Space",
243
+ "status": "PASS",
244
+ "details": ""
245
+ },
246
+ {
247
+ "id": "H4",
248
+ "description": "README has task descriptions",
249
+ "status": "PASS",
250
+ "details": ""
251
+ },
252
+ {
253
+ "id": "H5",
254
+ "description": "README has setup/usage",
255
+ "status": "PASS",
256
+ "details": ""
257
+ },
258
+ {
259
+ "id": "H6",
260
+ "description": "README mentions baseline",
261
+ "status": "PASS",
262
+ "details": ""
263
+ },
264
+ {
265
+ "id": "H7",
266
+ "description": "README mentions OpenEnv/HF",
267
+ "status": "PASS",
268
+ "details": ""
269
+ },
270
+ {
271
+ "id": "I1",
272
+ "description": "All 3 task scores present: 3",
273
+ "status": "PASS",
274
+ "details": ""
275
+ },
276
+ {
277
+ "id": "I2",
278
+ "description": "All scores in [0.0, 1.0]",
279
+ "status": "PASS",
280
+ "details": ""
281
+ },
282
+ {
283
+ "id": "I3",
284
+ "description": "Has model and api_base fields",
285
+ "status": "PASS",
286
+ "details": ""
287
+ },
288
+ {
289
+ "id": "J1",
290
+ "description": "requirements.txt exists and includes required packages",
291
+ "status": "PASS",
292
+ "details": ""
293
+ },
294
+ {
295
+ "id": "J2",
296
+ "description": "openai package is importable",
297
+ "status": "PASS",
298
+ "details": ""
299
+ },
300
+ {
301
+ "id": "J4",
302
+ "description": "requests package is importable",
303
+ "status": "PASS",
304
+ "details": ""
305
+ }
306
+ ]
307
+ }