superb-ai-onprem 0.9.1__py3-none-any.whl → 0.10.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of superb-ai-onprem might be problematic. Click here for more details.
- spb_onprem/__init__.py +39 -4
- spb_onprem/_version.py +2 -2
- spb_onprem/data/entities/__init__.py +2 -0
- spb_onprem/data/entities/data.py +2 -0
- spb_onprem/data/entities/data_annotation_stats.py +8 -0
- spb_onprem/data/params/data_list.py +7 -2
- spb_onprem/data/params/update_data.py +11 -0
- spb_onprem/data/params/update_data_slice.py +14 -2
- spb_onprem/data/queries.py +12 -1
- spb_onprem/data/service.py +9 -0
- spb_onprem/entities.py +24 -2
- spb_onprem/models/__init__.py +8 -3
- spb_onprem/models/entities/__init__.py +9 -0
- spb_onprem/models/entities/model.py +32 -0
- spb_onprem/models/entities/model_page_info.py +14 -0
- spb_onprem/models/entities/model_train_class.py +15 -0
- spb_onprem/models/params/__init__.py +16 -4
- spb_onprem/models/params/create_model.py +70 -0
- spb_onprem/models/params/delete_model.py +11 -8
- spb_onprem/models/params/model.py +17 -0
- spb_onprem/models/params/models.py +60 -0
- spb_onprem/models/params/pin_model.py +17 -0
- spb_onprem/models/params/unpin_model.py +17 -0
- spb_onprem/models/params/update_model.py +61 -0
- spb_onprem/models/queries.py +224 -19
- spb_onprem/models/service.py +251 -30
- spb_onprem/reports/__init__.py +25 -0
- spb_onprem/reports/entities/__init__.py +10 -0
- spb_onprem/reports/entities/analytics_report.py +22 -0
- spb_onprem/reports/entities/analytics_report_item.py +30 -0
- spb_onprem/reports/entities/analytics_report_page_info.py +14 -0
- spb_onprem/reports/params/__init__.py +29 -0
- spb_onprem/reports/params/analytics_report.py +17 -0
- spb_onprem/reports/params/analytics_reports.py +87 -0
- spb_onprem/reports/params/create_analytics_report.py +35 -0
- spb_onprem/reports/params/create_analytics_report_item.py +47 -0
- spb_onprem/reports/params/delete_analytics_report.py +17 -0
- spb_onprem/reports/params/delete_analytics_report_item.py +20 -0
- spb_onprem/reports/params/update_analytics_report.py +38 -0
- spb_onprem/reports/params/update_analytics_report_item.py +46 -0
- spb_onprem/reports/queries.py +239 -0
- spb_onprem/reports/service.py +328 -0
- spb_onprem/searches.py +18 -0
- {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/METADATA +53 -9
- {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/RECORD +48 -38
- spb_onprem/models/entities.py +0 -9
- spb_onprem/models/params/get_models.py +0 -29
- spb_onprem/predictions/__init__.py +0 -7
- spb_onprem/predictions/entities.py +0 -11
- spb_onprem/predictions/params/__init__.py +0 -15
- spb_onprem/predictions/params/create_prediction_set.py +0 -44
- spb_onprem/predictions/params/delete_prediction_from_data.py +0 -20
- spb_onprem/predictions/params/delete_prediction_set.py +0 -14
- spb_onprem/predictions/params/get_prediction_set.py +0 -14
- spb_onprem/predictions/params/get_prediction_sets.py +0 -29
- spb_onprem/predictions/params/update_prediction_set_data_info.py +0 -28
- spb_onprem/predictions/queries.py +0 -110
- spb_onprem/predictions/service.py +0 -225
- tests/models/__init__.py +0 -1
- tests/models/test_model_service.py +0 -249
- tests/predictions/__init__.py +0 -1
- tests/predictions/test_prediction_service.py +0 -359
- {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/WHEEL +0 -0
- {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/licenses/LICENSE +0 -0
- {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/top_level.txt +0 -0
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from unittest.mock import Mock
|
|
3
|
-
|
|
4
|
-
from spb_onprem.models.service import ModelService
|
|
5
|
-
from spb_onprem.models.queries import Queries
|
|
6
|
-
from spb_onprem.exceptions import BadParameterError
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class TestModelService:
|
|
10
|
-
"""Test cases for ModelService methods."""
|
|
11
|
-
|
|
12
|
-
def setup_method(self):
|
|
13
|
-
"""Set up test fixtures before each test method."""
|
|
14
|
-
self.model_service = ModelService()
|
|
15
|
-
self.model_service.request_gql = Mock()
|
|
16
|
-
|
|
17
|
-
def test_get_models_success(self):
|
|
18
|
-
"""Test successful models list retrieval."""
|
|
19
|
-
# Arrange
|
|
20
|
-
dataset_id = "dataset-123"
|
|
21
|
-
filter_dict = {"name": "test"}
|
|
22
|
-
cursor = "cursor-abc"
|
|
23
|
-
length = 25
|
|
24
|
-
|
|
25
|
-
mock_response = {
|
|
26
|
-
"models": [
|
|
27
|
-
{"id": "model-1", "name": "Model 1"},
|
|
28
|
-
{"id": "model-2", "name": "Model 2"}
|
|
29
|
-
],
|
|
30
|
-
"next": "cursor-def",
|
|
31
|
-
"totalCount": 50
|
|
32
|
-
}
|
|
33
|
-
self.model_service.request_gql.return_value = mock_response
|
|
34
|
-
|
|
35
|
-
# Act
|
|
36
|
-
result = self.model_service.get_models(
|
|
37
|
-
dataset_id=dataset_id,
|
|
38
|
-
filter=filter_dict,
|
|
39
|
-
cursor=cursor,
|
|
40
|
-
length=length
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
# Assert
|
|
44
|
-
models, next_cursor, total_count = result
|
|
45
|
-
assert len(models) == 2
|
|
46
|
-
assert models[0].id == "model-1"
|
|
47
|
-
assert models[0].name == "Model 1"
|
|
48
|
-
assert models[1].id == "model-2"
|
|
49
|
-
assert models[1].name == "Model 2"
|
|
50
|
-
assert next_cursor == "cursor-def"
|
|
51
|
-
assert total_count == 50
|
|
52
|
-
self.model_service.request_gql.assert_called_once_with(
|
|
53
|
-
Queries.GET_MODELS,
|
|
54
|
-
Queries.GET_MODELS["variables"](
|
|
55
|
-
dataset_id=dataset_id,
|
|
56
|
-
filter=filter_dict,
|
|
57
|
-
cursor=cursor,
|
|
58
|
-
length=length
|
|
59
|
-
)
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
def test_get_models_without_filter(self):
|
|
63
|
-
"""Test models retrieval without filter."""
|
|
64
|
-
# Arrange
|
|
65
|
-
dataset_id = "dataset-123"
|
|
66
|
-
|
|
67
|
-
mock_response = {
|
|
68
|
-
"models": [{"id": "model-1", "name": "Test Model"}],
|
|
69
|
-
"next": None,
|
|
70
|
-
"totalCount": 1
|
|
71
|
-
}
|
|
72
|
-
self.model_service.request_gql.return_value = mock_response
|
|
73
|
-
|
|
74
|
-
# Act
|
|
75
|
-
result = self.model_service.get_models(dataset_id=dataset_id)
|
|
76
|
-
|
|
77
|
-
# Assert
|
|
78
|
-
models, next_cursor, total_count = result
|
|
79
|
-
assert total_count == 1
|
|
80
|
-
assert next_cursor is None
|
|
81
|
-
assert len(models) == 1
|
|
82
|
-
assert models[0].name == "Test Model"
|
|
83
|
-
|
|
84
|
-
def test_get_models_with_pagination(self):
|
|
85
|
-
"""Test models retrieval with pagination parameters."""
|
|
86
|
-
# Arrange
|
|
87
|
-
dataset_id = "dataset-123"
|
|
88
|
-
cursor = "pagination-cursor"
|
|
89
|
-
length = 10
|
|
90
|
-
|
|
91
|
-
mock_response = {
|
|
92
|
-
"models": [
|
|
93
|
-
{"id": "model-3", "name": "Model 3"},
|
|
94
|
-
{"id": "model-4", "name": "Model 4"}
|
|
95
|
-
],
|
|
96
|
-
"next": "next-cursor",
|
|
97
|
-
"totalCount": 20
|
|
98
|
-
}
|
|
99
|
-
self.model_service.request_gql.return_value = mock_response
|
|
100
|
-
|
|
101
|
-
# Act
|
|
102
|
-
result = self.model_service.get_models(
|
|
103
|
-
dataset_id=dataset_id,
|
|
104
|
-
cursor=cursor,
|
|
105
|
-
length=length
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
# Assert
|
|
109
|
-
models, next_cursor, total_count = result
|
|
110
|
-
assert next_cursor == "next-cursor"
|
|
111
|
-
assert total_count == 20
|
|
112
|
-
assert len(models) == 2
|
|
113
|
-
|
|
114
|
-
def test_get_models_missing_dataset_id(self):
|
|
115
|
-
"""Test models with missing dataset_id."""
|
|
116
|
-
# Act & Assert
|
|
117
|
-
with pytest.raises(BadParameterError, match="dataset_id is required"):
|
|
118
|
-
self.model_service.get_models(dataset_id=None)
|
|
119
|
-
|
|
120
|
-
def test_get_models_empty_response(self):
|
|
121
|
-
"""Test models with empty response."""
|
|
122
|
-
# Arrange
|
|
123
|
-
dataset_id = "dataset-123"
|
|
124
|
-
mock_response = {}
|
|
125
|
-
self.model_service.request_gql.return_value = mock_response
|
|
126
|
-
|
|
127
|
-
# Act
|
|
128
|
-
result = self.model_service.get_models(dataset_id=dataset_id)
|
|
129
|
-
|
|
130
|
-
# Assert
|
|
131
|
-
models, next_cursor, total_count = result
|
|
132
|
-
assert len(models) == 0
|
|
133
|
-
assert next_cursor is None
|
|
134
|
-
assert total_count == 0
|
|
135
|
-
|
|
136
|
-
def test_get_models_zero_results(self):
|
|
137
|
-
"""Test models retrieval with zero results."""
|
|
138
|
-
# Arrange
|
|
139
|
-
dataset_id = "empty-dataset"
|
|
140
|
-
|
|
141
|
-
mock_response = {
|
|
142
|
-
"models": [],
|
|
143
|
-
"next": None,
|
|
144
|
-
"totalCount": 0
|
|
145
|
-
}
|
|
146
|
-
self.model_service.request_gql.return_value = mock_response
|
|
147
|
-
|
|
148
|
-
# Act
|
|
149
|
-
result = self.model_service.get_models(dataset_id=dataset_id)
|
|
150
|
-
|
|
151
|
-
# Assert
|
|
152
|
-
models, next_cursor, total_count = result
|
|
153
|
-
assert total_count == 0
|
|
154
|
-
assert next_cursor is None
|
|
155
|
-
assert len(models) == 0
|
|
156
|
-
|
|
157
|
-
def test_delete_model_success(self):
|
|
158
|
-
"""Test successful model deletion."""
|
|
159
|
-
# Arrange
|
|
160
|
-
dataset_id = "dataset-123"
|
|
161
|
-
model_id = "model-456"
|
|
162
|
-
|
|
163
|
-
mock_response = True
|
|
164
|
-
self.model_service.request_gql.return_value = mock_response
|
|
165
|
-
|
|
166
|
-
# Act
|
|
167
|
-
result = self.model_service.delete_model(
|
|
168
|
-
dataset_id=dataset_id,
|
|
169
|
-
model_id=model_id
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
# Assert
|
|
173
|
-
assert result is True
|
|
174
|
-
self.model_service.request_gql.assert_called_once_with(
|
|
175
|
-
Queries.DELETE_MODEL,
|
|
176
|
-
Queries.DELETE_MODEL["variables"](
|
|
177
|
-
dataset_id=dataset_id,
|
|
178
|
-
model_id=model_id
|
|
179
|
-
)
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
def test_delete_model_failure(self):
|
|
183
|
-
"""Test model deletion failure."""
|
|
184
|
-
# Arrange
|
|
185
|
-
dataset_id = "dataset-123"
|
|
186
|
-
model_id = "nonexistent-model"
|
|
187
|
-
|
|
188
|
-
mock_response = False
|
|
189
|
-
self.model_service.request_gql.return_value = mock_response
|
|
190
|
-
|
|
191
|
-
# Act
|
|
192
|
-
result = self.model_service.delete_model(
|
|
193
|
-
dataset_id=dataset_id,
|
|
194
|
-
model_id=model_id
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
# Assert
|
|
198
|
-
assert result is False
|
|
199
|
-
|
|
200
|
-
def test_delete_model_missing_response(self):
|
|
201
|
-
"""Test model deletion with missing response field."""
|
|
202
|
-
# Arrange
|
|
203
|
-
dataset_id = "dataset-123"
|
|
204
|
-
model_id = "model-456"
|
|
205
|
-
|
|
206
|
-
mock_response = False
|
|
207
|
-
self.model_service.request_gql.return_value = mock_response
|
|
208
|
-
|
|
209
|
-
# Act
|
|
210
|
-
result = self.model_service.delete_model(
|
|
211
|
-
dataset_id=dataset_id,
|
|
212
|
-
model_id=model_id
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
# Assert
|
|
216
|
-
assert result is False
|
|
217
|
-
|
|
218
|
-
def test_delete_model_missing_dataset_id(self):
|
|
219
|
-
"""Test delete model with missing dataset_id."""
|
|
220
|
-
# Arrange
|
|
221
|
-
model_id = "model-456"
|
|
222
|
-
|
|
223
|
-
# Act & Assert
|
|
224
|
-
with pytest.raises(BadParameterError, match="dataset_id is required"):
|
|
225
|
-
self.model_service.delete_model(
|
|
226
|
-
dataset_id=None,
|
|
227
|
-
model_id=model_id
|
|
228
|
-
)
|
|
229
|
-
|
|
230
|
-
def test_delete_model_missing_model_id(self):
|
|
231
|
-
"""Test delete model with missing model_id."""
|
|
232
|
-
# Arrange
|
|
233
|
-
dataset_id = "dataset-123"
|
|
234
|
-
|
|
235
|
-
# Act & Assert
|
|
236
|
-
with pytest.raises(BadParameterError, match="model_id is required"):
|
|
237
|
-
self.model_service.delete_model(
|
|
238
|
-
dataset_id=dataset_id,
|
|
239
|
-
model_id=None
|
|
240
|
-
)
|
|
241
|
-
|
|
242
|
-
def test_delete_model_both_missing_params(self):
|
|
243
|
-
"""Test delete model with both missing parameters."""
|
|
244
|
-
# Act & Assert
|
|
245
|
-
with pytest.raises(BadParameterError, match="dataset_id is required"):
|
|
246
|
-
self.model_service.delete_model(
|
|
247
|
-
dataset_id=None,
|
|
248
|
-
model_id=None
|
|
249
|
-
)
|
tests/predictions/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Predictions test package
|
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from unittest.mock import Mock
|
|
3
|
-
|
|
4
|
-
from spb_onprem.predictions.service import PredictionService
|
|
5
|
-
from spb_onprem.predictions.queries import Queries
|
|
6
|
-
from spb_onprem.predictions.entities import PredictionSet
|
|
7
|
-
from spb_onprem.exceptions import BadParameterError
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class TestPredictionService:
|
|
11
|
-
"""Test cases for PredictionService methods."""
|
|
12
|
-
|
|
13
|
-
def setup_method(self):
|
|
14
|
-
"""Set up test fixtures before each test method."""
|
|
15
|
-
self.prediction_service = PredictionService()
|
|
16
|
-
self.prediction_service.request_gql = Mock()
|
|
17
|
-
|
|
18
|
-
def test_get_prediction_sets_success(self):
|
|
19
|
-
"""Test successful prediction sets list retrieval."""
|
|
20
|
-
# Arrange
|
|
21
|
-
dataset_id = "dataset-123"
|
|
22
|
-
filter_dict = {"name": "test"}
|
|
23
|
-
cursor = "cursor-abc"
|
|
24
|
-
length = 25
|
|
25
|
-
|
|
26
|
-
mock_response = {
|
|
27
|
-
"predictionSets": [
|
|
28
|
-
{"id": "pred-1", "name": "Prediction Set 1"},
|
|
29
|
-
{"id": "pred-2", "name": "Prediction Set 2"}
|
|
30
|
-
],
|
|
31
|
-
"next": "cursor-def",
|
|
32
|
-
"totalCount": 100
|
|
33
|
-
}
|
|
34
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
35
|
-
|
|
36
|
-
# Act
|
|
37
|
-
result = self.prediction_service.get_prediction_sets(
|
|
38
|
-
dataset_id=dataset_id,
|
|
39
|
-
filter=filter_dict,
|
|
40
|
-
cursor=cursor,
|
|
41
|
-
length=length
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
# Assert
|
|
45
|
-
prediction_sets, next_cursor, total_count = result
|
|
46
|
-
assert len(prediction_sets) == 2
|
|
47
|
-
assert prediction_sets[0].id == "pred-1"
|
|
48
|
-
assert prediction_sets[0].name == "Prediction Set 1"
|
|
49
|
-
assert prediction_sets[1].id == "pred-2"
|
|
50
|
-
assert prediction_sets[1].name == "Prediction Set 2"
|
|
51
|
-
assert next_cursor == "cursor-def"
|
|
52
|
-
assert total_count == 100
|
|
53
|
-
self.prediction_service.request_gql.assert_called_once_with(
|
|
54
|
-
Queries.GET_PREDICTION_SETS,
|
|
55
|
-
Queries.GET_PREDICTION_SETS["variables"](
|
|
56
|
-
dataset_id=dataset_id,
|
|
57
|
-
filter=filter_dict,
|
|
58
|
-
cursor=cursor,
|
|
59
|
-
length=length
|
|
60
|
-
)
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
def test_get_prediction_sets_without_filter(self):
|
|
64
|
-
"""Test prediction sets retrieval without filter."""
|
|
65
|
-
# Arrange
|
|
66
|
-
dataset_id = "dataset-123"
|
|
67
|
-
|
|
68
|
-
mock_response = {
|
|
69
|
-
"predictionSets": [{"id": "pred-1", "name": "Test"}],
|
|
70
|
-
"next": None,
|
|
71
|
-
"totalCount": 1
|
|
72
|
-
}
|
|
73
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
74
|
-
|
|
75
|
-
# Act
|
|
76
|
-
result = self.prediction_service.get_prediction_sets(dataset_id=dataset_id)
|
|
77
|
-
|
|
78
|
-
# Assert
|
|
79
|
-
prediction_sets, next_cursor, total_count = result
|
|
80
|
-
assert total_count == 1
|
|
81
|
-
assert next_cursor is None
|
|
82
|
-
assert len(prediction_sets) == 1
|
|
83
|
-
|
|
84
|
-
def test_get_prediction_sets_missing_dataset_id(self):
|
|
85
|
-
"""Test prediction sets with missing dataset_id."""
|
|
86
|
-
# Act & Assert
|
|
87
|
-
with pytest.raises(BadParameterError, match="dataset_id is required"):
|
|
88
|
-
self.prediction_service.get_prediction_sets(dataset_id=None)
|
|
89
|
-
|
|
90
|
-
def test_get_prediction_sets_empty_response(self):
|
|
91
|
-
"""Test prediction sets with empty response."""
|
|
92
|
-
# Arrange
|
|
93
|
-
dataset_id = "dataset-123"
|
|
94
|
-
mock_response = {}
|
|
95
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
96
|
-
|
|
97
|
-
# Act
|
|
98
|
-
result = self.prediction_service.get_prediction_sets(dataset_id=dataset_id)
|
|
99
|
-
|
|
100
|
-
# Assert
|
|
101
|
-
prediction_sets, next_cursor, total_count = result
|
|
102
|
-
assert len(prediction_sets) == 0
|
|
103
|
-
assert next_cursor is None
|
|
104
|
-
assert total_count == 0
|
|
105
|
-
|
|
106
|
-
def test_get_prediction_set_success(self):
|
|
107
|
-
"""Test successful single prediction set retrieval."""
|
|
108
|
-
# Arrange
|
|
109
|
-
dataset_id = "dataset-123"
|
|
110
|
-
prediction_set_id = "pred-set-456"
|
|
111
|
-
|
|
112
|
-
mock_response = {
|
|
113
|
-
"predictionSet": {
|
|
114
|
-
"id": prediction_set_id,
|
|
115
|
-
"name": "Test Prediction Set",
|
|
116
|
-
"annotationsContents": ["content-1", "content-2"],
|
|
117
|
-
"evaluationResultContent": {"id": "eval-result-1"}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
121
|
-
|
|
122
|
-
# Act
|
|
123
|
-
result = self.prediction_service.get_prediction_set(
|
|
124
|
-
dataset_id=dataset_id,
|
|
125
|
-
prediction_set_id=prediction_set_id
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
# Assert
|
|
129
|
-
assert isinstance(result, PredictionSet)
|
|
130
|
-
assert result.id == prediction_set_id
|
|
131
|
-
assert result.name == "Test Prediction Set"
|
|
132
|
-
assert result.annotations_contents == ["content-1", "content-2"]
|
|
133
|
-
assert result.evaluation_result_content == {"id": "eval-result-1"}
|
|
134
|
-
self.prediction_service.request_gql.assert_called_once_with(
|
|
135
|
-
Queries.GET_PREDICTION_SET,
|
|
136
|
-
Queries.GET_PREDICTION_SET["variables"](
|
|
137
|
-
dataset_id=dataset_id,
|
|
138
|
-
prediction_set_id=prediction_set_id
|
|
139
|
-
)
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
def test_get_prediction_set_missing_dataset_id(self):
|
|
143
|
-
"""Test get prediction set with missing dataset_id."""
|
|
144
|
-
# Arrange
|
|
145
|
-
prediction_set_id = "pred-set-456"
|
|
146
|
-
|
|
147
|
-
# Act & Assert
|
|
148
|
-
with pytest.raises(BadParameterError, match="dataset_id is required"):
|
|
149
|
-
self.prediction_service.get_prediction_set(
|
|
150
|
-
dataset_id=None,
|
|
151
|
-
prediction_set_id=prediction_set_id
|
|
152
|
-
)
|
|
153
|
-
|
|
154
|
-
def test_get_prediction_set_missing_prediction_set_id(self):
|
|
155
|
-
"""Test get prediction set with missing prediction_set_id."""
|
|
156
|
-
# Arrange
|
|
157
|
-
dataset_id = "dataset-123"
|
|
158
|
-
|
|
159
|
-
# Act & Assert
|
|
160
|
-
with pytest.raises(BadParameterError, match="prediction_set_id is required"):
|
|
161
|
-
self.prediction_service.get_prediction_set(
|
|
162
|
-
dataset_id=dataset_id,
|
|
163
|
-
prediction_set_id=None
|
|
164
|
-
)
|
|
165
|
-
|
|
166
|
-
def test_get_prediction_set_minimal_response(self):
|
|
167
|
-
"""Test get prediction set with minimal response."""
|
|
168
|
-
# Arrange
|
|
169
|
-
dataset_id = "dataset-123"
|
|
170
|
-
prediction_set_id = "pred-set-456"
|
|
171
|
-
|
|
172
|
-
mock_response = {"predictionSet": {"id": prediction_set_id}}
|
|
173
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
174
|
-
|
|
175
|
-
# Act
|
|
176
|
-
result = self.prediction_service.get_prediction_set(
|
|
177
|
-
dataset_id=dataset_id,
|
|
178
|
-
prediction_set_id=prediction_set_id
|
|
179
|
-
)
|
|
180
|
-
|
|
181
|
-
# Assert
|
|
182
|
-
assert isinstance(result, PredictionSet)
|
|
183
|
-
assert result.id == prediction_set_id
|
|
184
|
-
assert result.name is None # Optional fields should be None
|
|
185
|
-
|
|
186
|
-
def test_delete_prediction_set_success(self):
|
|
187
|
-
"""Test successful prediction set deletion."""
|
|
188
|
-
# Arrange
|
|
189
|
-
dataset_id = "dataset-123"
|
|
190
|
-
prediction_set_id = "pred-set-456"
|
|
191
|
-
|
|
192
|
-
mock_response = True
|
|
193
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
194
|
-
|
|
195
|
-
# Act
|
|
196
|
-
result = self.prediction_service.delete_prediction_set(
|
|
197
|
-
dataset_id=dataset_id,
|
|
198
|
-
prediction_set_id=prediction_set_id
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
# Assert
|
|
202
|
-
assert result is True
|
|
203
|
-
self.prediction_service.request_gql.assert_called_once_with(
|
|
204
|
-
Queries.DELETE_PREDICTION_SET,
|
|
205
|
-
Queries.DELETE_PREDICTION_SET["variables"](
|
|
206
|
-
dataset_id=dataset_id,
|
|
207
|
-
prediction_set_id=prediction_set_id
|
|
208
|
-
)
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
def test_delete_prediction_set_failure(self):
|
|
212
|
-
"""Test prediction set deletion failure."""
|
|
213
|
-
# Arrange
|
|
214
|
-
dataset_id = "dataset-123"
|
|
215
|
-
prediction_set_id = "nonexistent-pred-set"
|
|
216
|
-
|
|
217
|
-
mock_response = False
|
|
218
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
219
|
-
|
|
220
|
-
# Act
|
|
221
|
-
result = self.prediction_service.delete_prediction_set(
|
|
222
|
-
dataset_id=dataset_id,
|
|
223
|
-
prediction_set_id=prediction_set_id
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
# Assert
|
|
227
|
-
assert result is False
|
|
228
|
-
|
|
229
|
-
def test_delete_prediction_set_missing_response(self):
|
|
230
|
-
"""Test prediction set deletion with missing response field."""
|
|
231
|
-
# Arrange
|
|
232
|
-
dataset_id = "dataset-123"
|
|
233
|
-
prediction_set_id = "pred-set-456"
|
|
234
|
-
|
|
235
|
-
mock_response = False
|
|
236
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
237
|
-
|
|
238
|
-
# Act
|
|
239
|
-
result = self.prediction_service.delete_prediction_set(
|
|
240
|
-
dataset_id=dataset_id,
|
|
241
|
-
prediction_set_id=prediction_set_id
|
|
242
|
-
)
|
|
243
|
-
|
|
244
|
-
# Assert
|
|
245
|
-
assert result is False
|
|
246
|
-
|
|
247
|
-
def test_delete_prediction_set_missing_dataset_id(self):
|
|
248
|
-
"""Test delete prediction set with missing dataset_id."""
|
|
249
|
-
# Arrange
|
|
250
|
-
prediction_set_id = "pred-set-456"
|
|
251
|
-
|
|
252
|
-
# Act & Assert
|
|
253
|
-
with pytest.raises(BadParameterError, match="dataset_id is required"):
|
|
254
|
-
self.prediction_service.delete_prediction_set(
|
|
255
|
-
dataset_id=None,
|
|
256
|
-
prediction_set_id=prediction_set_id
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
def test_delete_prediction_set_missing_prediction_set_id(self):
|
|
260
|
-
"""Test delete prediction set with missing prediction_set_id."""
|
|
261
|
-
# Arrange
|
|
262
|
-
dataset_id = "dataset-123"
|
|
263
|
-
|
|
264
|
-
# Act & Assert
|
|
265
|
-
with pytest.raises(BadParameterError, match="prediction_set_id is required"):
|
|
266
|
-
self.prediction_service.delete_prediction_set(
|
|
267
|
-
dataset_id=dataset_id,
|
|
268
|
-
prediction_set_id=None
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
def test_delete_prediction_from_data_success(self):
|
|
272
|
-
"""Test successful prediction deletion from data."""
|
|
273
|
-
# Arrange
|
|
274
|
-
dataset_id = "dataset-123"
|
|
275
|
-
data_id = "data-456"
|
|
276
|
-
prediction_set_id = "pred-set-789"
|
|
277
|
-
|
|
278
|
-
mock_response = {"deletePrediction": {"id": data_id, "dataset_id": dataset_id}}
|
|
279
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
280
|
-
|
|
281
|
-
# Act
|
|
282
|
-
result = self.prediction_service.delete_prediction_from_data(
|
|
283
|
-
dataset_id=dataset_id,
|
|
284
|
-
data_id=data_id,
|
|
285
|
-
prediction_set_id=prediction_set_id
|
|
286
|
-
)
|
|
287
|
-
|
|
288
|
-
# Assert
|
|
289
|
-
assert result is True
|
|
290
|
-
self.prediction_service.request_gql.assert_called_once_with(
|
|
291
|
-
Queries.DELETE_PREDICTION_FROM_DATA,
|
|
292
|
-
Queries.DELETE_PREDICTION_FROM_DATA["variables"](
|
|
293
|
-
dataset_id=dataset_id,
|
|
294
|
-
data_id=data_id,
|
|
295
|
-
prediction_set_id=prediction_set_id
|
|
296
|
-
)
|
|
297
|
-
)
|
|
298
|
-
|
|
299
|
-
def test_delete_prediction_from_data_failure(self):
|
|
300
|
-
"""Test prediction deletion from data failure."""
|
|
301
|
-
# Arrange
|
|
302
|
-
dataset_id = "dataset-123"
|
|
303
|
-
data_id = "data-456"
|
|
304
|
-
prediction_set_id = "pred-set-789"
|
|
305
|
-
|
|
306
|
-
mock_response = {"deletePrediction": None}
|
|
307
|
-
self.prediction_service.request_gql.return_value = mock_response
|
|
308
|
-
|
|
309
|
-
# Act
|
|
310
|
-
result = self.prediction_service.delete_prediction_from_data(
|
|
311
|
-
dataset_id=dataset_id,
|
|
312
|
-
data_id=data_id,
|
|
313
|
-
prediction_set_id=prediction_set_id
|
|
314
|
-
)
|
|
315
|
-
|
|
316
|
-
# Assert
|
|
317
|
-
assert result is False
|
|
318
|
-
|
|
319
|
-
def test_delete_prediction_from_data_missing_dataset_id(self):
|
|
320
|
-
"""Test delete prediction from data with missing dataset_id."""
|
|
321
|
-
# Arrange
|
|
322
|
-
data_id = "data-456"
|
|
323
|
-
prediction_set_id = "pred-set-789"
|
|
324
|
-
|
|
325
|
-
# Act & Assert
|
|
326
|
-
with pytest.raises(BadParameterError, match="dataset_id is required"):
|
|
327
|
-
self.prediction_service.delete_prediction_from_data(
|
|
328
|
-
dataset_id=None,
|
|
329
|
-
data_id=data_id,
|
|
330
|
-
prediction_set_id=prediction_set_id
|
|
331
|
-
)
|
|
332
|
-
|
|
333
|
-
def test_delete_prediction_from_data_missing_data_id(self):
|
|
334
|
-
"""Test delete prediction from data with missing data_id."""
|
|
335
|
-
# Arrange
|
|
336
|
-
dataset_id = "dataset-123"
|
|
337
|
-
prediction_set_id = "pred-set-789"
|
|
338
|
-
|
|
339
|
-
# Act & Assert
|
|
340
|
-
with pytest.raises(BadParameterError, match="data_id is required"):
|
|
341
|
-
self.prediction_service.delete_prediction_from_data(
|
|
342
|
-
dataset_id=dataset_id,
|
|
343
|
-
data_id=None,
|
|
344
|
-
prediction_set_id=prediction_set_id
|
|
345
|
-
)
|
|
346
|
-
|
|
347
|
-
def test_delete_prediction_from_data_missing_prediction_set_id(self):
|
|
348
|
-
"""Test delete prediction from data with missing prediction_set_id."""
|
|
349
|
-
# Arrange
|
|
350
|
-
dataset_id = "dataset-123"
|
|
351
|
-
data_id = "data-456"
|
|
352
|
-
|
|
353
|
-
# Act & Assert
|
|
354
|
-
with pytest.raises(BadParameterError, match="prediction_set_id is required"):
|
|
355
|
-
self.prediction_service.delete_prediction_from_data(
|
|
356
|
-
dataset_id=dataset_id,
|
|
357
|
-
data_id=data_id,
|
|
358
|
-
prediction_set_id=None
|
|
359
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|