Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2209: Add a feature to re-reun a submission by challenge host using UI #2340

Merged
merged 20 commits into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/jobs/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
views.get_remaining_submissions,
name="get_remaining_submissions",
),
url(
r'^submissions/(?P<submission_pk>[0-9]+)/re-run/$',
views.re_run_submission, name='re_run_submission'
),
url(
r"^challenge_phase_split/(?P<challenge_phase_split_id>[0-9]+)/leaderboard/$",
views.leaderboard,
Expand Down
36 changes: 36 additions & 0 deletions apps/jobs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,42 @@ def update_submission(request, challenge_pk):
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


@api_view(['POST', ])
@throttle_classes([UserRateThrottle, ])
@permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
@authentication_classes((ExpiringTokenAuthentication,))
def re_run_submission(request, submission_pk):
"""
API endpoint to re-run a submission.
Only challenge host has access to this endpoint.
"""
try:
submission = Submission.objects.get(pk=submission_pk)
except Submission.DoesNotExist:
response_data = {'error': 'Submission {} does not exist'.format(submission_pk)}
return Response(response_data, status=status.HTTP_404_NOT_FOUND)

# get the challenge and challenge phase object
challenge_phase = submission.challenge_phase
challenge = challenge_phase.challenge

if not is_user_a_host_of_challenge(request.user, challenge.pk):
response_data = {
"error": "Only challenge hosts are allowed to re-run a submission"
}
return Response(response_data, status=status.HTTP_403_FORBIDDEN)

if not challenge.is_active:
response_data = {'error': 'Challenge {} is not active'.format(challenge.title)}
return Response(response_data, status=status.HTTP_406_NOT_ACCEPTABLE)

publish_submission_message(challenge.pk, challenge_phase.pk, submission.pk)
response_data = {
'success': 'Submission is successfully submitted for re-running'
}
return Response(response_data, status=status.HTTP_200_OK)


@api_view(["GET"])
@throttle_classes([UserRateThrottle])
@permission_classes((permissions.IsAuthenticated, HasVerifiedEmail))
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 @@ -187,6 +187,28 @@ md-select.md-default-theme .md-select-value span:first-child:after, md-select .m
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;
}

.btn-switch {
position: relative;
display: block;
Expand Down
20 changes: 20 additions & 0 deletions frontend/src/js/controllers/challengeCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,26 @@

utilities.sendRequest(parameters);
};

vm.reRunSubmission = function(submissionObject) {
submissionObject.classList = ['spin', 'progress-indicator'];
parameters.url = 'jobs/submissions/' + submissionObject.id + '/re-run/';
parameters.method = 'POST';
parameters.token = userKey;
parameters.callback = {
onSuccess: function(response) {
$rootScope.notify("success", response.data.success);
submissionObject.classList = [''];
},
onError: function(response) {
var error = response.data;
$rootScope.notify("error", error);
submissionObject.classList = [''];
}
};
utilities.sendRequest(parameters);
};

vm.refreshLeaderboard = function() {
vm.startLoader("Loading Leaderboard Items");
vm.leaderboard = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,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>
</thead>
<tbody>
<tr ng-repeat="key in challenge.submissionResult.results" class="result-val">
Expand Down Expand Up @@ -116,6 +117,7 @@
<label for="isPublic{{ key.id }}"></label>
<span ng-if="key.status !== 'finished'" class="center"> N/A </span>
</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