Skip to content
Merged
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
69 changes: 0 additions & 69 deletions .github/workflows/release-version-update.yml

This file was deleted.

2 changes: 1 addition & 1 deletion compute_worker/compute_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ async def watch_detailed_results(self):
else:
logger.info(time.time() - start)
if time.time() - start > expiration_seconds:
timeout_error_message = f"Detailed results not written to after {expiration_seconds} seconds, exiting!"
timeout_error_message = f"WARNING: Detailed results not written before the execution."
logger.warning(timeout_error_message)
await asyncio.sleep(5)
file_path = self.get_detailed_results_file_path()
Expand Down
4 changes: 4 additions & 0 deletions src/apps/api/serializers/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Meta:
'max_submissions_per_person',
'auto_migrate_to_this_phase',
'hide_output',
'hide_prediction_output',
'hide_score_output',
'leaderboard',
'public_data',
'starting_kit',
Expand Down Expand Up @@ -124,6 +126,8 @@ class Meta:
'max_submissions_per_person',
'auto_migrate_to_this_phase',
'hide_output',
'hide_prediction_output',
'hide_score_output',
# no leaderboard
'public_data',
'starting_kit',
Expand Down
4 changes: 2 additions & 2 deletions src/apps/api/serializers/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def get_data_file(self, instance):

def get_prediction_result(self, instance):
if instance.prediction_result.name:
if instance.phase.hide_output and not instance.phase.competition.user_has_admin_permission(self.context['request'].user):
if (instance.phase.hide_output or instance.phase.hide_prediction_output) and not instance.phase.competition.user_has_admin_permission(self.context['request'].user):
return None
return make_url_sassy(instance.prediction_result.name)

Expand All @@ -271,7 +271,7 @@ def get_detailed_result(self, instance):

def get_scoring_result(self, instance):
if instance.scoring_result.name:
if instance.phase.hide_output and not instance.phase.competition.user_has_admin_permission(self.context['request'].user):
if (instance.phase.hide_output or instance.phase.hide_score_output) and not instance.phase.competition.user_has_admin_permission(self.context['request'].user):
return None
return make_url_sassy(instance.scoring_result.name)

Expand Down
2 changes: 2 additions & 0 deletions src/apps/api/views/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ def update(self, request, *args, **kwargs):
name=phase["name"],
description=phase["description"],
hide_output=phase["hide_output"],
hide_prediction_output=phase["hide_prediction_output"],
hide_score_output=phase["hide_score_output"],
competition=Competition.objects.get(id=data['id'])
)
# Get phase id
Expand Down
41 changes: 36 additions & 5 deletions src/apps/api/views/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def soft_delete(self, request, pk):
return Response({'error': 'You are not allowed to delete a leaderboard submission'}, status=status.HTTP_403_FORBIDDEN)

# Check if submission is in running state
if submission.status not in [Submission.FAILED, Submission.FINISHED]:
if submission.status not in [Submission.FAILED, Submission.FINISHED, Submission.CANCELLED]:
return Response({'error': 'You are not allowed to delete a running submission'}, status=status.HTTP_403_FORBIDDEN)

# Check if submission is not already soft deleted
Expand Down Expand Up @@ -351,16 +351,47 @@ def re_run_many_submissions(self, request):

@action(detail=False, methods=['get'])
def download_many(self, request):
"""
Download a ZIP containing several submissions.
"""
pks = request.query_params.get('pks')
if pks:
pks = json.loads(pks) # Convert JSON string to list
else:
return Response({"error": "`pks` query parameter is required"}, status=400)

# Get submissions
submissions = Submission.objects.filter(pk__in=pks).select_related(
"owner",
"phase__competition",
"phase__competition__created_by",
).prefetch_related("phase__competition__collaborators")
if submissions.count() != len(pks):
return Response({"error": "One or more submission IDs are invalid"}, status=404)

# Check permissions
if not request.user.is_authenticated:
raise PermissionDenied("You must be logged in to download submissions")
# Allow admins
if request.user.is_superuser or request.user.is_staff:
allowed = True
else:
# Build one Q object for "owner OR organizer"
organiser_q = (
Q(phase__competition__created_by=request.user) |
Q(phase__competition__collaborators=request.user)
)
# Submissions that violate the rule
disallowed = submissions.exclude(Q(owner=request.user) | organiser_q)
allowed = not disallowed.exists()
if not allowed:
raise PermissionDenied(
"You do not have permission to download one or more of the requested submissions"
)

# Doing a local import here to avoid circular imports
# Download
from competitions.tasks import stream_batch_download

# in_memory_zip = stream_batch_download.apply_async((pks,)).get()
in_memory_zip = stream_batch_download(pks)

response = StreamingHttpResponse(in_memory_zip, content_type='application/zip')
response['Content-Disposition'] = 'attachment; filename="bulk_submissions.zip"'
return response
Expand Down
18 changes: 18 additions & 0 deletions src/apps/competitions/migrations/0054_auto_20250321_1341.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2025-03-21 13:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('competitions', '0053_auto_20250218_1151'),
]

operations = [
migrations.AlterField(
model_name='submissiondetails',
name='file_size',
field=models.DecimalField(blank=True, decimal_places=2, max_digits=15, null=True),
),
]
14 changes: 14 additions & 0 deletions src/apps/competitions/migrations/0056_merge_20250324_2128.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.2.28 on 2025-03-24 21:28

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('competitions', '0054_auto_20250321_1341'),
('competitions', '0055_merge_20250324_0650'),
]

