-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsynthesizer_python.py
More file actions
38 lines (33 loc) · 2.07 KB
/
synthesizer_python.py
File metadata and controls
38 lines (33 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import tempfile
import subprocess
import time
from typing import Optional
from synthesizer import ProgramSynthesizer
from logger import SynthesisLogger
from report import EvaluationReport
from dataset import ProgramSynthesisDatapoint
class PythonProgramSynthesizer(ProgramSynthesizer):
def __init__(self, prompting_method: str = "zero_shot", model_name: str = "gemini-1.5-flash",
api_key: Optional[str] = None, logger: Optional[SynthesisLogger] = None):
super().__init__("python", prompting_method, model_name, api_key, logger)
def evaluate(self, datapoint: ProgramSynthesisDatapoint, synthesized_program: str) -> EvaluationReport:
"""Evaluate Python program with comprehensive execution testing."""
report = EvaluationReport(synthesized_program)
# Create temporary directory for execution
with tempfile.TemporaryDirectory() as temp_dir:
################################################################################
# #
# TODO: Part 1a. Evaluate Python program with comprehensive execution testing. #
# #
# Populate the report with the evaluation results. Check for syntax errors, #
# runtime errors, and test cases (which are in datapoint.sample_inputs and #
# datapoint.sample_outputs). #
# #
# To run the program, you can create a temporary file and write the program to #
# it. Then, you can use subprocess to run the program with the test cases. #
# #
################################################################################
pass
report.finalize()
return report