Skip to content

Commit ac6ffdd

Browse files
author
Val Brodsky
committed
Add SharedWithOrganization filter
1 parent bc19373 commit ac6ffdd

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class OperationType(Enum):
3131
Supported search entity types
3232
"""
3333
Organization = 'organization_id'
34+
SharedWithOrganization = 'shared_with_organizations'
3435
Workspace = 'workspace'
3536
Tag = 'tag'
3637
Stage = 'stage'
@@ -72,6 +73,17 @@ class OrganizationFilter(BaseSearchFilter):
7273
values: List[str]
7374

7475

76+
class SharedWithOrganizationFilter(BaseSearchFilter):
77+
"""
78+
Find project shared with organization (i.e. not belonging to any of organization's workspace)
79+
"""
80+
operation: Literal[
81+
OperationType.
82+
SharedWithOrganization] = OperationType.SharedWithOrganization
83+
operator: IdOperator
84+
values: List[str]
85+
86+
7587
class WorkspaceFilter(BaseSearchFilter):
7688
"""
7789
Filter for workspace
@@ -194,7 +206,8 @@ class TaskRemainingCountFilter(BaseSearchFilter):
194206
value: IntegerValue
195207

196208

197-
SearchFilter = Union[OrganizationFilter, WorkspaceFilter, TagFilter,
209+
SearchFilter = Union[OrganizationFilter, WorkspaceFilter,
210+
SharedWithOrganizationFilter, TagFilter,
198211
ProjectStageFilter, WorkforceRequestedDateFilter,
199212
WorkforceStageUpdatedFilter,
200213
WorkforceRequestedDateRangeFilter,

libs/labelbox/tests/unit/test_unit_search_filters.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
from datetime import datetime
2-
from labelbox.schema.search_filters import IntegerValue, RangeOperatorWithSingleValue, DateRange, RangeOperatorWithValue, DateRangeValue, DateValue, IdOperator, OperationType, OrganizationFilter, ProjectStageFilter, TagFilter, TaskCompletedCountFilter, TaskRemainingCountFilter, WorkforceRequestedDateFilter, WorkforceRequestedDateRangeFilter, WorkforceStageUpdatedFilter, WorkforceStageUpdatedRangeFilter, WorkspaceFilter, build_search_filter
2+
from labelbox.schema.search_filters import IntegerValue, RangeOperatorWithSingleValue, DateRange, RangeOperatorWithValue, DateRangeValue, DateValue, IdOperator, OperationType, OrganizationFilter, ProjectStageFilter, SharedWithOrganizationFilter, TagFilter, TaskCompletedCountFilter, TaskRemainingCountFilter, WorkforceRequestedDateFilter, WorkforceRequestedDateRangeFilter, WorkforceStageUpdatedFilter, WorkforceStageUpdatedRangeFilter, WorkspaceFilter, build_search_filter
33
from labelbox.utils import format_iso_datetime
44

55

66
def test_id_filters():
77
filters = [
88
OrganizationFilter(operator=IdOperator.Is,
99
values=["clphb4vd7000cd2wv1ktu5cwa"]),
10+
SharedWithOrganizationFilter(operator=IdOperator.Is,
11+
values=["clphb4vd7000cd2wv1ktu5cwa"]),
1012
WorkspaceFilter(operator=IdOperator.Is,
1113
values=["clphb4vd7000cd2wv1ktu5cwa"]),
1214
TagFilter(operator=IdOperator.Is, values=["tag"]),
@@ -15,7 +17,7 @@ def test_id_filters():
1517

1618
assert build_search_filter(
1719
filters
18-
) == '[{operator: "is", values: ["clphb4vd7000cd2wv1ktu5cwa"], type: "organization_id"}, {operator: "is", values: ["clphb4vd7000cd2wv1ktu5cwa"], type: "workspace"}, {operator: "is", values: ["tag"], type: "tag"}, {operator: "is", values: ["requested"], type: "stage"}]'
20+
) == '[{operator: "is", values: ["clphb4vd7000cd2wv1ktu5cwa"], type: "organization_id"}, {operator: "is", values: ["clphb4vd7000cd2wv1ktu5cwa"], type: "shared_with_organizations"}, {operator: "is", values: ["clphb4vd7000cd2wv1ktu5cwa"], type: "workspace"}, {operator: "is", values: ["tag"], type: "tag"}, {operator: "is", values: ["requested"], type: "stage"}]'
1921

2022

2123
def test_date_filters():

0 commit comments

Comments
 (0)