RoyAalekh commited on
Commit
779c826
·
1 Parent(s): db7ca89

fix: Correct ParameterLoader method calls in data_loader.py

Browse files

Fixed AttributeError by using actual ParameterLoader API:
- Use case_type_summary DataFrame to extract case types
- Use transition_probs DataFrame to extract stages
- Build stage_graph from get_stage_transitions() method
- Add try/except for adjournment probability lookups
- Add hasattr checks for safety

This resolves the 'ParameterLoader has no attribute get_case_types' error
shown on the EDA Analysis page.

scheduler/dashboard/utils/data_loader.py CHANGED
@@ -30,17 +30,34 @@ def load_param_loader(params_dir: str = "configs/parameters") -> dict[str, Any]:
30
  """
31
  loader = ParameterLoader(Path(params_dir))
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  return {
34
- "case_types": loader.get_case_types(),
35
- "stages": loader.get_stages(),
36
- "stage_graph": loader.get_stage_graph(),
37
- "adjournment_stats": {
38
- stage: {
39
- ct: loader.get_adjournment_prob(stage, ct)
40
- for ct in loader.get_case_types()
41
- }
42
- for stage in loader.get_stages()
43
- },
44
  }
45
 
46
 
 
30
  """
31
  loader = ParameterLoader(Path(params_dir))
32
 
33
+ # Extract case types from case_type_summary DataFrame
34
+ case_types = loader.case_type_summary["casetype"].unique().tolist() if hasattr(loader, 'case_type_summary') else []
35
+
36
+ # Extract stages from transition_probs DataFrame
37
+ stages = loader.transition_probs["STAGE_FROM"].unique().tolist() if hasattr(loader, 'transition_probs') else []
38
+
39
+ # Build stage graph from transition probabilities
40
+ stage_graph = {}
41
+ for stage in stages:
42
+ transitions = loader.get_stage_transitions(stage)
43
+ stage_graph[stage] = transitions.to_dict('records')
44
+
45
+ # Build adjournment stats
46
+ adjournment_stats = {}
47
+ for stage in stages:
48
+ adjournment_stats[stage] = {}
49
+ for ct in case_types:
50
+ try:
51
+ prob = loader.get_adjournment_prob(stage, ct)
52
+ adjournment_stats[stage][ct] = prob
53
+ except:
54
+ adjournment_stats[stage][ct] = 0.0
55
+
56
  return {
57
+ "case_types": case_types,
58
+ "stages": stages,
59
+ "stage_graph": stage_graph,
60
+ "adjournment_stats": adjournment_stats,
 
 
 
 
 
 
61
  }
62
 
63