Spaces:
Sleeping
Sleeping
Fix: Clamp score strictly between 0.01 and 0.99 for validator
Browse files
server/__pycache__/environment.cpython-312.pyc
CHANGED
|
Binary files a/server/__pycache__/environment.cpython-312.pyc and b/server/__pycache__/environment.cpython-312.pyc differ
|
|
|
server/__pycache__/grader.cpython-312.pyc
CHANGED
|
Binary files a/server/__pycache__/grader.cpython-312.pyc and b/server/__pycache__/grader.cpython-312.pyc differ
|
|
|
server/environment.py
CHANGED
|
@@ -171,7 +171,7 @@ class DbMigrationEnvironment(Environment):
|
|
| 171 |
target_schema_sql=self._task_config["target_ddl"],
|
| 172 |
last_execution_result="Error: Environment not initialized. Call reset() first.",
|
| 173 |
step_number=self._step_count,
|
| 174 |
-
migration_progress=0.
|
| 175 |
task_name=self.task_name,
|
| 176 |
metadata={"error": "not_initialized"},
|
| 177 |
)
|
|
@@ -200,7 +200,7 @@ class DbMigrationEnvironment(Environment):
|
|
| 200 |
current_score, step_reward = self._reconciler.compute_step_reward(self._conn)
|
| 201 |
|
| 202 |
# Episode termination: submit_final, max steps (20), OR perfect score
|
| 203 |
-
done = action.submit_final or self._step_count >= 20 or current_score >=
|
| 204 |
|
| 205 |
# Update state
|
| 206 |
self._state.step_count = self._step_count
|
|
|
|
| 171 |
target_schema_sql=self._task_config["target_ddl"],
|
| 172 |
last_execution_result="Error: Environment not initialized. Call reset() first.",
|
| 173 |
step_number=self._step_count,
|
| 174 |
+
migration_progress=0.01,
|
| 175 |
task_name=self.task_name,
|
| 176 |
metadata={"error": "not_initialized"},
|
| 177 |
)
|
|
|
|
| 200 |
current_score, step_reward = self._reconciler.compute_step_reward(self._conn)
|
| 201 |
|
| 202 |
# Episode termination: submit_final, max steps (20), OR perfect score
|
| 203 |
+
done = action.submit_final or self._step_count >= 20 or current_score >= 0.99
|
| 204 |
|
| 205 |
# Update state
|
| 206 |
self._state.step_count = self._step_count
|
server/grader.py
CHANGED
|
@@ -157,7 +157,7 @@ class StateReconciler:
|
|
| 157 |
if has_full_name and old_cols_gone and row_count == 0:
|
| 158 |
score = min(score, 0.1)
|
| 159 |
|
| 160 |
-
return
|
| 161 |
|
| 162 |
# =========================================================================
|
| 163 |
# Task 2: Table Normalization
|
|
@@ -223,7 +223,7 @@ class StateReconciler:
|
|
| 223 |
if c_count == 0 and o_count == 0:
|
| 224 |
score = min(score, 0.1)
|
| 225 |
|
| 226 |
-
return
|
| 227 |
|
| 228 |
# =========================================================================
|
| 229 |
# Task 3: Cascade Migration
|
|
@@ -343,4 +343,4 @@ class StateReconciler:
|
|
| 343 |
if "employees" in tables and _get_row_count(conn, "employees") == 0:
|
| 344 |
score = min(score, 0.1)
|
| 345 |
|
| 346 |
-
return
|
|
|
|
| 157 |
if has_full_name and old_cols_gone and row_count == 0:
|
| 158 |
score = min(score, 0.1)
|
| 159 |
|
| 160 |
+
return max(0.01, min(0.99, score))
|
| 161 |
|
| 162 |
# =========================================================================
|
| 163 |
# Task 2: Table Normalization
|
|
|
|
| 223 |
if c_count == 0 and o_count == 0:
|
| 224 |
score = min(score, 0.1)
|
| 225 |
|
| 226 |
+
return max(0.01, min(0.99, score))
|
| 227 |
|
| 228 |
# =========================================================================
|
| 229 |
# Task 3: Cascade Migration
|
|
|
|
| 343 |
if "employees" in tables and _get_row_count(conn, "employees") == 0:
|
| 344 |
score = min(score, 0.1)
|
| 345 |
|
| 346 |
+
return max(0.01, min(0.99, score))
|
test_smoke.py
CHANGED
|
@@ -58,7 +58,7 @@ conn.execute("ALTER TABLE users_new RENAME TO users")
|
|
| 58 |
conn.commit()
|
| 59 |
score = reconciler.score(conn)
|
| 60 |
print(f"PASS: Score after correct Task 1: {score:.2f}")
|
| 61 |
-
assert score ==
|
| 62 |
conn.close()
|
| 63 |
|
| 64 |
# Test 6: Full environment
|
|
@@ -88,9 +88,9 @@ for i, sql in enumerate(steps):
|
|
| 88 |
print(f" Step {i+1}: reward={obs.reward:.2f}, progress={obs.migration_progress:.2f}, done={obs.done}")
|
| 89 |
|
| 90 |
assert obs.done == True
|
| 91 |
-
assert obs.migration_progress ==
|
| 92 |
env.close()
|
| 93 |
-
print("PASS: Full migration episode completed with score
|
| 94 |
|
| 95 |
# Test 7: Task 2 grader
|
| 96 |
conn = sqlite3.connect(":memory:")
|
|
|
|
| 58 |
conn.commit()
|
| 59 |
score = reconciler.score(conn)
|
| 60 |
print(f"PASS: Score after correct Task 1: {score:.2f}")
|
| 61 |
+
assert score == 0.99, f"Expected 0.99, got {score}"
|
| 62 |
conn.close()
|
| 63 |
|
| 64 |
# Test 6: Full environment
|
|
|
|
| 88 |
print(f" Step {i+1}: reward={obs.reward:.2f}, progress={obs.migration_progress:.2f}, done={obs.done}")
|
| 89 |
|
| 90 |
assert obs.done == True
|
| 91 |
+
assert obs.migration_progress == 0.99, f"Expected 0.99, got {obs.migration_progress}"
|
| 92 |
env.close()
|
| 93 |
+
print("PASS: Full migration episode completed with score 0.99")
|
| 94 |
|
| 95 |
# Test 7: Task 2 grader
|
| 96 |
conn = sqlite3.connect(":memory:")
|