def prepare_task(self): info = { "solution_id": 1000, "code": self.get_code(), "language": self.get_language(), "time_limit": 100, "memory_limit": 100, } task = Task() task.load(info) return task
def testReturn(self): self.skipTest('not finished') executor = Runner() executor.set_image('runner:test') task = Task() task.working_dir = tempfile.mkdtemp('runner_test') info = {'time_limit': 1, 'memory_limit': 2, 'solution_id': 3} task.set_info(info) executor.execute(task.working_dir) self.assertTrue(executor.is_ok()) result = CaseResult() result.parse_runner(executor.get_stdout()) self.assertEqual(result.result, 4) self.assertEqual(result.time_cost, 7) self.assertEqual(result.memory_cost, 200)
def main(): parser = argparse.ArgumentParser( description='Quick execute container task') parser.add_argument('--path', metavar='-p', type=str, required=True, help='path to the working dir') parser.add_argument('--memory', metavar='-m', type=int, default=10, help='memory limit (default: 10)') args = parser.parse_args() task = Task() task.set_info({'memory_limit': args.memory, 'solution_id': 10000}) task.working_dir = args.path run(task)
def run(self): dispatcher = TaskCentre(self.cfg.message_queue) while not self.should_stop(): self.idle_mark() job = dispatcher.get_job() if job: logger.info("New task arrive: {job}".format(job=job)) worker = Worker(self.cfg, self.api) task = Task.from_json(job) worker.process(task, self.get_data_provider(task.problem_id)) else: self.take_rest()
def handle(self, job): try: worker = Worker() task = Task.from_json(job) if task.language_type.language_id == 3: LOGGER.info('java current is not support now') return if task.is_special: LOGGER.info('special judge is not support now') return worker.process(task, self.dataProvider.get_data(task.problem_id)) if worker.has_exception: return result = worker.get_result() self.api.report(result) except JudgeException as e: LOGGER.error("task failed! {job}: {err}".format(job=job, err=e))