Spaces:
Sleeping
Sleeping
Upload 16 files
Browse files- inference.py +6 -1
- server/graders.py +9 -9
inference.py
CHANGED
|
@@ -285,6 +285,10 @@ Generate your next action (SQL or action name):"""
|
|
| 285 |
log_step(step=step, action=current_action, reward=0.0, done=False, error=error_msg)
|
| 286 |
break
|
| 287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 288 |
except Exception as e:
|
| 289 |
print(f"[DEBUG] Task execution failed: {e}", flush=True, file=sys.stderr)
|
| 290 |
|
|
@@ -323,7 +327,8 @@ def main():
|
|
| 323 |
success, steps, score, rewards = agent.run_task(TASK_NAME, seed=42)
|
| 324 |
|
| 325 |
# Log end
|
| 326 |
-
|
|
|
|
| 327 |
|
| 328 |
|
| 329 |
if __name__ == "__main__":
|
|
|
|
| 285 |
log_step(step=step, action=current_action, reward=0.0, done=False, error=error_msg)
|
| 286 |
break
|
| 287 |
|
| 288 |
+
# Fix: Ensure score is not 0.0 when loop ends without done=True
|
| 289 |
+
if not success and steps_taken == MAX_STEPS:
|
| 290 |
+
score = max(0.001, score)
|
| 291 |
+
|
| 292 |
except Exception as e:
|
| 293 |
print(f"[DEBUG] Task execution failed: {e}", flush=True, file=sys.stderr)
|
| 294 |
|
|
|
|
| 327 |
success, steps, score, rewards = agent.run_task(TASK_NAME, seed=42)
|
| 328 |
|
| 329 |
# Log end
|
| 330 |
+
safe_score = round(max(0.001, min(0.999, score)), 4)
|
| 331 |
+
log_end(success=success, steps=steps, score=safe_score, rewards=rewards)
|
| 332 |
|
| 333 |
|
| 334 |
if __name__ == "__main__":
|
server/graders.py
CHANGED
|
@@ -204,7 +204,7 @@ def _evaluate_fix_outcome(
|
|
| 204 |
return False, 0.0, False
|
| 205 |
|
| 206 |
if task_type == "type_repair":
|
| 207 |
-
target_col = ground_truth.get("column", ground_truth.get("target_column", "
|
| 208 |
if uploaded_mode:
|
| 209 |
try:
|
| 210 |
rows = test_conn.execute(
|
|
@@ -343,7 +343,7 @@ def _evaluate_fix_outcome(
|
|
| 343 |
return issue_resolved, preservation, True
|
| 344 |
|
| 345 |
if task_type == "null_audit":
|
| 346 |
-
target_col = ground_truth.get("column", ground_truth.get("null_column", "
|
| 347 |
if uploaded_mode:
|
| 348 |
try:
|
| 349 |
rows = test_conn.execute(
|
|
@@ -432,7 +432,7 @@ def _evaluate_fix_outcome(
|
|
| 432 |
return False, 0.0, True
|
| 433 |
|
| 434 |
if task_type == "dedup_bug":
|
| 435 |
-
key_cols = ground_truth.get("key_columns") or [ground_truth.get("column", ground_truth.get("offending_key", "
|
| 436 |
expected_clean = ground_truth.get("expected_clean_count", 0)
|
| 437 |
if uploaded_mode:
|
| 438 |
try:
|
|
@@ -488,7 +488,7 @@ def _evaluate_fix_outcome(
|
|
| 488 |
if task_type == "fk_integrity":
|
| 489 |
parent_table = ground_truth.get("parent_table", "customers")
|
| 490 |
parent_key = ground_truth.get("parent_key", "id")
|
| 491 |
-
fk_col = ground_truth.get("column", "
|
| 492 |
if uploaded_mode:
|
| 493 |
try:
|
| 494 |
orphan_count = test_conn.execute(
|
|
@@ -555,7 +555,7 @@ def _evaluate_fix_outcome(
|
|
| 555 |
if task_type == "schema_drift":
|
| 556 |
expected_columns = ground_truth.get(
|
| 557 |
"expected_columns",
|
| 558 |
-
[
|
| 559 |
)
|
| 560 |
expected_rows = ground_truth.get("expected_row_count", 0)
|
| 561 |
canonical_table = ground_truth.get("table", "canonical_events")
|
|
@@ -1027,7 +1027,7 @@ def compute_episode_score(
|
|
| 1027 |
d5 = 0.0
|
| 1028 |
if task_type == "dedup_bug":
|
| 1029 |
correct_table = ground_truth.get("table", "order_items").lower()
|
| 1030 |
-
correct_key = ground_truth.get("column", "
|
| 1031 |
table_ok = (submit_action.root_cause_table or "").lower() == correct_table
|
| 1032 |
key_ok = (submit_action.offending_key or "").lower() == correct_key
|
| 1033 |
if table_ok and key_ok:
|
|
@@ -1082,8 +1082,8 @@ def compute_episode_score(
|
|
| 1082 |
dimensions.update(null_meta)
|
| 1083 |
|
| 1084 |
return SQLReward(
|
| 1085 |
-
score=final_score,
|
| 1086 |
-
step_reward=final_score,
|
| 1087 |
feedback=" | ".join(feedback_parts),
|
| 1088 |
dimensions=dimensions,
|
| 1089 |
partial_scores={
|
|
@@ -1193,7 +1193,7 @@ def grade_dedup_bug(
|
|
| 1193 |
"""Single-step dedup_bug scorer for exploit checks and compatibility."""
|
| 1194 |
fix_sql = (action.fix_query or action.sql or "").strip()
|
| 1195 |
target_table = ground_truth.get("table", ground_truth.get("root_cause_table", "order_items"))
|
| 1196 |
-
target_key = ground_truth.get("column", ground_truth.get("offending_key", "
|
| 1197 |
table_ok = (action.root_cause_table or "").lower() == target_table.lower()
|
| 1198 |
key_ok = (action.offending_key or "").lower() == target_key.lower()
|
| 1199 |
partial_scores = {
|
|
|
|
| 204 |
return False, 0.0, False
|
| 205 |
|
| 206 |
if task_type == "type_repair":
|
| 207 |
+
target_col = ground_truth.get("column", ground_truth.get("target_column", ""))
|
| 208 |
if uploaded_mode:
|
| 209 |
try:
|
| 210 |
rows = test_conn.execute(
|
|
|
|
| 343 |
return issue_resolved, preservation, True
|
| 344 |
|
| 345 |
if task_type == "null_audit":
|
| 346 |
+
target_col = ground_truth.get("column", ground_truth.get("null_column", ""))
|
| 347 |
if uploaded_mode:
|
| 348 |
try:
|
| 349 |
rows = test_conn.execute(
|
|
|
|
| 432 |
return False, 0.0, True
|
| 433 |
|
| 434 |
if task_type == "dedup_bug":
|
| 435 |
+
key_cols = ground_truth.get("key_columns") or [ground_truth.get("column", ground_truth.get("offending_key", ""))]
|
| 436 |
expected_clean = ground_truth.get("expected_clean_count", 0)
|
| 437 |
if uploaded_mode:
|
| 438 |
try:
|
|
|
|
| 488 |
if task_type == "fk_integrity":
|
| 489 |
parent_table = ground_truth.get("parent_table", "customers")
|
| 490 |
parent_key = ground_truth.get("parent_key", "id")
|
| 491 |
+
fk_col = ground_truth.get("column", "")
|
| 492 |
if uploaded_mode:
|
| 493 |
try:
|
| 494 |
orphan_count = test_conn.execute(
|
|
|
|
| 555 |
if task_type == "schema_drift":
|
| 556 |
expected_columns = ground_truth.get(
|
| 557 |
"expected_columns",
|
| 558 |
+
[],
|
| 559 |
)
|
| 560 |
expected_rows = ground_truth.get("expected_row_count", 0)
|
| 561 |
canonical_table = ground_truth.get("table", "canonical_events")
|
|
|
|
| 1027 |
d5 = 0.0
|
| 1028 |
if task_type == "dedup_bug":
|
| 1029 |
correct_table = ground_truth.get("table", "order_items").lower()
|
| 1030 |
+
correct_key = ground_truth.get("column", "").lower()
|
| 1031 |
table_ok = (submit_action.root_cause_table or "").lower() == correct_table
|
| 1032 |
key_ok = (submit_action.offending_key or "").lower() == correct_key
|
| 1033 |
if table_ok and key_ok:
|
|
|
|
| 1082 |
dimensions.update(null_meta)
|
| 1083 |
|
| 1084 |
return SQLReward(
|
| 1085 |
+
score=_clamp(final_score),
|
| 1086 |
+
step_reward=_clamp(final_score),
|
| 1087 |
feedback=" | ".join(feedback_parts),
|
| 1088 |
dimensions=dimensions,
|
| 1089 |
partial_scores={
|
|
|
|
| 1193 |
"""Single-step dedup_bug scorer for exploit checks and compatibility."""
|
| 1194 |
fix_sql = (action.fix_query or action.sql or "").strip()
|
| 1195 |
target_table = ground_truth.get("table", ground_truth.get("root_cause_table", "order_items"))
|
| 1196 |
+
target_key = ground_truth.get("column", ground_truth.get("offending_key", ""))
|
| 1197 |
table_ok = (action.root_cause_table or "").lower() == target_table.lower()
|
| 1198 |
key_ok = (action.offending_key or "").lower() == target_key.lower()
|
| 1199 |
partial_scores = {
|