Spaces:
Sleeping
Sleeping
jjyang77
commited on
Commit
·
7cb9920
1
Parent(s):
da384b4
api samples input just List[dict]
Browse files- api/app.py +1 -11
- api/bigcodebench_data.py +9 -0
api/app.py
CHANGED
|
@@ -7,8 +7,6 @@ from concurrent.futures import ProcessPoolExecutor, as_completed
|
|
| 7 |
from typing import Dict, List, Tuple
|
| 8 |
import gc
|
| 9 |
|
| 10 |
-
from pydantic import BaseModel
|
| 11 |
-
|
| 12 |
from fastapi import FastAPI
|
| 13 |
from fastapi.responses import RedirectResponse
|
| 14 |
|
|
@@ -17,14 +15,6 @@ from api.code_execution import untrusted_check
|
|
| 17 |
|
| 18 |
Result = Tuple[str, List[bool]]
|
| 19 |
|
| 20 |
-
class SampleDate(BaseModel):
|
| 21 |
-
task_id: str
|
| 22 |
-
solution: str
|
| 23 |
-
code_prompt: str
|
| 24 |
-
test: str
|
| 25 |
-
entry_point: str
|
| 26 |
-
res_id: int
|
| 27 |
-
|
| 28 |
def create_app() -> FastAPI:
|
| 29 |
|
| 30 |
level = os.environ.get("LOG_LEVEL", default=logging.INFO)
|
|
@@ -43,7 +33,7 @@ def create_app() -> FastAPI:
|
|
| 43 |
|
| 44 |
@app.post("/evaluate/")
|
| 45 |
async def evaluate(
|
| 46 |
-
samples: List[
|
| 47 |
calibrate: bool = True,
|
| 48 |
parallel: int = -1,
|
| 49 |
min_time_limit: float = 1,
|
|
|
|
| 7 |
from typing import Dict, List, Tuple
|
| 8 |
import gc
|
| 9 |
|
|
|
|
|
|
|
| 10 |
from fastapi import FastAPI
|
| 11 |
from fastapi.responses import RedirectResponse
|
| 12 |
|
|
|
|
| 15 |
|
| 16 |
Result = Tuple[str, List[bool]]
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def create_app() -> FastAPI:
|
| 19 |
|
| 20 |
level = os.environ.get("LOG_LEVEL", default=logging.INFO)
|
|
|
|
| 33 |
|
| 34 |
@app.post("/evaluate/")
|
| 35 |
async def evaluate(
|
| 36 |
+
samples: List[dict],
|
| 37 |
calibrate: bool = True,
|
| 38 |
parallel: int = -1,
|
| 39 |
min_time_limit: float = 1,
|
api/bigcodebench_data.py
CHANGED
|
@@ -24,6 +24,15 @@ def load_solutions(samples) -> Iterable[Dict]:
|
|
| 24 |
"""
|
| 25 |
"""
|
| 26 |
for i, sample in enumerate(samples):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
sample["_identifier"] = (
|
| 28 |
sample["task_id"] + f" (line {i+1} )"
|
| 29 |
)
|
|
|
|
| 24 |
"""
|
| 25 |
"""
|
| 26 |
for i, sample in enumerate(samples):
|
| 27 |
+
assert "task_id" in sample, "No task_id found in sample!"
|
| 28 |
+
assert "res_id" in sample, "No res_id found in sample!"
|
| 29 |
+
assert "test" in sample, "No test found in sample!"
|
| 30 |
+
assert "solution" in sample, "No solution found in sample!"
|
| 31 |
+
assert "entry_point" in sample, "No entry_point found in sample!"
|
| 32 |
+
assert isinstance(
|
| 33 |
+
sample["solution"], str
|
| 34 |
+
), "Solution must be a string! If you have multiple solutions, please repeat the task_id."
|
| 35 |
+
|
| 36 |
sample["_identifier"] = (
|
| 37 |
sample["task_id"] + f" (line {i+1} )"
|
| 38 |
)
|