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

Add feature to disable private submission #4419

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.20 on 2024-08-31 06:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('challenges', '0112_challenge_sqs_retention_period'),
]

operations = [
migrations.AddField(
model_name='challenge',
name='disable_private_submission',
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions apps/challenges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def __init__(self, *args, **kwargs):
)
worker_image_url = models.CharField(max_length=200, blank=True, null=True, default="")
evaluation_module_error = models.TextField(null=True, blank=True)
disable_private_submission = models.BooleanField(default=False)

class Meta:
app_label = "challenges"
Expand Down
6 changes: 4 additions & 2 deletions apps/challenges/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class Meta:
"evaluation_module_error",
"worker_image_url",
"worker_instance_type",
"sqs_retention_period"
"sqs_retention_period",
"disable_private_submission"
)


Expand Down Expand Up @@ -311,7 +312,8 @@ class Meta:
"ephemeral_storage",
"evaluation_module_error",
"worker_image_url",
"sqs_retention_period"
"sqs_retention_period",
"disable_private_submission"
)


Expand Down
2 changes: 2 additions & 0 deletions docs/source/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Following fields are required (and can be customized) in the [`challenge_config.

3. `metadata`: This field defines additional information about the metrics that are used to evaluate the challenge submissions.

- **disable_private_submission**: True/False (a Boolean field that gives the flexibility to Challenge Hosts to either disable or enable private submissions. Default is `False`)

The leaderboard schema for the [sample challenge configuration](https://github.com/Cloud-CV/EvalAI-Starters/blob/master/challenge_config.yaml) looks like this:

```yaml
Expand Down
49 changes: 47 additions & 2 deletions frontend/src/js/controllers/challengeCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
vm.currentPhaseLeaderboardPublic = false;
vm.eligible_to_submit = false;
vm.evaluation_module_error = null;

vm.disable_private_submission = false;
vm.filter_all_submission_by_team_name = '';
vm.filter_my_submission_by_team_name = '';
// show loader
Expand Down Expand Up @@ -396,6 +396,7 @@
vm.has_sponsors = details.has_sponsors;
vm.queueName = details.queue;
vm.evaluation_module_error = details.evaluation_module_error;
vm.disable_private_submission = details.disable_private_submission;
vm.getTeamName(vm.challengeId);
if (vm.page.image === null) {
vm.page.image = "dist/images/logo.png";
Expand Down Expand Up @@ -708,6 +709,9 @@
formData.append("project_url", vm.projectUrl);
formData.append("publication_url", vm.publicationUrl);
formData.append("submission_metadata", JSON.stringify(vm.metaAttributesforCurrentSubmission));
if (vm.disable_private_submission) {
vm.isPublicSubmission = true;
}
if (vm.isPublicSubmission !== null) {
formData.append("is_public", vm.isPublicSubmission);
}
Expand Down Expand Up @@ -2836,7 +2840,48 @@
$mdDialog.hide();
}
};

