CC_flows / CF_CodeTesting.py
martinjosifoski's picture
Add an abstract CodeTesting Flow and working CF_CodeTesting Flow.
6fffc74
raw
history blame
1.1 kB
from typing import Any, Dict
from flows import utils
from .src.evaluation import testing_utils_codeforces
from .CodeTesting import CodeTesting
log = utils.get_pylogger(__name__)
# ToDo: Add a flags to control whether hidden, public or both tests should be used for evaluation
class CF_CodeTesting(CodeTesting):
REQUIRED_KEYS_CONFIG = []
REQUIRED_KEYS_KWARGS = []
def __init__(self, **kwargs):
super().__init__(**kwargs)
def _get_test_data(self, input_data: Dict):
"""This function retrieves (or generates) input-output pairs that will be used to test the implementation."""
return input_data["public_tests_individual_io"]
def _run_tests(self, input_data: Dict, test_data: Dict) -> Dict[str, Any]:
testing_results = testing_utils_codeforces.evaluate_solution_for_problem(
candidate_solution=input_data["code"],
public_tests_io=test_data
)
for test_output in testing_results["public_tests_results"]:
test_output["input"] = "\n".join(test_output["input"])
return testing_results