예제 #1
0
파일: tests.py 프로젝트: sjoerdk/codalab
        def single_run(a_id, a_args):
            """
            Create a job status update task, run it, query for the job and return it.

            a_id: job ID
            a_args: job status update task arguments
            """
            models.update_job_status_task(a_id, a_args)
            return Job.objects.get(pk=job.id)
예제 #2
0
파일: tests.py 프로젝트: Dryuna/codalab
        def single_run(a_id, a_args):
            """
            Create a job status update task, run it, query for the job and return it.

            a_id: job ID
            a_args: job status update task arguments
            """
            models.update_job_status_task(a_id, a_args)
            return Job.objects.get(pk=job.id)
예제 #3
0
 def test_update_task_with_info(self):
     """
     Test setting and getting custom info on a job.
     """
     job = Job.objects.create()
     self.assertIsNotNone(job)
     self.assertEqual(job.status, Job.PENDING)
     info = { 'key1': "value1", 'key2' : 2 }
     models.update_job_status_task(job.id, { 'status': 'finished', 'info' : info })
     job = Job.objects.get(pk=job.id)
     self.assertEqual(job.status, Job.FINISHED)
     self.assertDictEqual(job.get_task_info(), info)
     job.delete()
예제 #4
0
파일: tests.py 프로젝트: Dryuna/codalab
 def test_update_task_with_info(self):
     """
     Test setting and getting custom info on a job.
     """
     job = Job.objects.create()
     self.assertIsNotNone(job)
     self.assertEqual(job.status, Job.PENDING)
     info = { 'key1': "value1", 'key2' : 2 }
     models.update_job_status_task(job.id, { 'status': 'finished', 'info' : info })
     job = Job.objects.get(pk=job.id)
     self.assertEqual(job.status, Job.FINISHED)
     self.assertDictEqual(job.get_task_info(), info)
     job.delete()
예제 #5
0
def create_competition(job_id, comp_def_id):
    """
    A task to create a competition from a bundle with the competition's definition.

    job_id: The ID of the job.
    args: A dictionary with the arguments for the task. Expected items are:
        args['comp_def_id']: The ID of the bundle holding the competition definition.
    Once the task succeeds, a new competition will be ready to use in CodaLab.
    """

    logger.info("Creating competition for competition bundle (bundle_id=%s)", comp_def_id)
    competition_def = CompetitionDefBundle.objects.get(pk=comp_def_id)
    try:
        competition = competition_def.unpack()
        result = JobTaskResult(status=Job.FINISHED, info={'competition_id': competition.pk})
        update_job_status_task(job_id, result.get_dict())
        logger.info("Created competition for competition bundle (bundle_id=%s, comp_id=%s)",
                    comp_def_id, competition.pk)

    except Exception as e:
        result = JobTaskResult(status=Job.FAILED, info={'error': str(e)})
        update_job_status_task(job_id, result.get_dict())