vm.toggleDisablePrivateSubmission = function(ev) {
ev.stopPropagation();
vm.toggleSubmissionState = null;
vm.submissionDesc = null;
if (vm.disable_private_submission)
vm.toggleSubmissionState = "allowed";
else
vm.toggleSubmissionState = "disabled";

var confirm = $mdDialog.confirm()
.title('Make private submissions ' + vm.toggleSubmissionState + '?')
.ariaLabel('')
.targetEvent(ev)
.ok('Yes')
.cancel('No');

$mdDialog.show(confirm).then(function() {
parameters.url = "challenges/challenge_host_team/" + vm.page.creator.id + "/challenge/" + vm.page.id;
parameters.method = 'PATCH';
parameters.data = {
"disable_private_submission": !vm.disable_private_submission,
};
vm.disable_private_submission = !vm.disable_private_submission;
parameters.callback = {
onSuccess: function(response) {
var status = response.status;
if (status === 200) {
$mdDialog.hide();
$rootScope.notify("success", "Private submissions were successfully made " + vm.toggleSubmissionState);
}
},
onError: function(response) {
$mdDialog.hide();
var error = response.data;
$rootScope.notify("error", error);
}
};
utilities.sendRequest(parameters);
}, function() {
// Nope
});
};
vm.publishChallenge = function(ev) {
ev.stopPropagation();
vm.toggleChallengeState = null;
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/views/web/challenge/challenge-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ <h4 class="challenge-step-title w-300">{{challenge.page.title}}
<strong class="text-light-black">Not Published </strong>
<i class="fa fa-eye red-text" aria-hidden="true"></i>
</a>
</span><br>
<span ng-if="challenge.disable_private_submission">
<a class="pointer" ng-click="challenge.toggleDisablePrivateSubmission($event)">
<strong class="text-light-black">Private Submissions Disabled </strong>
<i class="fa fa-lock red-text" aria-hidden="true"></i>
</a>
</span>
<span ng-if="!challenge.disable_private_submission">
<a class="pointer" ng-click="challenge.toggleDisablePrivateSubmission($event)">
<strong class="text-light-black">Private Submissions Allowed </strong>
<i class="fa fa-unlock green-text" aria-hidden="true"></i>
</a>
</span>
</span>
<br>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/web/challenge/my-submission.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h6>My Participated Team: {{challenge.participated_team_name}}</h6>
<th class="fs-18 w-300" ng-if="challenge.isChallengeHost &&
!challenge.isStaticCodeUploadChallenge" data-field="file">Environment Logs</th>
<th class="align-center fs-18 w-300" data-field="file">Submitted at</th>
<th class="align-center fs-18 w-300" ng-if="challenge.currentPhaseLeaderboardPublic"
<th class="align-center fs-18 w-300" ng-if="!challenge.disable_private_submission && challenge.currentPhaseLeaderboardPublic"
data-field="file">
Show on leaderboard</th>
<th class="fs-18 w-300" data-field="isBaseline" ng-if="challenge.isChallengeHost">Baseline
Expand Down Expand Up @@ -121,7 +121,7 @@ <h6>My Participated Team: {{challenge.participated_team_name}}</h6>

<td>{{key.submitted_at | date:'medium'}}</td>

<td ng-if="challenge.currentPhaseLeaderboardPublic" class="center">
<td ng-if="!challenge.disable_private_submission && challenge.currentPhaseLeaderboardPublic" class="center">
<input ng-checked="key.is_public" ng-if="!challenge.isCurrentPhaseRestrictedToSelectOneSubmission"
ng-model="challenge.submissionVisibility[key.id]" type="checkbox"
id="isPublic{{ key.id }}"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/web/challenge/submission.html
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ <h5 class="w-300">Make Submission</h5>
<div
ng-show="challenge.isSubmissionUsingUrl || challenge.isSubmissionUsingFile">

<div ng-show="challenge.currentPhaseLeaderboardPublic">
<div ng-if="!challenge.disable_private_submission" ng-show="challenge.currentPhaseLeaderboardPublic">
<p class="fs-14 w-400" ng>Select submission visibility:</p>
<li>
<input type="radio" name="submissionVisibility" class="with-gap selectPhase" id="isPublicSubmission"
Expand Down Expand Up @@ -488,7 +488,7 @@ <h5 class="w-300">Make Submission</h5>
</button>
</li>
<li>
<div class="center-content">Use &nbsp;<code> --private </code> &nbsp;or&nbsp; <code> --public </code>&nbsp; flag in the submission
<div class="center-content">Use &nbsp; <span ng-show="!challenge.disable_private_submission"><code> --private </code> &nbsp;or&nbsp; </span><code> --public </code>&nbsp; flag in the submission
command to make the submission private or public respectively.<br />
</div>
</li>
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/challenges/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def test_get_challenge(self):
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
"sqs_retention_period": self.challenge.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
]

