Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- inference.py +13 -16
- openenv.yaml +5 -0
inference.py
CHANGED
|
@@ -47,7 +47,11 @@ API_KEY = (
|
|
| 47 |
LOCAL_IMAGE_NAME = os.getenv("LOCAL_IMAGE_NAME")
|
| 48 |
|
| 49 |
# SQL Quality Environment specific variables
|
| 50 |
-
ENV_BASE_URL =
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
TASK_NAME = os.getenv("SQL_QUALITY_TASK", "null_audit")
|
| 52 |
BENCHMARK = "sql_quality_env"
|
| 53 |
MAX_STEPS = 20
|
|
@@ -254,10 +258,13 @@ Generate your next action (SQL or action name):"""
|
|
| 254 |
"SELECT id, user_id, "
|
| 255 |
"CAST(amount AS REAL) as amount, "
|
| 256 |
"description, category, date, "
|
| 257 |
-
"transaction_date FROM transactions
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
"
|
|
|
|
|
|
|
|
|
|
| 261 |
None),
|
| 262 |
("submit", None, ""),
|
| 263 |
],
|
|
@@ -370,18 +377,8 @@ Generate your next action (SQL or action name):"""
|
|
| 370 |
answer = None
|
| 371 |
|
| 372 |
try:
|
| 373 |
-
data = {
|
| 374 |
-
"task_id": task_id,
|
| 375 |
-
"episode_id": self.episode_id,
|
| 376 |
-
"action_type": action_type,
|
| 377 |
-
}
|
| 378 |
-
if sql:
|
| 379 |
-
data["sql"] = sql
|
| 380 |
-
if answer is not None:
|
| 381 |
-
data["answer"] = answer
|
| 382 |
-
|
| 383 |
step_result = self.step(
|
| 384 |
-
action_type, sql,
|
| 385 |
)
|
| 386 |
reward_data = step_result.get("reward", {})
|
| 387 |
reward = reward_data.get("step_reward", 0.0)
|
|
|
|
| 47 |
LOCAL_IMAGE_NAME = os.getenv("LOCAL_IMAGE_NAME")
|
| 48 |
|
| 49 |
# SQL Quality Environment specific variables
|
| 50 |
+
ENV_BASE_URL = (
|
| 51 |
+
os.getenv("ENV_BASE_URL") or
|
| 52 |
+
os.getenv("SPACE_URL") or
|
| 53 |
+
"https://deadman922-sql-quality-env.hf.space"
|
| 54 |
+
)
|
| 55 |
TASK_NAME = os.getenv("SQL_QUALITY_TASK", "null_audit")
|
| 56 |
BENCHMARK = "sql_quality_env"
|
| 57 |
MAX_STEPS = 20
|
|
|
|
| 258 |
"SELECT id, user_id, "
|
| 259 |
"CAST(amount AS REAL) as amount, "
|
| 260 |
"description, category, date, "
|
| 261 |
+
"transaction_date FROM transactions",
|
| 262 |
+
None),
|
| 263 |
+
("fix",
|
| 264 |
+
"DROP TABLE transactions",
|
| 265 |
+
None),
|
| 266 |
+
("fix",
|
| 267 |
+
"ALTER TABLE transactions_new RENAME TO transactions",
|
| 268 |
None),
|
| 269 |
("submit", None, ""),
|
| 270 |
],
|
|
|
|
| 377 |
answer = None
|
| 378 |
|
| 379 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
step_result = self.step(
|
| 381 |
+
action_type, sql, None
|
| 382 |
)
|
| 383 |
reward_data = step_result.get("reward", {})
|
| 384 |
reward = reward_data.get("step_reward", 0.0)
|
openenv.yaml
CHANGED
|
@@ -29,6 +29,7 @@ tasks:
|
|
| 29 |
grader: true
|
| 30 |
has_grader: true
|
| 31 |
scored: true
|
|
|
|
| 32 |
- id: type_repair
|
| 33 |
difficulty: medium
|
| 34 |
description: "Fix numeric type mismatch in transaction records"
|
|
@@ -36,6 +37,7 @@ tasks:
|
|
| 36 |
grader: true
|
| 37 |
has_grader: true
|
| 38 |
scored: true
|
|
|
|
| 39 |
- id: dedup_bug
|
| 40 |
difficulty: hard
|
| 41 |
description: "Find and repair duplication bug inflating join volumes"
|
|
@@ -43,6 +45,7 @@ tasks:
|
|
| 43 |
grader: true
|
| 44 |
has_grader: true
|
| 45 |
scored: true
|
|
|
|
| 46 |
- id: fk_integrity
|
| 47 |
difficulty: hard
|
| 48 |
description: "Remove orphan child records violating referential integrity"
|
|
@@ -50,6 +53,7 @@ tasks:
|
|
| 50 |
grader: true
|
| 51 |
has_grader: true
|
| 52 |
scored: true
|
|
|
|
| 53 |
- id: schema_drift
|
| 54 |
difficulty: medium
|
| 55 |
description: "Normalize drifted schemas into canonical analytics artifact"
|
|
@@ -57,3 +61,4 @@ tasks:
|
|
| 57 |
grader: true
|
| 58 |
has_grader: true
|
| 59 |
scored: true
|
|
|
|
|
|
| 29 |
grader: true
|
| 30 |
has_grader: true
|
| 31 |
scored: true
|
| 32 |
+
grader_fn: "server.graders:grade_null_audit"
|
| 33 |
- id: type_repair
|
| 34 |
difficulty: medium
|
| 35 |
description: "Fix numeric type mismatch in transaction records"
|
|
|
|
| 37 |
grader: true
|
| 38 |
has_grader: true
|
| 39 |
scored: true
|
| 40 |
+
grader_fn: "server.graders:grade_type_repair"
|
| 41 |
- id: dedup_bug
|
| 42 |
difficulty: hard
|
| 43 |
description: "Find and repair duplication bug inflating join volumes"
|
|
|
|
| 45 |
grader: true
|
| 46 |
has_grader: true
|
| 47 |
scored: true
|
| 48 |
+
grader_fn: "server.graders:grade_dedup_bug"
|
| 49 |
- id: fk_integrity
|
| 50 |
difficulty: hard
|
| 51 |
description: "Remove orphan child records violating referential integrity"
|
|
|
|
| 53 |
grader: true
|
| 54 |
has_grader: true
|
| 55 |
scored: true
|
| 56 |
+
grader_fn: "server.graders:compute_episode_score"
|
| 57 |
- id: schema_drift
|
| 58 |
difficulty: medium
|
| 59 |
description: "Normalize drifted schemas into canonical analytics artifact"
|
|
|
|
| 61 |
grader: true
|
| 62 |
has_grader: true
|
| 63 |
scored: true
|
| 64 |
+
grader_fn: "server.graders:compute_episode_score"
|