Akshaya Kumar commited on
Commit
2ef23a4
·
1 Parent(s): 7a539e6

fix: clamp all scores to strictly open interval (0.0, 1.0)

Browse files

Phase 2 failed: 'One or more task scores are out of range'.
Hackathon requires reward strictly between 0 and 1 (not 0.0, not 1.0).

Changes:
- grader.py: clamp final score to (0.01, 0.99) instead of [0.0, 1.0]
- environment.py: reset() now returns reward=0.01 (not 0.0)

Verified: all 4 query types across all 3 tasks now produce scores
strictly in the open interval (0, 1). Max possible = 0.99.

Files changed (2) hide show
  1. server/environment.py +1 -1
  2. server/grader.py +9 -5
server/environment.py CHANGED
@@ -151,7 +151,7 @@ class SQLDebugEnvironment(Environment[SQLAction, SQLObservation, SQLState]):
151
  error_message=err,
152
  result_preview=preview,
153
  current_row_count=current_count,
154
- reward_value=0.0,
155
  is_done=False,
156
  )
157
 
 
151
  error_message=err,
152
  result_preview=preview,
153
  current_row_count=current_count,
154
+ reward_value=0.01, # strictly > 0.0 — hackathon requires open interval (0, 1)
155
  is_done=False,
156
  )
157
 
server/grader.py CHANGED
@@ -1,7 +1,7 @@
1
  """
2
  Grading logic for submitted SQL queries.
3
 
4
- We compute a 4-part reward score between 0 and 1:
5
  - 0.15 for syntax (does it even parse?)
6
  - 0.55 for row-level F1 (how many right rows did you get?)
7
  - 0.20 exact match bonus (nailed it perfectly)
@@ -94,7 +94,8 @@ def grade(
94
  ) -> tuple[float, dict[str, Any]]:
95
  """Grade a submitted query against the reference answer.
96
 
97
- Returns (score, info) where score is 0-1 and info has
 
98
  the per-component breakdown for debugging.
99
  """
100
  info: dict[str, Any] = {
@@ -122,13 +123,13 @@ def grade(
122
  except Exception as e:
123
  info["error_message"] = str(e)
124
  # No point checking anything else if the syntax is broken
125
- return max(0.0, min(score, 1.0)), info
126
 
127
  # --- Run both queries ---
128
  submitted_rows, submit_err = _run_query(conn, submitted_query)
129
  if submit_err:
130
  info["error_message"] = submit_err
131
- return max(0.0, min(score, 1.0)), info
132
 
133
  expected_rows, _ = _run_query(conn, correct_query)
134
 
@@ -157,4 +158,7 @@ def grade(
157
  info["efficiency_score"] = 0.10
158
  score += 0.10
159
 
160
- return round(max(0.0, min(score, 1.0)), 4), info
 
 
 
 
1
  """
2
  Grading logic for submitted SQL queries.
3
 
4
+ We compute a 4-part reward score strictly between 0 and 1 (exclusive):
5
  - 0.15 for syntax (does it even parse?)
6
  - 0.55 for row-level F1 (how many right rows did you get?)
7
  - 0.20 exact match bonus (nailed it perfectly)
 
94
  ) -> tuple[float, dict[str, Any]]:
95
  """Grade a submitted query against the reference answer.
96
 
97
+ Returns (score, info) where score is strictly in the open interval
98
+ (0.0, 1.0) — i.e. never exactly 0.0 or 1.0 — and info has
99
  the per-component breakdown for debugging.
100
  """
101
  info: dict[str, Any] = {
 
123
  except Exception as e:
124
  info["error_message"] = str(e)
125
  # No point checking anything else if the syntax is broken
126
+ return max(0.01, min(score, 0.99)), info
127
 
128
  # --- Run both queries ---
129
  submitted_rows, submit_err = _run_query(conn, submitted_query)
130
  if submit_err:
131
  info["error_message"] = submit_err
132
+ return max(0.01, min(score, 0.99)), info
133
 
134
  expected_rows, _ = _run_query(conn, correct_query)
135
 
 
158
  info["efficiency_score"] = 0.10
159
  score += 0.10
160
 
161
+ # Clamp to strictly open interval (0.0, 1.0) — hackathon requires this.
162
+ # Minimum 0.01: a syntactically valid query earns at least a tiny reward.
163
+ # Maximum 0.99: no query is considered "perfect" by the grader.
164
+ return round(max(0.01, min(score, 0.99)), 4), info