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.

Files changed (65) hide show
  1. spb_onprem/__init__.py +39 -4
  2. spb_onprem/_version.py +2 -2
  3. spb_onprem/data/entities/__init__.py +2 -0
  4. spb_onprem/data/entities/data.py +2 -0
  5. spb_onprem/data/entities/data_annotation_stats.py +8 -0
  6. spb_onprem/data/params/data_list.py +7 -2
  7. spb_onprem/data/params/update_data.py +11 -0
  8. spb_onprem/data/params/update_data_slice.py +14 -2
  9. spb_onprem/data/queries.py +12 -1
  10. spb_onprem/data/service.py +9 -0
  11. spb_onprem/entities.py +24 -2
  12. spb_onprem/models/__init__.py +8 -3
  13. spb_onprem/models/entities/__init__.py +9 -0
  14. spb_onprem/models/entities/model.py +32 -0
  15. spb_onprem/models/entities/model_page_info.py +14 -0
  16. spb_onprem/models/entities/model_train_class.py +15 -0
  17. spb_onprem/models/params/__init__.py +16 -4
  18. spb_onprem/models/params/create_model.py +70 -0
  19. spb_onprem/models/params/delete_model.py +11 -8
  20. spb_onprem/models/params/model.py +17 -0
  21. spb_onprem/models/params/models.py +60 -0
  22. spb_onprem/models/params/pin_model.py +17 -0
  23. spb_onprem/models/params/unpin_model.py +17 -0
  24. spb_onprem/models/params/update_model.py +61 -0
  25. spb_onprem/models/queries.py +224 -19
  26. spb_onprem/models/service.py +251 -30
  27. spb_onprem/reports/__init__.py +25 -0
  28. spb_onprem/reports/entities/__init__.py +10 -0
  29. spb_onprem/reports/entities/analytics_report.py +22 -0
  30. spb_onprem/reports/entities/analytics_report_item.py +30 -0
  31. spb_onprem/reports/entities/analytics_report_page_info.py +14 -0
  32. spb_onprem/reports/params/__init__.py +29 -0
  33. spb_onprem/reports/params/analytics_report.py +17 -0
  34. spb_onprem/reports/params/analytics_reports.py +87 -0
  35. spb_onprem/reports/params/create_analytics_report.py +35 -0
  36. spb_onprem/reports/params/create_analytics_report_item.py +47 -0
  37. spb_onprem/reports/params/delete_analytics_report.py +17 -0
  38. spb_onprem/reports/params/delete_analytics_report_item.py +20 -0
  39. spb_onprem/reports/params/update_analytics_report.py +38 -0
  40. spb_onprem/reports/params/update_analytics_report_item.py +46 -0
  41. spb_onprem/reports/queries.py +239 -0
  42. spb_onprem/reports/service.py +328 -0
  43. spb_onprem/searches.py +18 -0
  44. {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/METADATA +53 -9
  45. {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/RECORD +48 -38
  46. spb_onprem/models/entities.py +0 -9
  47. spb_onprem/models/params/get_models.py +0 -29
  48. spb_onprem/predictions/__init__.py +0 -7
  49. spb_onprem/predictions/entities.py +0 -11
  50. spb_onprem/predictions/params/__init__.py +0 -15
  51. spb_onprem/predictions/params/create_prediction_set.py +0 -44
  52. spb_onprem/predictions/params/delete_prediction_from_data.py +0 -20
  53. spb_onprem/predictions/params/delete_prediction_set.py +0 -14
  54. spb_onprem/predictions/params/get_prediction_set.py +0 -14
  55. spb_onprem/predictions/params/get_prediction_sets.py +0 -29
  56. spb_onprem/predictions/params/update_prediction_set_data_info.py +0 -28
  57. spb_onprem/predictions/queries.py +0 -110
  58. spb_onprem/predictions/service.py +0 -225
  59. tests/models/__init__.py +0 -1
  60. tests/models/test_model_service.py +0 -249
  61. tests/predictions/__init__.py +0 -1
  62. tests/predictions/test_prediction_service.py +0 -359
  63. {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/WHEEL +0 -0
  64. {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/licenses/LICENSE +0 -0
  65. {superb_ai_onprem-0.9.1.dist-info → superb_ai_onprem-0.10.0.dist-info}/top_level.txt +0 -0
@@ -1,7 +0,0 @@
1
- from .service import PredictionService
2
- from .entities import PredictionSet
3
-
4
- __all__ = [
5
- "PredictionService",
6
- "PredictionSet",
7
- ]
@@ -1,11 +0,0 @@
1
- from typing import List, Optional
2
- from spb_onprem.base_model import CustomBaseModel, Field
3
-
4
-
5
- class PredictionSet(CustomBaseModel):
6
- """PredictionSet entity representing a set of predictions in the dataset."""
7
-
8
- id: str
9
- name: Optional[str] = None
10
- annotations_contents: Optional[List[str]] = Field(None, alias="annotationsContents")
11
- evaluation_result_content: Optional[dict] = Field(None, alias="evaluationResultContent")
@@ -1,15 +0,0 @@
1
- from .get_prediction_sets import get_prediction_sets_params
2
- from .get_prediction_set import get_prediction_set_params
3
- from .delete_prediction_set import delete_prediction_set_params
4
- from .delete_prediction_from_data import delete_prediction_from_data_params
5
- from .create_prediction_set import create_prediction_set_params
6
- from .update_prediction_set_data_info import update_prediction_set_data_info_params
7
-
8
- __all__ = [
9
- "get_prediction_sets_params",
10
- "get_prediction_set_params",
11
- "delete_prediction_set_params",
12
- "delete_prediction_from_data_params",
13
- "create_prediction_set_params",
14
- "update_prediction_set_data_info_params",
15
- ]
@@ -1,44 +0,0 @@
1
- from typing import Optional, Dict, Any
2
-
3
-
4
- def create_prediction_set_params(
5
- dataset_id: str,
6
- model_id: str,
7
- name: str,
8
- type: str,
9
- description: Optional[str] = None,
10
- annotations_count: Optional[int] = None,
11
- data_count: Optional[int] = None,
12
- ) -> Dict[str, Any]:
13
- """Convert parameters for create_prediction_set GraphQL mutation.
14
-
15
- Args:
16
- dataset_id (str): The dataset ID
17
- model_id (str): The model ID
18
- name (str): Name of the prediction set
19
- type (str): Type of the prediction set
20
- description (Optional[str]): Description of the prediction set
21
- annotations_count (Optional[int]): Number of annotations
22
- data_count (Optional[int]): Number of data items
23
-
24
- Returns:
25
- Dict[str, Any]: Parameters formatted for GraphQL mutation
26
- """
27
- params = {
28
- "datasetId": dataset_id,
29
- "modelId": model_id,
30
- "name": name,
31
- "type": type,
32
- }
33
-
34
- if description is not None:
35
- params["description"] = description
36
-
37
- if annotations_count is not None or data_count is not None:
38
- params["dataInfo"] = {}
39
- if annotations_count is not None:
40
- params["dataInfo"]["annotationsCount"] = annotations_count
41
- if data_count is not None:
42
- params["dataInfo"]["dataCount"] = data_count
43
-
44
- return params
@@ -1,20 +0,0 @@
1
- def delete_prediction_from_data_params(
2
- dataset_id: str,
3
- data_id: str,
4
- prediction_set_id: str
5
- ):
6
- """Generate variables for delete prediction from data GraphQL mutation.
7
-
8
- Args:
9
- dataset_id (str): The ID of the dataset.
10
- data_id (str): The ID of the data.
11
- prediction_set_id (str): The ID of the prediction set.
12
-
13
- Returns:
14
- dict: Variables dictionary for the GraphQL mutation.
15
- """
16
- return {
17
- "dataset_id": dataset_id,
18
- "data_id": data_id,
19
- "set_id": prediction_set_id
20
- }
@@ -1,14 +0,0 @@
1
- def delete_prediction_set_params(dataset_id: str, prediction_set_id: str):
2
- """Generate variables for delete prediction set GraphQL mutation.
3
-
4
- Args:
5
- dataset_id (str): The ID of the dataset.
6
- prediction_set_id (str): The ID of the prediction set to delete.
7
-
8
- Returns:
9
- dict: Variables dictionary for the GraphQL mutation.
10
- """
11
- return {
12
- "dataset_id": dataset_id,
13
- "id": prediction_set_id
14
- }
@@ -1,14 +0,0 @@
1
- def get_prediction_set_params(dataset_id: str, prediction_set_id: str):
2
- """Generate variables for get prediction set GraphQL query.
3
-
4
- Args:
5
- dataset_id (str): The ID of the dataset.
6
- prediction_set_id (str): The ID of the prediction set.
7
-
8
- Returns:
9
- dict: Variables dictionary for the GraphQL query.
10
- """
11
- return {
12
- "dataset_id": dataset_id,
13
- "id": prediction_set_id
14
- }
@@ -1,29 +0,0 @@
1
- def get_prediction_sets_params(
2
- dataset_id: str,
3
- filter: dict = None,
4
- cursor: str = None,
5
- length: int = 50
6
- ):
7
- """Generate variables for get prediction sets GraphQL query.
8
-
9
- Args:
10
- dataset_id (str): The ID of the dataset.
11
- filter (dict, optional): Filter for prediction sets.
12
- cursor (str, optional): Cursor for pagination.
13
- length (int): Number of items to retrieve per page.
14
-
15
- Returns:
16
- dict: Variables dictionary for the GraphQL query.
17
- """
18
- params = {
19
- "dataset_id": dataset_id,
20
- "length": length
21
- }
22
-
23
- if filter is not None:
24
- params["filter"] = filter
25
-
26
- if cursor is not None:
27
- params["cursor"] = cursor
28
-
29
- return params
@@ -1,28 +0,0 @@
1
- from typing import Dict, Any
2
-
3
-
4
- def update_prediction_set_data_info_params(
5
- dataset_id: str,
6
- id: str,
7
- annotation_count: int,
8
- data_count: int
9
- ) -> Dict[str, Any]:
10
- """Convert parameters for update_prediction_set_data_info GraphQL mutation.
11
-
12
- Args:
13
- dataset_id (str): The dataset ID
14
- id (str): The prediction set ID to update
15
- annotation_count (int): Number of annotations
16
- data_count (int): Number of data items
17
-
18
- Returns:
19
- Dict[str, Any]: Parameters formatted for GraphQL mutation
20
- """
21
- return {
22
- "datasetId": dataset_id,
23
- "updatePredictionSetId": id,
24
- "dataInfo": {
25
- "annotationsCount": annotation_count,
26
- "dataCount": data_count,
27
- }
28
- }
@@ -1,110 +0,0 @@
1
- from .params import (
2
- get_prediction_sets_params,
3
- get_prediction_set_params,
4
- delete_prediction_set_params,
5
- delete_prediction_from_data_params,
6
- create_prediction_set_params,
7
- update_prediction_set_data_info_params,
8
- )
9
-
10
-
11
- class Queries:
12
- GET_PREDICTION_SETS = {
13
- "name": "getPredictionSets",
14
- "query": '''
15
- query GetPredictionSets($dataset_id: String!, $filter: PredictionSetFilter, $cursor: String, $length: Int) {
16
- predictionSets(datasetId: $dataset_id, filter: $filter, cursor: $cursor, length: $length) {
17
- predictionSets {
18
- id
19
- name
20
- }
21
- next
22
- totalCount
23
- }
24
- }
25
- ''',
26
- "variables": get_prediction_sets_params
27
- }
28
-
29
- GET_PREDICTION_SET = {
30
- "name": "getPredictionSet",
31
- "query": '''
32
- query GetPredictionSet($dataset_id: String!, $id: String!) {
33
- predictionSet(datasetId: $dataset_id, id: $id) {
34
- id
35
- name
36
- annotationsContents
37
- evaluationResultContent {
38
- id
39
- }
40
- }
41
- }
42
- ''',
43
- "variables": get_prediction_set_params
44
- }
45
-
46
- DELETE_PREDICTION_SET = {
47
- "name": "deletePredictionSet",
48
- "query": '''
49
- mutation DeletePredictionSet($dataset_id: String!, $id: String!) {
50
- deletePredictionSet(datasetId: $dataset_id, id: $id)
51
- }
52
- ''',
53
- "variables": delete_prediction_set_params
54
- }
55
-
56
- DELETE_PREDICTION_FROM_DATA = {
57
- "name": "deletePredictionFromData",
58
- "query": '''
59
- mutation DeletePrediction($dataset_id: String!, $data_id: String!, $set_id: String!) {
60
- deletePrediction(datasetId: $dataset_id, dataId: $data_id, setId: $set_id)
61
- }
62
- ''',
63
- "variables": delete_prediction_from_data_params
64
- }
65
-
66
- CREATE_PREDICTION_SET = {
67
- "name": "createPredictionSet",
68
- "query": '''
69
- mutation CreatePredictionSet(
70
- $datasetId: ID!,
71
- $modelId: ID!,
72
- $name: String!,
73
- $description: String,
74
- $type: PredictionSetTypes!,
75
- $dataInfo: PredictionSetDataInfoInput
76
- ) {
77
- createPredictionSet(
78
- datasetId: $datasetId,
79
- modelId: $modelId,
80
- name: $name,
81
- description: $description,
82
- type: $type,
83
- dataInfo: $dataInfo
84
- ) {
85
- id
86
- }
87
- }
88
- ''',
89
- "variables": create_prediction_set_params
90
- }
91
-
92
- UPDATE_PREDICTION_SET_DATA_INFO = {
93
- "name": "updatePredictionSet",
94
- "query": '''
95
- mutation UpdatePredictionSet(
96
- $datasetId: ID!,
97
- $updatePredictionSetId: ID!,
98
- $dataInfo: PredictionSetDataInfoInput
99
- ) {
100
- updatePredictionSet(
101
- datasetId: $datasetId,
102
- id: $updatePredictionSetId,
103
- dataInfo: $dataInfo
104
- ) {
105
- id
106
- }
107
- }
108
- ''',
109
- "variables": update_prediction_set_data_info_params
110
- }
@@ -1,225 +0,0 @@
1
- from typing import Optional, Dict, Any, List, Tuple, Union
2
-
3
- from spb_onprem.base_service import BaseService
4
- from spb_onprem.base_types import Undefined, UndefinedType
5
- from spb_onprem.exceptions import BadParameterError
6
- from .queries import Queries
7
- from .entities import PredictionSet
8
-
9
-
10
- class PredictionService(BaseService):
11
- """Service class for handling prediction set operations."""
12
-
13
- def get_prediction_sets(
14
- self,
15
- dataset_id: str,
16
- filter: Union[UndefinedType, Dict[str, Any]] = Undefined,
17
- cursor: Union[UndefinedType, str] = Undefined,
18
- length: int = 50
19
- ) -> Tuple[List[PredictionSet], Optional[str], int]:
20
- """Get paginated list of prediction sets for a dataset.
21
-
22
- Args:
23
- dataset_id (str): The dataset ID.
24
- filter (Union[UndefinedType, Dict[str, Any]]): Filter for prediction sets.
25
- cursor (Union[UndefinedType, str]): Cursor for pagination.
26
- length (int): Number of items to retrieve per page.
27
-
28
- Returns:
29
- Tuple[List[PredictionSet], Optional[str], int]: A tuple containing prediction sets, next cursor, and total count.
30
- """
31
- if dataset_id is None:
32
- raise BadParameterError("dataset_id is required.")
33
-
34
- response = self.request_gql(
35
- Queries.GET_PREDICTION_SETS,
36
- Queries.GET_PREDICTION_SETS["variables"](
37
- dataset_id=dataset_id,
38
- filter=filter,
39
- cursor=cursor,
40
- length=length
41
- )
42
- )
43
- prediction_sets_list = response.get("predictionSets", [])
44
- return (
45
- [PredictionSet.model_validate(ps) for ps in prediction_sets_list],
46
- response.get("next"),
47
- response.get("totalCount", 0)
48
- )
49
-
50
- def get_prediction_set(
51
- self,
52
- dataset_id: str,
53
- prediction_set_id: str
54
- ) -> PredictionSet:
55
- """Get detailed prediction set information including content IDs.
56
-
57
- Args:
58
- dataset_id (str): The dataset ID.
59
- prediction_set_id (str): The prediction set ID.
60
-
61
- Returns:
62
- PredictionSet: The prediction set entity.
63
- """
64
- if dataset_id is None:
65
- raise BadParameterError("dataset_id is required.")
66
- if prediction_set_id is None:
67
- raise BadParameterError("prediction_set_id is required.")
68
-
69
- response = self.request_gql(
70
- Queries.GET_PREDICTION_SET,
71
- Queries.GET_PREDICTION_SET["variables"](
72
- dataset_id=dataset_id,
73
- prediction_set_id=prediction_set_id
74
- )
75
- )
76
- prediction_set_dict = response.get("predictionSet", {})
77
- return PredictionSet.model_validate(prediction_set_dict)
78
-
79
- def delete_prediction_set(
80
- self,
81
- dataset_id: str,
82
- prediction_set_id: str
83
- ) -> bool:
84
- """Delete a prediction set from the dataset.
85
-
86
- Args:
87
- dataset_id (str): The dataset ID.
88
- prediction_set_id (str): The prediction set ID to delete.
89
-
90
- Returns:
91
- bool: True if deletion was successful.
92
- """
93
- if dataset_id is None:
94
- raise BadParameterError("dataset_id is required.")
95
- if prediction_set_id is None:
96
- raise BadParameterError("prediction_set_id is required.")
97
-
98
- response = self.request_gql(
99
- Queries.DELETE_PREDICTION_SET,
100
- Queries.DELETE_PREDICTION_SET["variables"](
101
- dataset_id=dataset_id,
102
- prediction_set_id=prediction_set_id
103
- )
104
- )
105
- return response
106
-
107
- def delete_prediction_from_data(
108
- self,
109
- dataset_id: str,
110
- data_id: str,
111
- prediction_set_id: str
112
- ) -> bool:
113
- """Delete predictions from a specific data item for a given prediction set.
114
-
115
- Args:
116
- dataset_id (str): The dataset ID.
117
- data_id (str): The data ID.
118
- prediction_set_id (str): The prediction set ID.
119
-
120
- Returns:
121
- bool: True if deletion was successful.
122
- """
123
- if dataset_id is None:
124
- raise BadParameterError("dataset_id is required.")
125
- if data_id is None:
126
- raise BadParameterError("data_id is required.")
127
- if prediction_set_id is None:
128
- raise BadParameterError("prediction_set_id is required.")
129
-
130
- response = self.request_gql(
131
- Queries.DELETE_PREDICTION_FROM_DATA,
132
- Queries.DELETE_PREDICTION_FROM_DATA["variables"](
133
- dataset_id=dataset_id,
134
- data_id=data_id,
135
- prediction_set_id=prediction_set_id
136
- )
137
- )
138
- return response.get("deletePrediction") is not None
139
-
140
- def create_prediction_set(
141
- self,
142
- dataset_id: str,
143
- model_id: str,
144
- name: str,
145
- type: str,
146
- description: Optional[str] = None,
147
- annotations_count: Optional[int] = None,
148
- data_count: Optional[int] = None,
149
- ) -> Optional[str]:
150
- """Create a new prediction set.
151
-
152
- Args:
153
- dataset_id (str): The dataset ID.
154
- model_id (str): The model ID.
155
- name (str): Name of the prediction set.
156
- type (str): Type of the prediction set.
157
- description (Optional[str]): Description of the prediction set.
158
- annotations_count (Optional[int]): Number of annotations.
159
- data_count (Optional[int]): Number of data items.
160
-
161
- Returns:
162
- Optional[str]: The created prediction set ID if successful, None otherwise.
163
- """
164
- if dataset_id is None:
165
- raise BadParameterError("dataset_id is required.")
166
- if model_id is None:
167
- raise BadParameterError("model_id is required.")
168
- if name is None:
169
- raise BadParameterError("name is required.")
170
- if type is None:
171
- raise BadParameterError("type is required.")
172
-
173
- response = self.request_gql(
174
- Queries.CREATE_PREDICTION_SET,
175
- Queries.CREATE_PREDICTION_SET["variables"](
176
- dataset_id=dataset_id,
177
- model_id=model_id,
178
- name=name,
179
- type=type,
180
- description=description,
181
- annotations_count=annotations_count,
182
- data_count=data_count
183
- )
184
- )
185
- prediction_set = response.get("createPredictionSet")
186
- return prediction_set.get("id") if prediction_set else None
187
-
188
- def update_prediction_set_data_info(
189
- self,
190
- dataset_id: str,
191
- id: str,
192
- annotation_count: int,
193
- data_count: int
194
- ) -> Optional[str]:
195
- """Update the data info of a prediction set.
196
-
197
- Args:
198
- dataset_id (str): The dataset ID.
199
- id (str): The prediction set ID to update.
200
- annotation_count (int): Number of annotations.
201
- data_count (int): Number of data items.
202
-
203
- Returns:
204
- Optional[str]: The updated prediction set ID if successful, None otherwise.
205
- """
206
- if dataset_id is None:
207
- raise BadParameterError("dataset_id is required.")
208
- if id is None:
209
- raise BadParameterError("id is required.")
210
- if annotation_count is None:
211
- raise BadParameterError("annotation_count is required.")
212
- if data_count is None:
213
- raise BadParameterError("data_count is required.")
214
-
215
- response = self.request_gql(
216
- Queries.UPDATE_PREDICTION_SET_DATA_INFO,
217
- Queries.UPDATE_PREDICTION_SET_DATA_INFO["variables"](
218
- dataset_id=dataset_id,
219
- id=id,
220
- annotation_count=annotation_count,
221
- data_count=data_count
222
- )
223
- )
224
- prediction_set = response.get("updatePredictionSet")
225
- return prediction_set.get("id") if prediction_set else None
tests/models/__init__.py DELETED
@@ -1 +0,0 @@
1
- # Models test package