Skip to content

Commit e6b85e8

Browse files
authored
Merge pull request #1963 from codalab/develop
Patch release 1.20.0 (#1962)
2 parents 9127d57 + 1327e48 commit e6b85e8

File tree

1 file changed

+5
-35
lines changed

1 file changed

+5
-35
lines changed

src/apps/api/views/tasks.py

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django.core.files.uploadedfile import InMemoryUploadedFile
55
from collections import defaultdict
66

7-
from django.db.models import Q, Case, When, Value, BooleanField
7+
from django.db.models import Q, Value, BooleanField
88
from django.db import transaction
99

1010
from rest_framework import status
@@ -17,7 +17,7 @@
1717

1818
from api.pagination import BasicPagination
1919
from api.serializers import tasks as serializers
20-
from competitions.models import Submission, Phase
20+
from competitions.models import Phase
2121
from profiles.models import User
2222
from tasks.models import Task
2323
from datasets.models import Data
@@ -53,40 +53,10 @@ def get_queryset(self):
5353
# the public task to the user and hence we check the `retrieve` action
5454
if self.request.query_params.get('public') or self.action == 'retrieve':
5555
task_filter |= Q(is_public=True)
56-
56+
# Removed the "task validation" process (https://github.com/codalab/codabench/pull/1962)
57+
# We now always set "validated" to False. The "task validation" was only partly implemented and never used.
5758
qs = qs.filter(task_filter)
58-
# Determine whether a task is "valid" by finding some solution with a
59-
# passing submission
60-
# !CONCERN!
61-
# We are looping through all tasks and potentially storing in memory.
62-
# Should we potentially change "Task.objects.prefetch_related" to
63-
# have similar filters as "qs" so as not to have all tasks in the db
64-
# in memory.
65-
# !CONCERN!
66-
tasks_with_solutions = Task.objects.prefetch_related("solutions")
67-
task_validations = {}
68-
for task in tasks_with_solutions:
69-
solution_md5s = task.solutions.values_list("md5", flat=True)
70-
is_valid = Submission.objects.filter(
71-
md5__in=solution_md5s,
72-
status=Submission.FINISHED,
73-
).exists()
74-
task_validations[task.id] = is_valid
75-
76-
# Annotate queryset with validation results
77-
cases = [
78-
When(id=task_id, then=Value(validated))
79-
for task_id, validated in task_validations.items()
80-
]
81-
# The qs has a task in it right now.
82-
# Baked into cases is task_id from task_validations.
83-
# So if any of the tasks in qs, that are up for consideration,
84-
# match a task from task_validations, then grab that task's
85-
# validation status and return so that this task in qs now
86-
# has a "validated" attribute we can access later in
87-
# src/apps/api/tests/test_tasks.py as resp.data["validated"].
88-
qs = qs.annotate(validated=Case(*cases, default=Value(False), output_field=BooleanField()))
89-
59+
qs = qs.annotate(validated=Value(False, output_field=BooleanField()))
9060
return qs.order_by('-created_when').distinct()
9161

9262
def get_serializer_class(self):

0 commit comments

Comments
 (0)