| 41 | |
| 42 | @dataclass |
| 43 | class CodeGenerationProblem: |
| 44 | question_title: str |
| 45 | question_content: str |
| 46 | platform: Platform |
| 47 | question_id: str |
| 48 | contest_id: str |
| 49 | contest_date: datetime |
| 50 | starter_code: str |
| 51 | difficulty: Difficulty |
| 52 | public_test_cases: list[Test] |
| 53 | private_test_cases: list[Test] |
| 54 | metadata: dict |
| 55 | |
| 56 | def __post_init__(self): |
| 57 | self.platform = Platform(self.platform) |
| 58 | self.difficulty = Difficulty(self.difficulty) |
| 59 | self.contest_date = datetime.fromisoformat(self.contest_date) |
| 60 | |
| 61 | self.public_test_cases = json.loads(self.public_test_cases) # type: ignore |
| 62 | self.public_test_cases = [Test(**t) for t in self.public_test_cases] |
| 63 | |
| 64 | try: |
| 65 | self.private_test_cases = json.loads(self.private_test_cases) # type: ignore |
| 66 | except: |
| 67 | self.private_test_cases = json.loads( |
| 68 | pickle.loads( |
| 69 | zlib.decompress( |
| 70 | base64.b64decode(self.private_test_cases.encode("utf-8")) # type: ignore |
| 71 | ) |
| 72 | ) |
| 73 | ) # type: ignore |
| 74 | self.private_test_cases = [Test(**t) for t in self.private_test_cases] |
| 75 | |
| 76 | self.metadata = json.loads(self.metadata) # type: ignore |
| 77 | |
| 78 | def insert_output(self, output_list: list[str], code_list: list[str]) -> dict: |
| 79 | return { |
| 80 | "question_title": self.question_title, |
| 81 | "question_content": self.question_content, |
| 82 | "platform": self.platform.value, |
| 83 | "question_id": self.question_id, |
| 84 | "contest_id": self.contest_id, |
| 85 | "contest_date": self.contest_date.isoformat(), |
| 86 | "starter_code": self.starter_code, |
| 87 | "difficulty": self.difficulty.value, |
| 88 | "output_list": output_list, |
| 89 | "code_list": code_list, |
| 90 | } |
| 91 | |
| 92 | def insert_output_evaluation( |
| 93 | self, |
| 94 | output_list: list[str], |
| 95 | code_list: list[str], |
| 96 | graded_list: list[bool], |
| 97 | **kwargs, |
| 98 | ) -> dict: |
| 99 | output = self.insert_output(output_list, code_list) |
| 100 | output["graded_list"] = graded_list |
no outgoing calls
no test coverage detected