Skip to content

Commit 6e1ac84

Browse files
author
Val Brodsky
committed
Fix tests post-merge
1 parent 38d8127 commit 6e1ac84

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

libs/labelbox/src/labelbox/schema/search_filters.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Config:
1919
use_enum_values = True
2020

2121

22-
class OperationTypeEnum(Enum):
22+
class OperationType(Enum):
2323
"""
2424
Supported search entity types
2525
Each type corresponds to a different filter class
@@ -35,8 +35,14 @@ class OperationTypeEnum(Enum):
3535
TaskRemainingCount = 'task_remaining_count'
3636

3737

38-
OperationType = Annotated[OperationTypeEnum,
39-
PlainSerializer(lambda x: x.value, return_type=str)]
38+
def convert_enum_to_str(enum_or_str: Union[Enum, str]) -> str:
39+
if isinstance(enum_or_str, Enum):
40+
return enum_or_str.value
41+
return enum_or_str
42+
43+
44+
OperationType = Annotated[OperationType,
45+
PlainSerializer(convert_enum_to_str, return_type=str)]
4046

4147
IsoDatetimeType = Annotated[datetime.datetime,
4248
PlainSerializer(format_iso_datetime)]
@@ -77,7 +83,7 @@ class OrganizationFilter(BaseSearchFilter):
7783
"""
7884
Filter for organization to which projects belong
7985
"""
80-
operation: OperationType = Field(default=OperationTypeEnum.Organization,
86+
operation: OperationType = Field(default=OperationType.Organization,
8187
serialization_alias='type')
8288
operator: IdOperator
8389
values: List[str]
@@ -89,7 +95,7 @@ class SharedWithOrganizationFilter(BaseSearchFilter):
8995
"""
9096

9197
operation: OperationType = Field(
92-
default=OperationTypeEnum.SharedWithOrganization,
98+
default=OperationType.SharedWithOrganization,
9399
serialization_alias='type')
94100
operator: IdOperator
95101
values: List[str]
@@ -99,7 +105,7 @@ class WorkspaceFilter(BaseSearchFilter):
99105
"""
100106
Filter for workspace
101107
"""
102-
operation: OperationType = Field(default=OperationTypeEnum.Workspace,
108+
operation: OperationType = Field(default=OperationType.Workspace,
103109
serialization_alias='type')
104110
operator: IdOperator
105111
values: List[str]
@@ -110,7 +116,7 @@ class TagFilter(BaseSearchFilter):
110116
Filter for project tags
111117
values are tag ids
112118
"""
113-
operation: OperationType = Field(default=OperationTypeEnum.Tag,
119+
operation: OperationType = Field(default=OperationType.Tag,
114120
serialization_alias='type')
115121
operator: IdOperator
116122
values: List[str]
@@ -121,7 +127,7 @@ class ProjectStageFilter(BaseSearchFilter):
121127
Filter labelbox service / aka project stages
122128
Stages are: requested, in_progress, completed etc. as described by LabelingServiceStatus
123129
"""
124-
operation: OperationType = Field(default=OperationTypeEnum.Stage,
130+
operation: OperationType = Field(default=OperationType.Stage,
125131
serialization_alias='type')
126132
operator: IdOperator
127133
values: List[LabelingServiceStatus]
@@ -163,7 +169,7 @@ class WorkforceStageUpdatedFilter(BaseSearchFilter):
163169
Filter for workforce stage updated date
164170
"""
165171
operation: OperationType = Field(
166-
default=OperationTypeEnum.WorkforceStageUpdatedDate,
172+
default=OperationType.WorkforceStageUpdatedDate,
167173
serialization_alias='type')
168174
value: DateValue
169175

@@ -173,8 +179,7 @@ class WorkforceRequestedDateFilter(BaseSearchFilter):
173179
Filter for workforce requested date
174180
"""
175181
operation: OperationType = Field(
176-
default=OperationTypeEnum.WorforceRequestedDate,
177-
serialization_alias='type')
182+
default=OperationType.WorforceRequestedDate, serialization_alias='type')
178183
value: DateValue
179184

180185

@@ -199,8 +204,7 @@ class WorkforceRequestedDateRangeFilter(BaseSearchFilter):
199204
Filter for workforce requested date range
200205
"""
201206
operation: OperationType = Field(
202-
default=OperationTypeEnum.WorforceRequestedDate,
203-
serialization_alias='type')
207+
default=OperationType.WorforceRequestedDate, serialization_alias='type')
204208
value: DateRangeValue
205209

206210

@@ -209,7 +213,7 @@ class WorkforceStageUpdatedRangeFilter(BaseSearchFilter):
209213
Filter for workforce stage updated date range
210214
"""
211215
operation: OperationType = Field(
212-
default=OperationTypeEnum.WorkforceStageUpdatedDate,
216+
default=OperationType.WorkforceStageUpdatedDate,
213217
serialization_alias='type')
214218
value: DateRangeValue
215219

@@ -219,19 +223,17 @@ class TaskCompletedCountFilter(BaseSearchFilter):
219223
Filter for completed tasks count
220224
A task maps to a data row. Task completed should map to a data row in a labeling queue DONE
221225
"""
222-
operation: OperationType = Field(
223-
default=OperationTypeEnum.TaskCompletedCount,
224-
serialization_alias='type')
226+
operation: OperationType = Field(default=OperationType.TaskCompletedCount,
227+
serialization_alias='type')
225228
value: IntegerValue
226229

227230

228231
class TaskRemainingCountFilter(BaseSearchFilter):
229232
"""
230233
Filter for remaining tasks count. Reverse of TaskCompletedCountFilter
231234
"""
232-
operation: OperationType = Field(
233-
default=OperationTypeEnum.TaskRemainingCount,
234-
serialization_alias='type')
235+
operation: OperationType = Field(default=OperationType.TaskRemainingCount,
236+
serialization_alias='type')
235237
value: IntegerValue
236238

237239

libs/labelbox/tests/integration/test_labeling_dashboard.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
2020
project, _ = requested_labeling_service
2121

2222
organization = project.client.get_organization()
23-
org_filter = OrganizationFilter(operation=OperationType.Organization,
24-
operator=IdOperator.Is,
23+
org_filter = OrganizationFilter(operator=IdOperator.Is,
2524
values=[organization.uid])
2625

2726
try:

0 commit comments

Comments
 (0)