Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 347194f

Browse files
committedJan 30, 2025·
refactor: OPTIC-1621: Remove Stale Feature Flag - fflag_perf_back_lsdv_4695_update_prediction_query_to_use_direct_project_relation
1 parent 6759d0c commit 347194f

File tree

5 files changed

+8
-47
lines changed

5 files changed

+8
-47
lines changed
 

‎label_studio/core/feature_flags/stale_feature_flags.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
'fflag_feat_front_optic_66_lazy_chart_evaluation_19092023_short': False,
44
'fflag_fix_back_leap_24_tasks_api_optimization_05092023_short': False,
55
'fflag_feat_optic_2_ensure_draft_saved_short': True,
6-
'fflag_perf_back_lsdv_4695_update_prediction_query_to_use_direct_project_relation': True,
76
'fflag_feat_front_lsdv_4620_outliner_optimization_310723_short': True,
87
'fflag_fix_front_lsdv_4600_lead_time_27072023_short': False,
98
'fflag_feat_front_lops_e_10_updated_ux_short': False,

‎label_studio/projects/functions/__init__.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ def annotate_finished_task_number(queryset):
1515

1616

1717
def annotate_total_predictions_number(queryset):
18-
if flag_set(
19-
'fflag_perf_back_lsdv_4695_update_prediction_query_to_use_direct_project_relation',
20-
user='auto',
21-
):
22-
predictions = Prediction.objects.filter(project=OuterRef('id')).values('id')
23-
else:
24-
predictions = Prediction.objects.filter(task__project=OuterRef('id')).values('id')
18+
predictions = Prediction.objects.filter(project=OuterRef('id')).values('id')
2519
return queryset.annotate(total_predictions_number=SQCount(predictions))
2620

2721

‎label_studio/projects/models.py

+2-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Any, Mapping, Optional
66

77
from annoying.fields import AutoOneToOneField
8-
from core.feature_flags import flag_set
98
from core.label_config import (
109
check_control_in_config_by_regex,
1110
check_toname_in_config_by_regex,
@@ -327,13 +326,7 @@ def has_predictions(self):
327326

328327
@property
329328
def has_any_predictions(self):
330-
if flag_set(
331-
'fflag_perf_back_lsdv_4695_update_prediction_query_to_use_direct_project_relation',
332-
user='auto',
333-
):
334-
return Prediction.objects.filter(Q(project=self.id)).exists()
335-
else:
336-
return Prediction.objects.filter(Q(task__project=self.id)).exists()
329+
return Prediction.objects.filter(Q(project=self.id)).exists()
337330

338331
@property
339332
def business(self):
@@ -933,14 +926,7 @@ def get_model_versions(self, with_counters=False, extended=False):
933926
:param extended: Boolean, if True, returns additional information. Default is False.
934927
:return: Dict or list containing model versions and their count predictions.
935928
"""
936-
if flag_set(
937-
'fflag_perf_back_lsdv_4695_update_prediction_query_to_use_direct_project_relation',
938-
user='auto',
939-
):
940-
predictions = Prediction.objects.filter(project=self)
941-
else:
942-
predictions = Prediction.objects.filter(task__project=self)
943-
# model_versions = set(predictions.values_list('model_version', flat=True).distinct())
929+
predictions = Prediction.objects.filter(project=self)
944930

945931
if extended:
946932
model_versions = list(

‎label_studio/tasks/api.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -778,13 +778,7 @@ class PredictionAPI(viewsets.ModelViewSet):
778778
filterset_fields = ['task', 'task__project', 'project']
779779

780780
def get_queryset(self):
781-
if flag_set(
782-
'fflag_perf_back_lsdv_4695_update_prediction_query_to_use_direct_project_relation',
783-
user='auto',
784-
):
785-
return Prediction.objects.filter(project__organization=self.request.user.active_organization)
786-
else:
787-
return Prediction.objects.filter(task__project__organization=self.request.user.active_organization)
781+
return Prediction.objects.filter(project__organization=self.request.user.active_organization)
788782

789783

790784
@method_decorator(name='get', decorator=swagger_auto_schema(auto_schema=None))

‎label_studio/tasks/models.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -933,15 +933,8 @@ def created_ago(self):
933933
return timesince(self.created_at)
934934

935935
def has_permission(self, user):
936-
if flag_set(
937-
'fflag_perf_back_lsdv_4695_update_prediction_query_to_use_direct_project_relation',
938-
user='auto',
939-
):
940-
user.project = self.project # link for activity log
941-
return self.project.has_permission(user)
942-
else:
943-
user.project = self.task.project # link for activity log
944-
return self.task.project.has_permission(user)
936+
user.project = self.project # link for activity log
937+
return self.project.has_permission(user)
945938

946939
@classmethod
947940
def prepare_prediction_result(cls, result, project):
@@ -1009,13 +1002,8 @@ def save(self, *args, update_fields=None, **kwargs):
10091002
update_fields = {'project_id'}.union(update_fields)
10101003

10111004
# "result" data can come in different forms - normalize them to JSON
1012-
if flag_set(
1013-
'fflag_perf_back_lsdv_4695_update_prediction_query_to_use_direct_project_relation',
1014-
user='auto',
1015-
):
1016-
self.result = self.prepare_prediction_result(self.result, self.project)
1017-
else:
1018-
self.result = self.prepare_prediction_result(self.result, self.task.project)
1005+
self.result = self.prepare_prediction_result(self.result, self.project)
1006+
10191007
if update_fields is not None:
10201008
update_fields = {'result'}.union(update_fields)
10211009
# set updated_at field of task to now()

0 commit comments

Comments
 (0)
Please sign in to comment.