rohan-arora-ibm commited on
Commit
1972fee
·
1 Parent(s): f3d9b3e

fix: path to session.jsonl

Browse files

Signed-off-by: Rohan R. Arora <rohan.arora@ibm.com>

Files changed (1) hide show
  1. analysis_src/utils.py +11 -8
analysis_src/utils.py CHANGED
@@ -1,4 +1,4 @@
1
- analysis_src/utils.pyimport json
2
  from pathlib import Path
3
 
4
  # Model display names (short for figures)
@@ -152,21 +152,24 @@ def filter_scenarios_with_min_runs(scenario_data: dict[str, list], min_runs_requ
152
  }
153
 
154
  def find_latest_rollout_file(trial_dir: Path) -> Path:
155
- """Find the latest rollout file in a trial's sessions directory."""
 
 
 
 
 
 
156
  sessions_dir = trial_dir / "sessions"
157
  if not sessions_dir.exists():
158
  return None
159
-
160
  rollout_files = []
161
  for rollout_file in sessions_dir.rglob("rollout-*.jsonl"):
162
  rollout_files.append(rollout_file)
163
-
164
  if not rollout_files:
165
  return None
166
-
167
- # Sort by filename (which includes timestamp) and return the latest
168
- # rollout_files.sort(key=lambda f: f.name, reverse=True)
169
- # return rollout_files[0]
170
 
 
171
  return max(rollout_files, key=lambda p: p.stat().st_mtime)
172
 
 
1
+ import json
2
  from pathlib import Path
3
 
4
  # Model display names (short for figures)
 
152
  }
153
 
154
  def find_latest_rollout_file(trial_dir: Path) -> Path:
155
+ """Find the latest rollout file in a trial's sessions directory or session.jsonl."""
156
+ # First check for session.jsonl directly in trial_dir (new structure)
157
+ session_file = trial_dir / "session.jsonl"
158
+ if session_file.exists():
159
+ return session_file
160
+
161
+ # Fall back to sessions/rollout-*.jsonl (old structure)
162
  sessions_dir = trial_dir / "sessions"
163
  if not sessions_dir.exists():
164
  return None
165
+
166
  rollout_files = []
167
  for rollout_file in sessions_dir.rglob("rollout-*.jsonl"):
168
  rollout_files.append(rollout_file)
169
+
170
  if not rollout_files:
171
  return None
 
 
 
 
172
 
173
+ # Sort by modification time and return the latest
174
  return max(rollout_files, key=lambda p: p.stat().st_mtime)
175