diff --git a/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py b/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py index b7147e98a..efbd740fb 100644 --- a/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py +++ b/libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py @@ -25,9 +25,16 @@ dataRowsDoneCount mediaType editorTaskType + tags """ +class LabelingServiceDashboardTags(BaseModel): + name: str + color: str + type: str + + class LabelingServiceDashboard(BaseModel): """ Represent labeling service data for a project @@ -52,6 +59,7 @@ class LabelingServiceDashboard(BaseModel): data_rows_done_count: int = Field(frozen=True) media_type: Optional[MediaType] = Field(frozen=True, default=None) editor_task_type: EditorTaskType = Field(frozen=True, default=None) + tags: List[LabelingServiceDashboardTags] = Field(frozen=True, default=None) client: Any # type Any to avoid circular import from client @@ -121,7 +129,8 @@ def get(cls, client, project_id: str) -> 'LabelingServiceDashboard': result = client.execute(query, {"id": project_id}, experimental=True) if result["getProjectById"] is None: raise ResourceNotFoundError( - message="The project does not have a labeling service.") + message="The project does not have a labeling service data yet." + ) data = result["getProjectById"] data["client"] = client return cls(**data) @@ -190,3 +199,11 @@ def convert_boost_data(cls, data): data['created_by_id'] = data.pop('boostRequestedBy') return data + + def dict(self, *args, **kwargs): + row = super().dict(*args, **kwargs) + row.pop('client') + row['tasks_completed'] = self.tasks_completed + row['tasks_remaining'] = self.tasks_remaining + row['service_type'] = self.service_type + return row diff --git a/libs/labelbox/src/labelbox/schema/media_type.py b/libs/labelbox/src/labelbox/schema/media_type.py index 266e2a0e3..99807522b 100644 --- a/libs/labelbox/src/labelbox/schema/media_type.py +++ b/libs/labelbox/src/labelbox/schema/media_type.py @@ -54,6 +54,8 @@ def matches(value, name): if matches(value, name): return member + return cls.Unsupported + @classmethod def is_supported(cls, value): return isinstance(value, diff --git a/libs/labelbox/src/labelbox/schema/search_filters.py b/libs/labelbox/src/labelbox/schema/search_filters.py index 7f3aefd89..e3e7d0e4b 100644 --- a/libs/labelbox/src/labelbox/schema/search_filters.py +++ b/libs/labelbox/src/labelbox/schema/search_filters.py @@ -30,7 +30,7 @@ class OperationType(Enum): """ Supported search entity types """ - Organization = 'organization' + Organization = 'organization_id' Workspace = 'workspace' Tag = 'tag' Stage = 'stage' diff --git a/libs/labelbox/tests/conftest.py b/libs/labelbox/tests/conftest.py index 0ee53a97c..a69556c04 100644 --- a/libs/labelbox/tests/conftest.py +++ b/libs/labelbox/tests/conftest.py @@ -1099,9 +1099,9 @@ def valid_model_id(): @pytest.fixture -def requested_labeling_service( - rand_gen, live_chat_evaluation_project_with_new_dataset, - chat_evaluation_ontology, model_config): +def requested_labeling_service(rand_gen, + live_chat_evaluation_project_with_new_dataset, + chat_evaluation_ontology, model_config): project = live_chat_evaluation_project_with_new_dataset project.connect_ontology(chat_evaluation_ontology) @@ -1113,4 +1113,4 @@ def requested_labeling_service( labeling_service.request() - yield project, labeling_service + yield project, project.get_labeling_service() diff --git a/libs/labelbox/tests/integration/test_labeling_dashboard.py b/libs/labelbox/tests/integration/test_labeling_dashboard.py index 11cd3ad19..803293497 100644 --- a/libs/labelbox/tests/integration/test_labeling_dashboard.py +++ b/libs/labelbox/tests/integration/test_labeling_dashboard.py @@ -1,35 +1,25 @@ from datetime import datetime, timedelta +from labelbox.exceptions import ResourceNotFoundError from labelbox.schema.labeling_service import LabelingServiceStatus from labelbox.schema.ontology_kind import EditorTaskType from labelbox.schema.media_type import MediaType from labelbox.schema.search_filters import IntegerValue, RangeOperatorWithSingleValue, DateRange, RangeOperatorWithValue, DateRangeValue, DateValue, IdOperator, OperationType, OrganizationFilter, TaskCompletedCountFilter, WorkforceRequestedDateFilter, WorkforceRequestedDateRangeFilter, WorkspaceFilter, TaskRemainingCountFilter -def test_request_labeling_service_dashboard(rand_gen, - offline_chat_evaluation_project, - chat_evaluation_ontology, - offline_conversational_data_row): - project = offline_chat_evaluation_project - project.connect_ontology(chat_evaluation_ontology) +def test_request_labeling_service_dashboard(requested_labeling_service): + project, _ = requested_labeling_service - project.create_batch( - rand_gen(str), - [offline_conversational_data_row.uid], # sample of data row objects - ) labeling_service_dashboard = project.labeling_service_dashboard() - assert labeling_service_dashboard.status == LabelingServiceStatus.Missing + assert labeling_service_dashboard.status == LabelingServiceStatus.Requested assert labeling_service_dashboard.tasks_completed == 0 assert labeling_service_dashboard.tasks_remaining == 0 assert labeling_service_dashboard.media_type == MediaType.Conversational - assert labeling_service_dashboard.editor_task_type == EditorTaskType.OfflineModelChatEvaluation - assert labeling_service_dashboard.service_type == "Offline chat evaluation" + assert labeling_service_dashboard.editor_task_type == EditorTaskType.ModelChatEvaluation + assert labeling_service_dashboard.service_type == "Live chat evaluation" - labeling_service_dashboard = [ - ld for ld in project.client.get_labeling_service_dashboards() - ][0] - assert labeling_service_dashboard.status == LabelingServiceStatus.Missing - assert labeling_service_dashboard.tasks_completed == 0 - assert labeling_service_dashboard.tasks_remaining == 0 + labeling_service_dashboard = project.client.get_labeling_service_dashboards( + ).get_one() + assert labeling_service_dashboard def test_request_labeling_service_dashboard_filters(requested_labeling_service): @@ -40,10 +30,8 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service): operator=IdOperator.Is, values=[organization.uid]) - labeling_service_dashboard = [ - ld for ld in project.client.get_labeling_service_dashboards( - search_query=[org_filter]) - ][0] + labeling_service_dashboard = project.client.get_labeling_service_dashboards( + search_query=[org_filter]).get_one() assert labeling_service_dashboard is not None workforce_requested_filter_before = WorkforceRequestedDateFilter( @@ -57,12 +45,10 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service): value=DateValue(operator=RangeOperatorWithSingleValue.LessThanOrEqual, value=year_from_now)) - labeling_service_dashboard = [ - ld - for ld in project.client.get_labeling_service_dashboards(search_query=[ + labeling_service_dashboard = project.client.get_labeling_service_dashboards( + search_query=[ workforce_requested_filter_after, workforce_requested_filter_before - ]) - ][0] + ]).get_one() assert labeling_service_dashboard is not None workforce_date_range_filter = WorkforceRequestedDateRangeFilter( @@ -71,10 +57,8 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service): value=DateRange(min="2024-01-01T00:00:00-0800", max=year_from_now))) - labeling_service_dashboard = [ - ld for ld in project.client.get_labeling_service_dashboards( - search_query=[workforce_date_range_filter]) - ][0] + labeling_service_dashboard = project.client.get_labeling_service_dashboards( + search_query=[workforce_date_range_filter]).get_one() assert labeling_service_dashboard is not None # with non existing data @@ -88,9 +72,6 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service): ] assert len(labeling_service_dashboard) == 0 assert labeling_service_dashboard == [] - labeling_service_dashboard = project.client.get_labeling_service_dashboards( - ).get_one() - assert labeling_service_dashboard task_done_count_filter = TaskCompletedCountFilter( operation=OperationType.TaskCompletedCount, @@ -101,8 +82,7 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service): value=IntegerValue( operator=RangeOperatorWithSingleValue.GreaterThanOrEqual, value=0)) - labeling_service_dashboard = [ - ld for ld in project.client.get_labeling_service_dashboards( - search_query=[task_done_count_filter, task_remaining_count_filter]) - ][0] + labeling_service_dashboard = project.client.get_labeling_service_dashboards( + search_query=[task_done_count_filter, task_remaining_count_filter + ]).get_one() assert labeling_service_dashboard is not None diff --git a/libs/labelbox/tests/unit/test_unit_search_filters.py b/libs/labelbox/tests/unit/test_unit_search_filters.py index 90b09ad67..404ba7b34 100644 --- a/libs/labelbox/tests/unit/test_unit_search_filters.py +++ b/libs/labelbox/tests/unit/test_unit_search_filters.py @@ -15,7 +15,7 @@ def test_id_filters(): assert build_search_filter( filters - ) == '[{operator: "is", values: ["clphb4vd7000cd2wv1ktu5cwa"], type: "organization"}, {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: "workspace"}, {operator: "is", values: ["tag"], type: "tag"}, {operator: "is", values: ["requested"], type: "stage"}]' def test_date_filters():