Spaces:
Sleeping
Sleeping
KUMARISHWETA242 commited on
Commit ·
36802ca
1
Parent(s): b9e1a1e
output format changed
Browse files- inference.py +5 -11
inference.py
CHANGED
|
@@ -564,9 +564,7 @@ async def run_task(task_name: str, client: Optional[OpenAI]) -> TaskRunResult:
|
|
| 564 |
observation = env.reset()
|
| 565 |
state = env.state()
|
| 566 |
step_limit = state.max_steps
|
| 567 |
-
|
| 568 |
-
print(f"\nRunning task: {task_name}")
|
| 569 |
-
|
| 570 |
for step in range(1, step_limit + 1):
|
| 571 |
obs_dict = observation_to_dict(observation)
|
| 572 |
actions = choose_actions(
|
|
@@ -578,7 +576,6 @@ async def run_task(task_name: str, client: Optional[OpenAI]) -> TaskRunResult:
|
|
| 578 |
observation.total_reward,
|
| 579 |
)
|
| 580 |
|
| 581 |
-
print(f"Step {step}: {actions}")
|
| 582 |
|
| 583 |
observation, reward, done, info = env.step(
|
| 584 |
SatelliteAction(satellite_actions=actions)
|
|
@@ -586,23 +583,20 @@ async def run_task(task_name: str, client: Optional[OpenAI]) -> TaskRunResult:
|
|
| 586 |
reward_value = float(reward.value)
|
| 587 |
history.append(f"step {step}: {actions} -> reward {reward_value:+.2f}")
|
| 588 |
|
| 589 |
-
print(
|
| 590 |
-
f" Reward: {reward_value:+.2f} | Total: {observation.total_reward:+.2f} "
|
| 591 |
-
f"| Done: {done} | Remaining: {info.get('tasks_remaining')}"
|
| 592 |
-
)
|
| 593 |
|
| 594 |
if REQUEST_DELAY > 0 and step < step_limit and not done:
|
| 595 |
time.sleep(REQUEST_DELAY)
|
| 596 |
|
| 597 |
if done:
|
| 598 |
-
print("Episode complete.")
|
| 599 |
break
|
| 600 |
else:
|
| 601 |
-
|
| 602 |
|
| 603 |
final_state = env.state()
|
| 604 |
metrics = {key: float(value) for key, value in final_state.metrics.items()}
|
| 605 |
score = grader.grade_episode(env)
|
|
|
|
| 606 |
return TaskRunResult(
|
| 607 |
task_name=task_name,
|
| 608 |
score=score,
|
|
@@ -632,7 +626,7 @@ async def async_main() -> None:
|
|
| 632 |
results = []
|
| 633 |
for task_name in TASK_ORDER:
|
| 634 |
results.append(await run_task(task_name, client))
|
| 635 |
-
print_summary(results)
|
| 636 |
|
| 637 |
|
| 638 |
def main() -> None:
|
|
|
|
| 564 |
observation = env.reset()
|
| 565 |
state = env.state()
|
| 566 |
step_limit = state.max_steps
|
| 567 |
+
print(f"[START] task={task_name}", flush=True)
|
|
|
|
|
|
|
| 568 |
for step in range(1, step_limit + 1):
|
| 569 |
obs_dict = observation_to_dict(observation)
|
| 570 |
actions = choose_actions(
|
|
|
|
| 576 |
observation.total_reward,
|
| 577 |
)
|
| 578 |
|
|
|
|
| 579 |
|
| 580 |
observation, reward, done, info = env.step(
|
| 581 |
SatelliteAction(satellite_actions=actions)
|
|
|
|
| 583 |
reward_value = float(reward.value)
|
| 584 |
history.append(f"step {step}: {actions} -> reward {reward_value:+.2f}")
|
| 585 |
|
| 586 |
+
print(f"[STEP] step={step} reward={reward_value:.4f} total={observation.total_reward:.4f}",flush=True)
|
|
|
|
|
|
|
|
|
|
| 587 |
|
| 588 |
if REQUEST_DELAY > 0 and step < step_limit and not done:
|
| 589 |
time.sleep(REQUEST_DELAY)
|
| 590 |
|
| 591 |
if done:
|
|
|
|
| 592 |
break
|
| 593 |
else:
|
| 594 |
+
pass
|
| 595 |
|
| 596 |
final_state = env.state()
|
| 597 |
metrics = {key: float(value) for key, value in final_state.metrics.items()}
|
| 598 |
score = grader.grade_episode(env)
|
| 599 |
+
print(f"[END] task={task_name} score={score:.4f} steps={final_state.step_count} done={final_state.done}",flush=True)
|
| 600 |
return TaskRunResult(
|
| 601 |
task_name=task_name,
|
| 602 |
score=score,
|
|
|
|
| 626 |
results = []
|
| 627 |
for task_name in TASK_ORDER:
|
| 628 |
results.append(await run_task(task_name, client))
|
| 629 |
+
# print_summary(results)
|
| 630 |
|
| 631 |
|
| 632 |
def main() -> None:
|