Skip to content

Commit 2497939

Browse files
authored
Vb/fixes and improvements 1 (#1777)
1 parent ebe0f35 commit 2497939

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

libs/labelbox/src/labelbox/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,8 @@ def get_labeling_service_dashboards(
24192419
search_query: A list of search filters representing the search
24202420
24212421
NOTE:
2422-
- Retrieves all projects for the organization or as filtered by the search query.
2422+
- Retrieves all projects for the organization or as filtered by the search query
2423+
- INCLUDING those not requesting labeling services
24232424
- Sorted by project created date in ascending order.
24242425
24252426
Examples:

libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
class LabelingServiceDashboardTags(BaseModel):
33-
name: str
33+
text: str
3434
color: str
3535
type: str
3636

@@ -167,7 +167,6 @@ def get_all(
167167
search_query=build_search_filter(search_query)
168168
if search_query else None,
169169
)
170-
171170
params: Dict[str, Union[str, int]] = {}
172171

173172
def convert_to_labeling_service_dashboard(client, data):

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import List, Literal, Union
44

55
from labelbox.pydantic_compat import BaseModel
6+
from labelbox.schema.labeling_service_status import LabelingServiceStatus
67
from labelbox.utils import format_iso_datetime
78

89

@@ -31,6 +32,7 @@ class OperationType(Enum):
3132
Supported search entity types
3233
"""
3334
Organization = 'organization_id'
35+
SharedWithOrganization = 'shared_with_organizations'
3436
Workspace = 'workspace'
3537
Tag = 'tag'
3638
Stage = 'stage'
@@ -72,6 +74,17 @@ class OrganizationFilter(BaseSearchFilter):
7274
values: List[str]
7375

7476

77+
class SharedWithOrganizationFilter(BaseSearchFilter):
78+
"""
79+
Find project shared with organization (i.e. not belonging to any of organization's workspace)
80+
"""
81+
operation: Literal[
82+
OperationType.
83+
SharedWithOrganization] = OperationType.SharedWithOrganization
84+
operator: IdOperator
85+
values: List[str]
86+
87+
7588
class WorkspaceFilter(BaseSearchFilter):
7689
"""
7790
Filter for workspace
@@ -96,7 +109,7 @@ class ProjectStageFilter(BaseSearchFilter):
96109
"""
97110
operation: Literal[OperationType.Stage] = OperationType.Stage
98111
operator: IdOperator
99-
values: List[str]
112+
values: List[LabelingServiceStatus]
100113

101114

102115
class DateValue(BaseSearchFilter):
@@ -194,7 +207,8 @@ class TaskRemainingCountFilter(BaseSearchFilter):
194207
value: IntegerValue
195208

196209

197-
SearchFilter = Union[OrganizationFilter, WorkspaceFilter, TagFilter,
210+
SearchFilter = Union[OrganizationFilter, WorkspaceFilter,
211+
SharedWithOrganizationFilter, TagFilter,
198212
ProjectStageFilter, WorkforceRequestedDateFilter,
199213
WorkforceStageUpdatedFilter,
200214
WorkforceRequestedDateRangeFilter,

libs/labelbox/tests/unit/test_unit_search_filters.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
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.labeling_service import LabelingServiceStatus
3+
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
34
from labelbox.utils import format_iso_datetime
45

56

67
def test_id_filters():
78
filters = [
89
OrganizationFilter(operator=IdOperator.Is,
910
values=["clphb4vd7000cd2wv1ktu5cwa"]),
11+
SharedWithOrganizationFilter(operator=IdOperator.Is,
12+
values=["clphb4vd7000cd2wv1ktu5cwa"]),
1013
WorkspaceFilter(operator=IdOperator.Is,
1114
values=["clphb4vd7000cd2wv1ktu5cwa"]),
1215
TagFilter(operator=IdOperator.Is, values=["tag"]),
13-
ProjectStageFilter(operator=IdOperator.Is, values=["requested"]),
16+
ProjectStageFilter(operator=IdOperator.Is,
17+
values=[LabelingServiceStatus.Requested]),
1418
]
1519

1620
assert build_search_filter(
1721
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"}]'
22+
) == '[{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"}]'
1923

2024

2125
def test_date_filters():

0 commit comments

Comments
 (0)