4
4
from labelbox .schema .ontology_kind import EditorTaskType
5
5
from labelbox .schema .media_type import MediaType
6
6
from labelbox .schema .search_filters import IntegerValue , RangeOperatorWithSingleValue , DateRange , RangeOperatorWithValue , DateRangeValue , DateValue , IdOperator , OperationType , OrganizationFilter , TaskCompletedCountFilter , WorkforceRequestedDateFilter , WorkforceRequestedDateRangeFilter , WorkspaceFilter , TaskRemainingCountFilter
7
- import pytest
8
7
9
8
10
9
def test_request_labeling_service_dashboard (requested_labeling_service ):
11
10
project , _ = requested_labeling_service
12
11
13
12
labeling_service_dashboard = project .labeling_service_dashboard ()
14
- assert labeling_service_dashboard .status == LabelingServiceStatus .Missing
13
+ assert labeling_service_dashboard .status == LabelingServiceStatus .Requested
15
14
assert labeling_service_dashboard .tasks_completed == 0
16
15
assert labeling_service_dashboard .tasks_remaining == 0
17
16
assert labeling_service_dashboard .media_type == MediaType .Conversational
18
- assert labeling_service_dashboard .editor_task_type == EditorTaskType .OfflineModelChatEvaluation
19
- assert labeling_service_dashboard .service_type == "Offline chat evaluation"
17
+ assert labeling_service_dashboard .editor_task_type == EditorTaskType .ModelChatEvaluation
18
+ assert labeling_service_dashboard .service_type == "Live chat evaluation"
20
19
21
- labeling_service_dashboard = [
22
- ld for ld in project .client .get_labeling_service_dashboards ()
23
- ][0 ]
24
- assert labeling_service_dashboard .status == LabelingServiceStatus .Missing
25
- assert labeling_service_dashboard .tasks_completed == 0
26
- assert labeling_service_dashboard .tasks_remaining == 0
27
-
28
-
29
- def test_request_labeling_service_dashboard_not_started (
30
- offline_chat_evaluation_project ):
31
- project = offline_chat_evaluation_project
32
-
33
- with pytest .raises (ResourceNotFoundError ) as e :
34
- project .labeling_service_dashboard ()
35
-
36
- with pytest .raises (ResourceNotFoundError ) as e :
37
- [ld for ld in project .client .get_labeling_service_dashboards ()][0 ]
20
+ labeling_service_dashboard = project .client .get_labeling_service_dashboards (
21
+ ).get_one ()
22
+ assert labeling_service_dashboard
38
23
39
24
40
25
def test_request_labeling_service_dashboard_filters (requested_labeling_service ):
@@ -45,10 +30,8 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
45
30
operator = IdOperator .Is ,
46
31
values = [organization .uid ])
47
32
48
- labeling_service_dashboard = [
49
- ld for ld in project .client .get_labeling_service_dashboards (
50
- search_query = [org_filter ])
51
- ][0 ]
33
+ labeling_service_dashboard = project .client .get_labeling_service_dashboards (
34
+ search_query = [org_filter ]).get_one ()
52
35
assert labeling_service_dashboard is not None
53
36
54
37
workforce_requested_filter_before = WorkforceRequestedDateFilter (
@@ -62,12 +45,10 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
62
45
value = DateValue (operator = RangeOperatorWithSingleValue .LessThanOrEqual ,
63
46
value = year_from_now ))
64
47
65
- labeling_service_dashboard = [
66
- ld
67
- for ld in project .client .get_labeling_service_dashboards (search_query = [
48
+ labeling_service_dashboard = project .client .get_labeling_service_dashboards (
49
+ search_query = [
68
50
workforce_requested_filter_after , workforce_requested_filter_before
69
- ])
70
- ][0 ]
51
+ ]).get_one ()
71
52
assert labeling_service_dashboard is not None
72
53
73
54
workforce_date_range_filter = WorkforceRequestedDateRangeFilter (
@@ -76,10 +57,8 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
76
57
value = DateRange (min = "2024-01-01T00:00:00-0800" ,
77
58
max = year_from_now )))
78
59
79
- labeling_service_dashboard = [
80
- ld for ld in project .client .get_labeling_service_dashboards (
81
- search_query = [workforce_date_range_filter ])
82
- ][0 ]
60
+ labeling_service_dashboard = project .client .get_labeling_service_dashboards (
61
+ search_query = [workforce_date_range_filter ]).get_one ()
83
62
assert labeling_service_dashboard is not None
84
63
85
64
# with non existing data
@@ -93,9 +72,6 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
93
72
]
94
73
assert len (labeling_service_dashboard ) == 0
95
74
assert labeling_service_dashboard == []
96
- labeling_service_dashboard = project .client .get_labeling_service_dashboards (
97
- ).get_one ()
98
- assert labeling_service_dashboard
99
75
100
76
task_done_count_filter = TaskCompletedCountFilter (
101
77
operation = OperationType .TaskCompletedCount ,
@@ -106,8 +82,7 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
106
82
value = IntegerValue (
107
83
operator = RangeOperatorWithSingleValue .GreaterThanOrEqual , value = 0 ))
108
84
109
- labeling_service_dashboard = [
110
- ld for ld in project .client .get_labeling_service_dashboards (
111
- search_query = [task_done_count_filter , task_remaining_count_filter ])
112
- ][0 ]
85
+ labeling_service_dashboard = project .client .get_labeling_service_dashboards (
86
+ search_query = [task_done_count_filter , task_remaining_count_filter
87
+ ]).get_one ()
113
88
assert labeling_service_dashboard is not None
0 commit comments