Expand Down Expand Up @@ -550,6 +551,7 @@ def test_get_particular_challenge(self):
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
"sqs_retention_period": self.challenge.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
response = self.client.get(self.url, {})
self.assertEqual(response.data, expected)
Expand Down Expand Up @@ -652,6 +654,7 @@ def test_update_challenge_when_user_is_its_creator(self):
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
"sqs_retention_period": self.challenge.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
response = self.client.put(
self.url, {"title": new_title, "description": new_description}
Expand Down Expand Up @@ -780,6 +783,7 @@ def test_particular_challenge_partial_update(self):
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
"sqs_retention_period": self.challenge.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
response = self.client.patch(self.url, self.partial_update_data)
self.assertEqual(response.data, expected)
Expand Down Expand Up @@ -857,6 +861,7 @@ def test_particular_challenge_update(self):
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
"sqs_retention_period": self.challenge.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
response = self.client.put(self.url, self.data)
self.assertEqual(response.data, expected)
Expand Down Expand Up @@ -1450,6 +1455,7 @@ def test_get_past_challenges(self):
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
"sqs_retention_period": self.challenge3.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -1533,6 +1539,7 @@ def test_get_present_challenges(self):
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
"sqs_retention_period": self.challenge.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -1616,6 +1623,7 @@ def test_get_future_challenges(self):
"worker_image_url": self.challenge4.worker_image_url,
"worker_instance_type": self.challenge4.worker_instance_type,
"sqs_retention_period": self.challenge4.sqs_retention_period,
"disable_private_submission": self.challenge4.disable_private_submission,
}
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -1699,6 +1707,7 @@ def test_get_all_challenges(self):
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
"sqs_retention_period": self.challenge3.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
},
{
"id": self.challenge3.pk,
Expand Down Expand Up @@ -1766,6 +1775,7 @@ def test_get_all_challenges(self):
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
"sqs_retention_period": self.challenge3.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
},
{
"id": self.challenge2.pk,
Expand Down Expand Up @@ -1833,6 +1843,7 @@ def test_get_all_challenges(self):
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
"sqs_retention_period": self.challenge2.sqs_retention_period,
"disable_private_submission": self.challenge2.disable_private_submission,
},
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -1971,6 +1982,7 @@ def test_get_featured_challenges(self):
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
"sqs_retention_period": self.challenge3.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -2133,6 +2145,7 @@ def test_get_challenge_by_pk_when_user_is_challenge_host(self):
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
"sqs_retention_period": self.challenge3.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}

response = self.client.get(self.url, {})
Expand Down Expand Up @@ -2224,6 +2237,7 @@ def test_get_challenge_by_pk_when_user_is_participant(self):
"worker_image_url": self.challenge4.worker_image_url,
"worker_instance_type": self.challenge4.worker_instance_type,
"sqs_retention_period": self.challenge4.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}

self.client.force_authenticate(user=self.user1)
Expand Down Expand Up @@ -2375,6 +2389,7 @@ def test_get_challenge_when_host_team_is_given(self):
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
"sqs_retention_period": self.challenge2.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
]

Expand Down Expand Up @@ -2454,6 +2469,7 @@ def test_get_challenge_when_participant_team_is_given(self):
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
"sqs_retention_period": self.challenge2.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
]

Expand Down Expand Up @@ -2533,6 +2549,7 @@ def test_get_challenge_when_mode_is_participant(self):
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
"sqs_retention_period": self.challenge2.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
}
]

Expand Down Expand Up @@ -2610,6 +2627,7 @@ def test_get_challenge_when_mode_is_host(self):
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
"sqs_retention_period": self.challenge.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
},
{
"id": self.challenge2.pk,
Expand Down Expand Up @@ -2677,6 +2695,7 @@ def test_get_challenge_when_mode_is_host(self):
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
"sqs_retention_period": self.challenge2.sqs_retention_period,
"disable_private_submission": self.challenge.disable_private_submission,
},
]

Expand Down
2 changes: 2 additions & 0 deletions tests/unit/participants/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ def test_get_teams_and_corresponding_challenges_for_a_participant(self):
"worker_image_url": self.challenge1.worker_image_url,
"worker_instance_type": self.challenge1.worker_instance_type,
"sqs_retention_period": self.challenge1.sqs_retention_period,
"disable_private_submission": self.challenge1.disable_private_submission,
},
"participant_team": {
"id": self.participant_team.id,
Expand Down Expand Up @@ -978,6 +979,7 @@ def test_get_participant_team_challenge_list(self):
"worker_image_url": self.challenge1.worker_image_url,
"worker_instance_type": self.challenge1.worker_instance_type,
"sqs_retention_period": self.challenge1.sqs_retention_period,
"disable_private_submission": self.challenge1.disable_private_submission,
}
]

Expand Down