Spaces:
Running
Running
feat: add console logging for inference start, step, and end events
Browse files- inference.py +5 -1
inference.py
CHANGED
|
@@ -245,12 +245,15 @@ def run_episode(env_client: GridMindEnvClient, agent: LLMAgent,
|
|
| 245 |
total_reward = 0.0
|
| 246 |
total_steps = 0
|
| 247 |
start_time = time.time()
|
|
|
|
|
|
|
| 248 |
|
| 249 |
step_resp = {}
|
| 250 |
-
_step =
|
| 251 |
while not step_resp.get("done", False):
|
| 252 |
action = agent.choose_action(obs, task_id)
|
| 253 |
step_resp = env_client.step(action)
|
|
|
|
| 254 |
|
| 255 |
if step_resp is None or "observation" not in step_resp:
|
| 256 |
print(f" [WARN] step {_step}: server returned invalid response, skipping step")
|
|
@@ -269,6 +272,7 @@ def run_episode(env_client: GridMindEnvClient, agent: LLMAgent,
|
|
| 269 |
f"reward={step_resp['reward']:.3f}")
|
| 270 |
_step += 1
|
| 271 |
|
|
|
|
| 272 |
elapsed = time.time() - start_time
|
| 273 |
grade = env_client.grade()
|
| 274 |
|
|
|
|
| 245 |
total_reward = 0.0
|
| 246 |
total_steps = 0
|
| 247 |
start_time = time.time()
|
| 248 |
+
|
| 249 |
+
print("[START]")
|
| 250 |
|
| 251 |
step_resp = {}
|
| 252 |
+
_step = 1
|
| 253 |
while not step_resp.get("done", False):
|
| 254 |
action = agent.choose_action(obs, task_id)
|
| 255 |
step_resp = env_client.step(action)
|
| 256 |
+
print(f"[STEP{_step}]")
|
| 257 |
|
| 258 |
if step_resp is None or "observation" not in step_resp:
|
| 259 |
print(f" [WARN] step {_step}: server returned invalid response, skipping step")
|
|
|
|
| 272 |
f"reward={step_resp['reward']:.3f}")
|
| 273 |
_step += 1
|
| 274 |
|
| 275 |
+
print("[END]")
|
| 276 |
elapsed = time.time() - start_time
|
| 277 |
grade = env_client.grade()
|
| 278 |
|