-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinference_logging.py
More file actions
22 lines (16 loc) · 856 Bytes
/
Copy pathinference_logging.py
File metadata and controls
22 lines (16 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Logging utilities for inference script stdout output."""
def log_start(task: str, env_name: str, model: str) -> None:
"""Log episode start."""
print(f"[START] task={task} env={env_name} model={model}", flush=True)
def log_step(step: int, action_str: str, reward: float, done: bool, error: str | None) -> None:
"""Log step result."""
error_val = error if error else "null"
done_val = str(done).lower()
print(
f"[STEP] step={step} action={action_str} reward={reward:.2f} done={done_val} error={error_val}",
flush=True,
)
def log_end(success: bool, steps: int, score: float, rewards: list[float]) -> None:
"""Log episode end."""
rewards_str = ",".join(f"{r:.2f}" for r in rewards)
print(f"[END] success={str(success).lower()} steps={steps} score={score:.2f} rewards={rewards_str}", flush=True)