Skip to content

Vb/fixes and improvements 1 #1777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libs/labelbox/src/labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,8 @@ def get_labeling_service_dashboards(
search_query: A list of search filters representing the search

NOTE:
- Retrieves all projects for the organization or as filtered by the search query.
- Retrieves all projects for the organization or as filtered by the search query
- INCLUDING those not requesting labeling services
- Sorted by project created date in ascending order.

Examples:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


class LabelingServiceDashboardTags(BaseModel):
name: str
text: str
color: str
type: str

Expand Down Expand Up @@ -167,7 +167,6 @@ def get_all(
search_query=build_search_filter(search_query)
if search_query else None,
)

params: Dict[str, Union[str, int]] = {}

def convert_to_labeling_service_dashboard(client, data):
Expand Down
18 changes: 16 additions & 2 deletions libs/labelbox/src/labelbox/schema/search_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import List, Literal, Union

from labelbox.pydantic_compat import BaseModel
from labelbox.schema.labeling_service_status import LabelingServiceStatus
from labelbox.utils import format_iso_datetime


Expand Down Expand Up @@ -31,6 +32,7 @@ class OperationType(Enum):
Supported search entity types
"""
Organization = 'organization_id'
SharedWithOrganization = 'shared_with_organizations'
Workspace = 'workspace'
Tag = 'tag'
Stage = 'stage'
Expand Down Expand Up @@ -72,6 +74,17 @@ class OrganizationFilter(BaseSearchFilter):
values: List[str]


class SharedWithOrganizationFilter(BaseSearchFilter):
"""
Find project shared with organization (i.e. not belonging to any of organization's workspace)
"""
operation: Literal[
OperationType.
SharedWithOrganization] = OperationType.SharedWithOrganization
operator: IdOperator
values: List[str]


class WorkspaceFilter(BaseSearchFilter):
"""
Filter for workspace
Expand All @@ -96,7 +109,7 @@ class ProjectStageFilter(BaseSearchFilter):
"""
operation: Literal[OperationType.Stage] = OperationType.Stage
operator: IdOperator
values: List[str]
values: List[LabelingServiceStatus]


class DateValue(BaseSearchFilter):
Expand Down Expand Up @@ -194,7 +207,8 @@ class TaskRemainingCountFilter(BaseSearchFilter):
value: IntegerValue


SearchFilter = Union[OrganizationFilter, WorkspaceFilter, TagFilter,
SearchFilter = Union[OrganizationFilter, WorkspaceFilter,
SharedWithOrganizationFilter, TagFilter,
ProjectStageFilter, WorkforceRequestedDateFilter,
WorkforceStageUpdatedFilter,
WorkforceRequestedDateRangeFilter,
Expand Down
10 changes: 7 additions & 3 deletions libs/labelbox/tests/unit/test_unit_search_filters.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
from datetime import datetime
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
from labelbox.schema.labeling_service import LabelingServiceStatus
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
from labelbox.utils import format_iso_datetime


def test_id_filters():
filters = [
OrganizationFilter(operator=IdOperator.Is,
values=["clphb4vd7000cd2wv1ktu5cwa"]),
SharedWithOrganizationFilter(operator=IdOperator.Is,
values=["clphb4vd7000cd2wv1ktu5cwa"]),
WorkspaceFilter(operator=IdOperator.Is,
values=["clphb4vd7000cd2wv1ktu5cwa"]),
TagFilter(operator=IdOperator.Is, values=["tag"]),
ProjectStageFilter(operator=IdOperator.Is, values=["requested"]),
ProjectStageFilter(operator=IdOperator.Is,
values=[LabelingServiceStatus.Requested]),
]

assert build_search_filter(
filters
) == '[{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"}]'
) == '[{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"}]'


def test_date_filters():
Expand Down
Loading