Kandukuri commited on
Commit
a75e08e
·
1 Parent(s): ed41ca2

Fix: OpenEnv reset() compatibility - no-arg reset, seed in __init__

Browse files
Files changed (1) hide show
  1. env_v2.py +23 -5
env_v2.py CHANGED
@@ -44,7 +44,9 @@ COMPONENTS = ["database", "api", "cache", "queue"]
44
  # ---------------------------------------------------------------------------
45
 
46
  class RepairEnvV2:
47
- def __init__(self) -> None:
 
 
48
  self._task_config: Optional[Dict[str, Any]] = None
49
 
50
  # Hidden State
@@ -62,15 +64,31 @@ class RepairEnvV2:
62
  self._fixed_symptom_before_root: bool = False
63
  self._root_cause_fixed: bool = False
64
 
65
- self._rng: random.Random = random.Random(SEED)
66
- self._symptom_engine: SymptomEngine = SymptomEngine(SEED)
67
 
68
  # ------------------------------------------------------------------
69
  # Public API
70
  # ------------------------------------------------------------------
71
 
72
- def reset(self, task_config: Dict[str, Any], task_id: str) -> SymptomObservation:
73
- """Reset the environment using a provided task configuration."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  self._task_config = copy.deepcopy(task_config)
75
  self._task_id = task_id
76
 
 
44
  # ---------------------------------------------------------------------------
45
 
46
  class RepairEnvV2:
47
+ def __init__(self, seed: int = SEED) -> None:
48
+ """OpenEnv-compatible constructor. Accepts optional seed (default 42)."""
49
+ self._init_seed = seed
50
  self._task_config: Optional[Dict[str, Any]] = None
51
 
52
  # Hidden State
 
64
  self._fixed_symptom_before_root: bool = False
65
  self._root_cause_fixed: bool = False
66
 
67
+ self._rng: random.Random = random.Random(seed)
68
+ self._symptom_engine: SymptomEngine = SymptomEngine(seed)
69
 
70
  # ------------------------------------------------------------------
71
  # Public API
72
  # ------------------------------------------------------------------
73
 
74
+ def reset(
75
+ self,
76
+ task_config: Optional[Dict[str, Any]] = None,
77
+ task_id: str = "easy",
78
+ ) -> SymptomObservation:
79
+ """
80
+ Reset the environment.
81
+
82
+ OpenEnv calls this with no arguments → defaults to 'easy' task.
83
+ server_v2.py calls it with (task_config=config, task_id=task_id) → still works.
84
+ """
85
+ # If no task_config provided, load from tasks_v2 by task_id
86
+ if task_config is None:
87
+ from tasks_v2 import TASKS
88
+ if task_id not in TASKS:
89
+ task_id = "easy"
90
+ task_config = TASKS[task_id]
91
+
92
  self._task_config = copy.deepcopy(task_config)
93
  self._task_id = task_id
94