Skip to content

Vb/make labeling service user friendly #1775

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 6 commits into from
Aug 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions libs/labelbox/src/labelbox/schema/media_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion libs/labelbox/src/labelbox/schema/search_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OperationType(Enum):
"""
Supported search entity types
"""
Organization = 'organization'
Organization = 'organization_id'
Workspace = 'workspace'
Tag = 'tag'
Stage = 'stage'
Expand Down
8 changes: 4 additions & 4 deletions libs/labelbox/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -1113,4 +1113,4 @@ def requested_labeling_service(

labeling_service.request()

yield project, labeling_service
yield project, project.get_labeling_service()
58 changes: 19 additions & 39 deletions libs/labelbox/tests/integration/test_labeling_dashboard.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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
2 changes: 1 addition & 1 deletion libs/labelbox/tests/unit/test_unit_search_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
Loading