rohan-arora-ibm commited on
Commit
7f74217
·
unverified ·
1 Parent(s): 4f5e74b

fix: getting the trajectories when the folder hierarchy has domain

Browse files
analysis_src/extract_inference_data.py CHANGED
@@ -244,6 +244,24 @@ def read_agent_stats(agent_dir: Path) -> dict[str, list[dict]]:
244
  Dict mapping scenario_id -> list of stats (one per trial)
245
  """
246
  scenario_data = {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
 
248
  for scenario_dir in agent_dir.iterdir():
249
  if not scenario_dir.is_dir() or not scenario_dir.name.startswith("Scenario"):
 
244
  Dict mapping scenario_id -> list of stats (one per trial)
245
  """
246
  scenario_data = {}
247
+ # Check if directory contains Scenario folders directly, or if we need to go one level deeper
248
+ # (e.g., agent_dir/sre/Scenario-1, agent_dir/finops/Scenario-1, etc.)
249
+ has_scenarios = any(d.name.startswith("Scenario") for d in agent_dir.iterdir() if d.is_dir())
250
+
251
+ if not has_scenarios:
252
+ # Look for subdirectories that might contain scenarios (sre, finops, etc.)
253
+ subdirs = [d for d in agent_dir.iterdir() if d.is_dir() and not d.name.startswith(".")]
254
+ if len(subdirs) == 1:
255
+ # If there's exactly one subdirectory, use it
256
+ agent_dir = subdirs[0]
257
+ elif len(subdirs) > 1:
258
+ # If there are multiple, try to find one with Scenario folders
259
+ for subdir in subdirs:
260
+ if any(d.name.startswith("Scenario") for d in subdir.iterdir() if d.is_dir()):
261
+ agent_dir = subdir
262
+ break
263
+
264
+
265
 
266
  for scenario_dir in agent_dir.iterdir():
267
  if not scenario_dir.is_dir() or not scenario_dir.name.startswith("Scenario"):
analysis_src/extract_tool_failures.py CHANGED
@@ -245,6 +245,24 @@ def read_agent_stats(agent_dir: Path) -> dict[str, list[dict]]:
245
  Dict mapping scenario_id -> list of stats (one per trial)
246
  """
247
  scenario_data = {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
  for scenario_dir in agent_dir.iterdir():
250
  if not scenario_dir.is_dir() or not scenario_dir.name.startswith("Scenario"):
 
245
  Dict mapping scenario_id -> list of stats (one per trial)
246
  """
247
  scenario_data = {}
248
+ # Check if directory contains Scenario folders directly, or if we need to go one level deeper
249
+ # (e.g., agent_dir/sre/Scenario-1, agent_dir/finops/Scenario-1, etc.)
250
+ has_scenarios = any(d.name.startswith("Scenario") for d in agent_dir.iterdir() if d.is_dir())
251
+
252
+ if not has_scenarios:
253
+ # Look for subdirectories that might contain scenarios (sre, finops, etc.)
254
+ subdirs = [d for d in agent_dir.iterdir() if d.is_dir() and not d.name.startswith(".")]
255
+ if len(subdirs) == 1:
256
+ # If there's exactly one subdirectory, use it
257
+ agent_dir = subdirs[0]
258
+ elif len(subdirs) > 1:
259
+ # If there are multiple, try to find one with Scenario folders
260
+ for subdir in subdirs:
261
+ if any(d.name.startswith("Scenario") for d in subdir.iterdir() if d.is_dir()):
262
+ agent_dir = subdir
263
+ break
264
+
265
+
266
 
267
  for scenario_dir in agent_dir.iterdir():
268
  if not scenario_dir.is_dir() or not scenario_dir.name.startswith("Scenario"):
analysis_src/utils.py CHANGED
@@ -1,4 +1,4 @@
1
- import json
2
  from pathlib import Path
3
 
4
  # Model display names (short for figures)
@@ -56,6 +56,23 @@ def read_judge_outputs_from_dir(agent_dir: Path) -> dict[str, list[dict]]:
56
  """
57
  scenario_data = {}
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  for scenario_dir in agent_dir.iterdir():
60
  if not scenario_dir.is_dir() or not scenario_dir.name.startswith("Scenario"):
61
  continue
 
1
+ analysis_src/utils.pyimport json
2
  from pathlib import Path
3
 
4
  # Model display names (short for figures)
 
56
  """
57
  scenario_data = {}
58
 
59
+ # Check if directory contains Scenario folders directly, or if we need to go one level deeper
60
+ # (e.g., agent_dir/sre/Scenario-1, agent_dir/finops/Scenario-1, etc.)
61
+ has_scenarios = any(d.name.startswith("Scenario") for d in agent_dir.iterdir() if d.is_dir())
62
+
63
+ if not has_scenarios:
64
+ # Look for subdirectories that might contain scenarios (sre, finops, etc.)
65
+ subdirs = [d for d in agent_dir.iterdir() if d.is_dir() and not d.name.startswith(".")]
66
+ if len(subdirs) == 1:
67
+ # If there's exactly one subdirectory, use it
68
+ agent_dir = subdirs[0]
69
+ elif len(subdirs) > 1:
70
+ # If there are multiple, try to find one with Scenario folders
71
+ for subdir in subdirs:
72
+ if any(d.name.startswith("Scenario") for d in subdir.iterdir() if d.is_dir()):
73
+ agent_dir = subdir
74
+ break
75
+
76
  for scenario_dir in agent_dir.iterdir():
77
  if not scenario_dir.is_dir() or not scenario_dir.name.startswith("Scenario"):
78
  continue