YUS200619 commited on
Commit
93557f4
·
verified ·
1 Parent(s): 55fb22d

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +27 -11
app.py CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
2
 
3
  import os
4
  import time
 
5
  from functools import lru_cache
6
  from threading import Lock
7
  from typing import Dict, List, Tuple
@@ -92,17 +93,32 @@ def _cached_episode(policy_style: str, seed: int, randomize_order: bool) -> Tupl
92
 
93
  def run_episode(policy_style: str, seed: int, randomize_order: bool):
94
  _throttle_event_requests()
95
- logs, state, components = _cached_episode(policy_style, seed, randomize_order)
96
- summary = (
97
- "### Outcome\n"
98
- f"- Friday energy: **{state['energy_pct']}%**\n"
99
- f"- Sprint health: **{state['sprint_health_pct']}%**\n"
100
- f"- Leave status: **{state['leave_status']}**\n"
101
- )
102
- comp_rows = [[k, round(v, 3)] for k, v in sorted(components.items())]
103
- if not comp_rows:
104
- comp_rows = [["(none)", 0.0]]
105
- return logs, summary, comp_rows
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
 
108
  def compare_policies(seed: int, randomize_order: bool):
 
2
 
3
  import os
4
  import time
5
+ import traceback
6
  from functools import lru_cache
7
  from threading import Lock
8
  from typing import Dict, List, Tuple
 
93
 
94
  def run_episode(policy_style: str, seed: int, randomize_order: bool):
95
  _throttle_event_requests()
96
+ try:
97
+ logs, state, components = _cached_episode(policy_style, seed, randomize_order)
98
+ episode_log = "\n".join([
99
+ "Episode started.",
100
+ logs,
101
+ ])
102
+ summary = (
103
+ "### Outcome\n"
104
+ f"- Friday energy: **{state['energy_pct']}%**\n"
105
+ f"- Sprint health: **{state['sprint_health_pct']}%**\n"
106
+ f"- Leave status: **{state['leave_status']}**\n"
107
+ )
108
+ comp_rows = [[k, round(v, 3)] for k, v in sorted(components.items())]
109
+ if not comp_rows:
110
+ comp_rows = [["(none)", 0.0]]
111
+ return episode_log, summary, comp_rows
112
+ except Exception as exc:
113
+ episode_log = "Episode failed:\n" + "".join(
114
+ traceback.format_exception(type(exc), exc, exc.__traceback__)
115
+ )
116
+ summary = (
117
+ "### Outcome\n"
118
+ f"- Error: **{type(exc).__name__}**\n"
119
+ f"- Message: **{exc}**\n"
120
+ )
121
+ return episode_log, summary, [["error", 1.0]]
122
 
123
 
124
  def compare_policies(seed: int, randomize_order: bool):