Spaces:
Sleeping
Sleeping
Commit ·
7a6f18c
1
Parent(s): c41f6ba
fix reset indentation and accept task_id param
Browse files- sql_env/server.py +20 -20
sql_env/server.py
CHANGED
|
@@ -29,26 +29,26 @@ class SQLCorrectionEnvironment(Environment):
|
|
| 29 |
self._rewards_history = []
|
| 30 |
|
| 31 |
def reset(self, difficulty: str = "easy", task_id: str = None, **kwargs) -> SQLObservation:
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
|
| 53 |
def step(self, action: SQLAction) -> SQLObservation:
|
| 54 |
self._step_count += 1
|
|
|
|
| 29 |
self._rewards_history = []
|
| 30 |
|
| 31 |
def reset(self, difficulty: str = "easy", task_id: str = None, **kwargs) -> SQLObservation:
|
| 32 |
+
# task_id and difficulty are the same thing in our env
|
| 33 |
+
actual_difficulty = task_id or difficulty or "easy"
|
| 34 |
+
self._difficulty = actual_difficulty
|
| 35 |
+
tasks = TASK_SETS.get(actual_difficulty, TASK_SETS["easy"])
|
| 36 |
+
self._current_task = random.choice(tasks)
|
| 37 |
+
self._step_count = 0
|
| 38 |
+
self._done = False
|
| 39 |
+
self._last_reward = 0.0
|
| 40 |
+
self._rewards_history = []
|
| 41 |
+
return SQLObservation(
|
| 42 |
+
task_id=self._current_task.task_id,
|
| 43 |
+
broken_query=self._current_task.broken_query,
|
| 44 |
+
schema_context=self._current_task.schema_context,
|
| 45 |
+
error_hint=self._current_task.error_hint,
|
| 46 |
+
step_number=0,
|
| 47 |
+
previous_attempt=None,
|
| 48 |
+
feedback=None,
|
| 49 |
+
reward=0.0,
|
| 50 |
+
done=False,
|
| 51 |
+
)
|
| 52 |
|
| 53 |
def step(self, action: SQLAction) -> SQLObservation:
|
| 54 |
self._step_count += 1
|