From 21a3161cd2384f3512e6a8fa8050778fb9b49a1f Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Fri, 23 Aug 2024 11:28:36 -0700 Subject: [PATCH 1/4] Deal with missing tag names --- libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py b/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py index efbd740fb..18597ddda 100644 --- a/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py +++ b/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py @@ -30,7 +30,7 @@ class LabelingServiceDashboardTags(BaseModel): - name: str + text: str color: str type: str From 1e31e613f661762913abd7f07ed2929deb78ece6 Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Fri, 23 Aug 2024 11:56:23 -0700 Subject: [PATCH 2/4] Add SharedWithOrganization filter --- .../src/labelbox/schema/search_filters.py | 15 ++++++++++++++- .../tests/unit/test_unit_search_filters.py | 6 ++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libs/labelbox/src/labelbox/schema/search_filters.py b/libs/labelbox/src/labelbox/schema/search_filters.py index e3e7d0e4b..372e05803 100644 --- a/libs/labelbox/src/labelbox/schema/search_filters.py +++ b/libs/labelbox/src/labelbox/schema/search_filters.py @@ -31,6 +31,7 @@ class OperationType(Enum): Supported search entity types """ Organization = 'organization_id' + SharedWithOrganization = 'shared_with_organizations' Workspace = 'workspace' Tag = 'tag' Stage = 'stage' @@ -72,6 +73,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 @@ -194,7 +206,8 @@ class TaskRemainingCountFilter(BaseSearchFilter): value: IntegerValue -SearchFilter = Union[OrganizationFilter, WorkspaceFilter, TagFilter, +SearchFilter = Union[OrganizationFilter, WorkspaceFilter, + SharedWithOrganizationFilter, TagFilter, ProjectStageFilter, WorkforceRequestedDateFilter, WorkforceStageUpdatedFilter, WorkforceRequestedDateRangeFilter, diff --git a/libs/labelbox/tests/unit/test_unit_search_filters.py b/libs/labelbox/tests/unit/test_unit_search_filters.py index 404ba7b34..29bc0fc78 100644 --- a/libs/labelbox/tests/unit/test_unit_search_filters.py +++ b/libs/labelbox/tests/unit/test_unit_search_filters.py @@ -1,5 +1,5 @@ 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.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 @@ -7,6 +7,8 @@ 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"]), @@ -15,7 +17,7 @@ def test_id_filters(): 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(): From 94f85ff569029c8e557d8032410c549861916c96 Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Fri, 23 Aug 2024 12:30:53 -0700 Subject: [PATCH 3/4] Fix stage filter --- .../labelbox/src/labelbox/schema/labeling_service_dashboard.py | 1 - libs/labelbox/src/labelbox/schema/search_filters.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py b/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py index 18597ddda..9c64d57b3 100644 --- a/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py +++ b/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py @@ -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): diff --git a/libs/labelbox/src/labelbox/schema/search_filters.py b/libs/labelbox/src/labelbox/schema/search_filters.py index 372e05803..10b46755d 100644 --- a/libs/labelbox/src/labelbox/schema/search_filters.py +++ b/libs/labelbox/src/labelbox/schema/search_filters.py @@ -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 @@ -108,7 +109,7 @@ class ProjectStageFilter(BaseSearchFilter): """ operation: Literal[OperationType.Stage] = OperationType.Stage operator: IdOperator - values: List[str] + values: List[LabelingServiceStatus] class DateValue(BaseSearchFilter): From 7bdf38d46caf9334dc7e42a777ee43886dc38ccc Mon Sep 17 00:00:00 2001 From: Val Brodsky Date: Fri, 23 Aug 2024 15:58:43 -0700 Subject: [PATCH 4/4] Docstring update --- libs/labelbox/src/labelbox/client.py | 3 ++- libs/labelbox/tests/unit/test_unit_search_filters.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/labelbox/src/labelbox/client.py b/libs/labelbox/src/labelbox/client.py index e67bf30bf..d2fa3e57e 100644 --- a/libs/labelbox/src/labelbox/client.py +++ b/libs/labelbox/src/labelbox/client.py @@ -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: diff --git a/libs/labelbox/tests/unit/test_unit_search_filters.py b/libs/labelbox/tests/unit/test_unit_search_filters.py index 29bc0fc78..38e091487 100644 --- a/libs/labelbox/tests/unit/test_unit_search_filters.py +++ b/libs/labelbox/tests/unit/test_unit_search_filters.py @@ -1,4 +1,5 @@ from datetime import datetime +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 @@ -12,12 +13,13 @@ def test_id_filters(): 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: "shared_with_organizations"}, {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():