(self, index, session: Session)
| 358 | return ret |
| 359 | |
| 360 | async def start_sample(self, index, session: Session) -> TaskSampleExecutionResult: |
| 361 | if not self.env_controller_background_task: |
| 362 | self.env_controller_background_task = asyncio.create_task(self.env_controller.background_task()) |
| 363 | weakref.finalize(self, self.env_controller_background_task.cancel) |
| 364 | |
| 365 | logging.info(f"Starting sample with index: {index}") |
| 366 | data_item = self.problem_configs[index] |
| 367 | config = data_item["config"] |
| 368 | file = data_item["file"] |
| 369 | index_in_file = data_item["index"] |
| 370 | |
| 371 | container = Container(self.env_controller, config.image) |
| 372 | try: |
| 373 | logging.info("Initializing container") |
| 374 | await container.initialize() |
| 375 | logging.info("Container initialized successfully") |
| 376 | |
| 377 | logging.info("Starting judge process") |
| 378 | result = await self._judge(session, config, container) |
| 379 | result.result["file"] = file |
| 380 | result.result["index_in_file"] = index_in_file |
| 381 | logging.info(f"Judge process completed with status: {result.status}") |
| 382 | return result |
| 383 | except AgentCancelledException: |
| 384 | session.inject(RewardHistoryItem(reward=0, score=0)) |
| 385 | return TaskSampleExecutionResult(status=SampleStatus.CANCELLED) |
| 386 | except: |
| 387 | logging.exception(f"Error in start_sample") |
| 388 | session.inject(RewardHistoryItem(reward=0, score=0)) |
| 389 | return TaskSampleExecutionResult( |
| 390 | status=SampleStatus.TASK_ERROR, |
| 391 | result={"result": False, "error": traceback.format_exc()}, |
| 392 | ) |
| 393 | finally: |
| 394 | try: |
| 395 | await container.cleanup() |
| 396 | except Exception as e: |
| 397 | logging.error(f"Error during container cleanup: {str(e)}") |
| 398 | |
| 399 | async def _judge( |
| 400 | self, session: Session, config: JudgeConfig, container: Container |
nothing calls this directly
no test coverage detected