operations = [
]
18 changes: 18 additions & 0 deletions src/apps/competitions/migrations/0057_phase_hide_score_output.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2025-04-25 09:59

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('competitions', '0056_merge_20250324_2128'),
]

operations = [
migrations.AddField(
model_name='phase',
name='hide_score_output',
field=models.BooleanField(default=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2025-05-14 19:37

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('competitions', '0057_phase_hide_score_output'),
]

operations = [
migrations.AddField(
model_name='phase',
name='hide_prediction_output',
field=models.BooleanField(default=False),
),
]
2 changes: 2 additions & 0 deletions src/apps/competitions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ class Phase(ChaHubSaveMixin, models.Model):
auto_migrate_to_this_phase = models.BooleanField(default=False)
has_been_migrated = models.BooleanField(default=False)
hide_output = models.BooleanField(default=False)
hide_prediction_output = models.BooleanField(default=False)
hide_score_output = models.BooleanField(default=False)

has_max_submissions = models.BooleanField(default=True)
max_submissions_per_day = models.PositiveIntegerField(default=5, null=True, blank=True)
Expand Down
2 changes: 2 additions & 0 deletions src/apps/competitions/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
'execution_time_limit',
'auto_migrate_to_this_phase',
'hide_output',
'hide_prediction_output',
'hide_score_output',
]
PHASE_FILES = [
"input_data",
Expand Down
14 changes: 6 additions & 8 deletions src/apps/competitions/tests/unpacker_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@
'starting_kit': None,
'tasks': [0],
'status': 'Previous',
'hide_output': False,
'hide_prediction_output': False,
'hide_score_output': False,
},
{
'index': 1,
Expand All @@ -230,14 +233,12 @@
'tasks': [1],
'status': 'Current',
'is_final_phase': True,
'hide_output': False,
'hide_prediction_output': False,
'hide_score_output': False,
}
]

V2_SPECIFIC_PHASE_DATA = [
# Tuples of (key, value) of data specific to v2 unpacker.
('hide_output', False)
]


def get_phases(version):
if version == 1:
Expand All @@ -246,9 +247,6 @@ def get_phases(version):
# Make a copy of the list so we aren't mutating the original phases object. May not be strictly necessary,
# but if we ever write a test comparing v1 to v2 or something, this would avoid bugs.
v2 = [{k: v for k, v in phase.items()} for phase in PHASES]
for phase in v2:
for key, value in V2_SPECIFIC_PHASE_DATA:
phase[key] = value
return v2


Expand Down
3 changes: 3 additions & 0 deletions src/apps/competitions/unpackers/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def _unpack_phases(self):
'max_submissions_per_day': phase.get('max_submissions_per_day', 5),
'max_submissions_per_person': phase.get('max_submissions', 100),
'auto_migrate_to_this_phase': phase.get('auto_migration', False),
'hide_output': phase.get('hide_output', False),
'hide_prediction_output': phase.get('hide_prediction_output', False),
'hide_score_output': phase.get('hide_score_output', False),
}
execution_time_limit = phase.get('execution_time_limit')
if execution_time_limit:
Expand Down
2 changes: 2 additions & 0 deletions src/apps/competitions/unpackers/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ def _unpack_phases(self):
'max_submissions_per_person': phase_data.get('max_submissions', 100),
'auto_migrate_to_this_phase': phase_data.get('auto_migrate_to_this_phase', False),
'hide_output': phase_data.get('hide_output', False),
'hide_prediction_output': phase_data.get('hide_prediction_output', False),
'hide_score_output': phase_data.get('hide_score_output', False),
}
try:
new_phase['tasks'] = phase_data['tasks']
Expand Down
4 changes: 2 additions & 2 deletions src/static/riot/competitions/detail/submission_manager.tag
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@
<i class="icon share grey alternate"></i>
</span>
<!-- Delete Submission -->
<!-- Show only if submission is Finished/Failed and not admin interface -->
<!-- Show only if submission is Finished/Failed/Cancelled and not admin interface -->
<!-- This condition && !opts.admin is there to not show soft delete button in the admin interface -->
<span if="{ ((submission.status === 'Finished' && !submission.on_leaderboard) || submission.status === 'Failed') && !opts.admin}"
<span if="{ ((submission.status === 'Finished' && !submission.on_leaderboard) || submission.status === 'Failed' || submission.status === 'Cancelled') && !opts.admin}"
data-tooltip="Delete Submission" data-inverted=""
onclick="{ soft_delete_submission.bind(this, submission) }">
<i class="icon red trash"></i>
Expand Down
4 changes: 2 additions & 2 deletions src/static/riot/competitions/detail/submission_modal.tag
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
</td>
</tr>
<tr>
<td class="selectable file-download {disabled: !prediction_result}">
<td class="selectable file-download {disabled: !prediction_result}" show="{!opts.hide_prediction_output}">
<a href="{ prediction_result }"><i class="file outline icon"></i>Output from prediction step</a>
</td>
</tr>
<tr>
<td class="selectable file-download {disabled: !scoring_result}">
<td class="selectable file-download {disabled: !scoring_result}" show="{!opts.hide_score_output}">
<a href="{ scoring_result }"><i class="file outline icon"></i>Output from scoring step</a>
</td>
</tr>
Expand Down
Loading