superb-ai-onprem 0.9.0__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 -9
- 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 -6
- 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.0.dist-info → superb_ai_onprem-0.10.0.dist-info}/METADATA +53 -9
- {superb_ai_onprem-0.9.0.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.0.dist-info → superb_ai_onprem-0.10.0.dist-info}/WHEEL +0 -0
- {superb_ai_onprem-0.9.0.dist-info → superb_ai_onprem-0.10.0.dist-info}/licenses/LICENSE +0 -0
- {superb_ai_onprem-0.9.0.dist-info → superb_ai_onprem-0.10.0.dist-info}/top_level.txt +0 -0
|
@@ -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
|