Ejemplo n.º 1
0
    def _deliver_submission(self, submission):
        payload = {'xqueue_body': submission.xqueue_body,
                   'xqueue_files': submission.s3_urls}

        submission.grader_id = self.worker_url
        submission.push_time = timezone.now()
        start = time.time()
        (grading_success, grader_reply) = _http_post(self.worker_url, json.dumps(payload), settings.GRADING_TIMEOUT)
        statsd.histogram('xqueue.consumer.consumer_callback.grading_time', time.time() - start,
                         tags=['queue:{0}'.format(self.queue_name)])

        job_count = get_queue_length(self.queue_name)
        statsd.gauge('xqueue.consumer.consumer_callback.queue_length', job_count,
                     tags=['queue:{0}'.format(self.queue_name)])

        submission.return_time = timezone.now()

        # TODO: For the time being, a submission in a push interface gets one chance at grading,
        #       with no requeuing logic
        if grading_success:
            submission.grader_reply = grader_reply
            submission.lms_ack = post_grade_to_lms(submission.xqueue_header, grader_reply)
        else:
            log.error("Submission {} to grader {} failure: Reply: {}, ".format(submission.id, self.worker_url, grader_reply))
            submission.num_failures += 1
            submission.lms_ack = post_failure_to_lms(submission.xqueue_header)

        # NOTE: retiring pushed submissions after one shot regardless of grading_success
        submission.retired = True

        submission.save()
Ejemplo n.º 2
0
    def _deliver_submission(self, submission):
        payload = {
            'xqueue_body': submission.xqueue_body,
            'xqueue_files': submission.urls
        }

        submission.grader_id = self.worker_url
        submission.push_time = timezone.now()
        start = time.time()
        (grading_success, grader_reply) = _http_post(self.worker_url,
                                                     json.dumps(payload),
                                                     settings.GRADING_TIMEOUT)
        grading_time = time.time() - start
        statsd.histogram('xqueue.consumer.consumer_callback.grading_time',
                         grading_time,
                         tags=['queue:{0}'.format(self.queue_name)])

        if grading_time > settings.GRADING_TIMEOUT:
            log.error(
                "Grading time above {} for submission. grading_time: {}s body: {} files: {}"
                .format(settings.GRADING_TIMEOUT, grading_time,
                        submission.xqueue_body, submission.urls))

        job_count = get_queue_length(self.queue_name)
        statsd.gauge('xqueue.consumer.consumer_callback.queue_length',
                     job_count,
                     tags=['queue:{0}'.format(self.queue_name)])

        submission.return_time = timezone.now()

        # TODO: For the time being, a submission in a push interface gets one chance at grading,
        #       with no requeuing logic
        if grading_success:
            submission.grader_reply = grader_reply
            submission.lms_ack = post_grade_to_lms(submission.xqueue_header,
                                                   grader_reply)
        else:
            log.error("Submission {} to grader {} failure: Reply: {}, ".format(
                submission.id, self.worker_url, grader_reply))
            submission.num_failures += 1
            submission.lms_ack = post_failure_to_lms(submission.xqueue_header)

        # NOTE: retiring pushed submissions after one shot regardless of grading_success
        submission.retired = True

        submission.save()