Skip to content

Commit

Permalink
Fix Cloud-CV#2209: Add a feature to re-reun a submission by challenge…
Browse files Browse the repository at this point in the history
… host using UI
  • Loading branch information
Sanji515 committed May 25, 2019
1 parent ec1a264 commit 5394377
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apps/jobs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
name="get_remaining_submissions",
),
url(
r'^re_run_submission/(?P<submission_number>[0-9]+)$',
r'^re_run_submission/(?P<submission_id>[0-9]+)$',
views.re_run_submission, name='re_run_submission'
),
url(
Expand Down
18 changes: 13 additions & 5 deletions apps/jobs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import json
import logging
import time

from rest_framework import permissions, status
from rest_framework.decorators import (
Expand Down Expand Up @@ -937,17 +938,17 @@ def update_submission(request, challenge_pk):
@throttle_classes([UserRateThrottle, ])
@permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
@authentication_classes((ExpiringTokenAuthentication,))
def re_run_submission(request, submission_number):
def re_run_submission(request, submission_id):
"""
API endpoint to re-run a submission.
Only challenge host has access to this endpoint.
"""
try:
submission = Submission.objects.get(submission_number=submission_number)
submission = Submission.objects.get(id=submission_id)
logger.info('Submission found with submission number {}'
.format(submission_number))
.format(submission_id))
except Submission.DoesNotExist:
response_data = {'error': 'Submission with submission number {} does not exist'.format(submission_number)}
response_data = {'error': 'Submission with submission number {} does not exist'.format(submission_id)}
return Response(response_data, status=status.HTTP_404_NOT_FOUND)

# check if the challenge phase exists or not
Expand Down Expand Up @@ -983,7 +984,14 @@ def re_run_submission(request, submission_number):
return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)
try:
publish_submission_message(challenge_id, challenge_phase_id, submission.id)
response_data = {'success': 'Submission result has been successfully updated'}
time.sleep(1)
submission = Submission.objects.get(id=submission_id)
response_data = {
'submission_status': submission.status,
'submission_execution_time': submission.execution_time,
'submission_number': submission.submission_number,
'success': 'Submission result has been successfully updated'
}
return Response(response_data, status=status.HTTP_200_OK)
except Exception as e:
logger.info('Error occured while sending to queue: {}'.format(str(e)))
Expand Down
22 changes: 22 additions & 0 deletions frontend/src/css/modules/challenge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,25 @@ md-select.md-default-theme .md-select-value span:first-child:after, md-select .m
#option-text-color {
color: #252833;
}

@-webkit-keyframes spin {
from { -webkit-transform: rotate(0deg); }
to { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
from {transform:rotate(0deg);}
to {transform:rotate(360deg);}
}


.spin {
-webkit-animation: spin 1s linear infinite;
animation: spin 1s linear infinite;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}

.progress-indicator {
width: 14px;
}
19 changes: 13 additions & 6 deletions frontend/src/js/controllers/challengeCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,26 +890,33 @@
utilities.sendRequest(parameters);
};

vm.rerunSubmission = function(submission_number) {
parameters.url = 'jobs/re_run_submission/' + submission_number;
vm.rerunSubmission = function(submissionObject) {
submissionObject.classList = ['spin', 'progress-indicator'];
parameters.url = 'jobs/re_run_submission/' + submissionObject.id;
parameters.method = 'POST';
var formData = new FormData();
parameters.data = formData;

parameters.token = userKey;
parameters.callback = {
onSuccess: function() {
onSuccess: function(response) {
$rootScope.notify("success", "Your submission has been re-run succesfully!");
vm.stopLoader();
submissionObject.status = response.data.submission_status;
submissionObject.execution_time = response.data.submission_execution_time;
submissionObject.submission_number = response.data.submission_number;
submissionObject.classList = [''];
$scope.reRunSubmission = 'false';
// vm.stopLoader();
},
onError: function(response) {
var status = response.status;
var error = response.data;
$rootScope.notify("error", error);
vm.stopLoader();
submissionObject.classList = [''];
// vm.stopLoader();
}
};
vm.startLoader("Loading Submissions");
// vm.startLoader("Loading Submissions");
utilities.sendRequest(parameters);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<th data-field="file">Stderr File</th>
<th data-field="file">Result File</th>
<th data-field="file">Metadata File</th>
<th data-field="="button">Re-run submissions</th>
<th data-field="button">Re-run Submissions</th>
</thead>
<tbody>
<tr ng-repeat="key in challenge.submissionResult.results" class="result-val">
Expand Down Expand Up @@ -100,8 +100,7 @@
<label for="isPublic{{ key.id }}"></label>
<span ng-if="key.status !== 'finished'" class="center"> N/A </span>
</td>

<td><button class="waves-effect waves-dark btn ev-btn-dark w-300 fs-14 " type="button" ng-click="challenge.rerunSubmission(key.submission_number)">Re-run submission</button></td>
<td><center><a ng-class="key.classList" class="fa fa-refresh pointer" ng-click="challenge.rerunSubmission(key)"></a></center></td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit 5394377

Please sign in to comment.