1
1
from datetime import datetime , timedelta
2
+ from labelbox .exceptions import ResourceNotFoundError
2
3
from labelbox .schema .labeling_service import LabelingServiceStatus
3
4
from labelbox .schema .ontology_kind import EditorTaskType
4
5
from labelbox .schema .media_type import MediaType
5
6
from labelbox .schema .search_filters import IntegerValue , RangeOperatorWithSingleValue , DateRange , RangeOperatorWithValue , DateRangeValue , DateValue , IdOperator , OperationType , OrganizationFilter , TaskCompletedCountFilter , WorkforceRequestedDateFilter , WorkforceRequestedDateRangeFilter , WorkspaceFilter , TaskRemainingCountFilter
6
7
7
8
8
- def test_request_labeling_service_dashboard (rand_gen ,
9
- offline_chat_evaluation_project ,
10
- chat_evaluation_ontology ,
11
- offline_conversational_data_row ):
12
- project = offline_chat_evaluation_project
13
- project .connect_ontology (chat_evaluation_ontology )
9
+ def test_request_labeling_service_dashboard (requested_labeling_service ):
10
+ project , _ = requested_labeling_service
14
11
15
- project .create_batch (
16
- rand_gen (str ),
17
- [offline_conversational_data_row .uid ], # sample of data row objects
18
- )
19
12
labeling_service_dashboard = project .labeling_service_dashboard ()
20
- assert labeling_service_dashboard .status == LabelingServiceStatus .Missing
13
+ assert labeling_service_dashboard .status == LabelingServiceStatus .Requested
21
14
assert labeling_service_dashboard .tasks_completed == 0
22
15
assert labeling_service_dashboard .tasks_remaining == 0
23
16
assert labeling_service_dashboard .media_type == MediaType .Conversational
24
- assert labeling_service_dashboard .editor_task_type == EditorTaskType .OfflineModelChatEvaluation
25
- 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"
26
19
27
- labeling_service_dashboard = [
28
- ld for ld in project .client .get_labeling_service_dashboards ()
29
- ][0 ]
30
- assert labeling_service_dashboard .status == LabelingServiceStatus .Missing
31
- assert labeling_service_dashboard .tasks_completed == 0
32
- assert labeling_service_dashboard .tasks_remaining == 0
20
+ labeling_service_dashboard = project .client .get_labeling_service_dashboards (
21
+ ).get_one ()
22
+ assert labeling_service_dashboard
33
23
34
24
35
25
def test_request_labeling_service_dashboard_filters (requested_labeling_service ):
@@ -40,10 +30,8 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
40
30
operator = IdOperator .Is ,
41
31
values = [organization .uid ])
42
32
43
- labeling_service_dashboard = [
44
- ld for ld in project .client .get_labeling_service_dashboards (
45
- search_query = [org_filter ])
46
- ][0 ]
33
+ labeling_service_dashboard = project .client .get_labeling_service_dashboards (
34
+ search_query = [org_filter ]).get_one ()
47
35
assert labeling_service_dashboard is not None
48
36
49
37
workforce_requested_filter_before = WorkforceRequestedDateFilter (
@@ -57,12 +45,10 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
57
45
value = DateValue (operator = RangeOperatorWithSingleValue .LessThanOrEqual ,
58
46
value = year_from_now ))
59
47
60
- labeling_service_dashboard = [
61
- ld
62
- for ld in project .client .get_labeling_service_dashboards (search_query = [
48
+ labeling_service_dashboard = project .client .get_labeling_service_dashboards (
49
+ search_query = [
63
50
workforce_requested_filter_after , workforce_requested_filter_before
64
- ])
65
- ][0 ]
51
+ ]).get_one ()
66
52
assert labeling_service_dashboard is not None
67
53
68
54
workforce_date_range_filter = WorkforceRequestedDateRangeFilter (
@@ -71,10 +57,8 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
71
57
value = DateRange (min = "2024-01-01T00:00:00-0800" ,
72
58
max = year_from_now )))
73
59
74
- labeling_service_dashboard = [
75
- ld for ld in project .client .get_labeling_service_dashboards (
76
- search_query = [workforce_date_range_filter ])
77
- ][0 ]
60
+ labeling_service_dashboard = project .client .get_labeling_service_dashboards (
61
+ search_query = [workforce_date_range_filter ]).get_one ()
78
62
assert labeling_service_dashboard is not None
79
63
80
64
# with non existing data
@@ -88,9 +72,6 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
88
72
]
89
73
assert len (labeling_service_dashboard ) == 0
90
74
assert labeling_service_dashboard == []
91
- labeling_service_dashboard = project .client .get_labeling_service_dashboards (
92
- ).get_one ()
93
- assert labeling_service_dashboard
94
75
95
76
task_done_count_filter = TaskCompletedCountFilter (
96
77
operation = OperationType .TaskCompletedCount ,
@@ -101,8 +82,7 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
101
82
value = IntegerValue (
102
83
operator = RangeOperatorWithSingleValue .GreaterThanOrEqual , value = 0 ))
103
84
104
- labeling_service_dashboard = [
105
- ld for ld in project .client .get_labeling_service_dashboards (
106
- search_query = [task_done_count_filter , task_remaining_count_filter ])
107
- ][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 ()
108
88
assert labeling_service_dashboard is not None
0 commit comments