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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from typing import Optional, List, Union
|
|
2
|
+
|
|
3
|
+
from spb_onprem.base_model import CustomBaseModel, Field
|
|
4
|
+
from spb_onprem.base_types import Undefined, UndefinedType
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ModelsFilterOptions(CustomBaseModel):
|
|
8
|
+
"""Options for filtering models.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
name_contains: Filter models by name containing this string
|
|
12
|
+
id_in: Filter models by list of IDs
|
|
13
|
+
is_pinned: Filter models by pinned status
|
|
14
|
+
is_trained: Filter models by trained status
|
|
15
|
+
"""
|
|
16
|
+
name_contains: Optional[str] = Field(None, alias="nameContains")
|
|
17
|
+
id_in: Optional[List[str]] = Field(None, alias="idIn")
|
|
18
|
+
is_pinned: Optional[bool] = Field(None, alias="isPinned")
|
|
19
|
+
is_trained: Optional[bool] = Field(None, alias="isTrained")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ModelsFilter(CustomBaseModel):
|
|
23
|
+
"""Filter criteria for model queries.
|
|
24
|
+
|
|
25
|
+
Attributes:
|
|
26
|
+
must_filter: Conditions that must be met
|
|
27
|
+
not_filter: Conditions that must not be met
|
|
28
|
+
"""
|
|
29
|
+
must_filter: Optional[ModelsFilterOptions] = Field(None, alias="must")
|
|
30
|
+
not_filter: Optional[ModelsFilterOptions] = Field(None, alias="not")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def models_params(
|
|
34
|
+
dataset_id: str,
|
|
35
|
+
models_filter: Union[
|
|
36
|
+
ModelsFilter,
|
|
37
|
+
UndefinedType
|
|
38
|
+
] = Undefined,
|
|
39
|
+
cursor: Optional[str] = None,
|
|
40
|
+
length: Optional[int] = 10
|
|
41
|
+
):
|
|
42
|
+
"""Get parameters for listing models.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
dataset_id: Required dataset ID
|
|
46
|
+
models_filter: Optional filter criteria for models
|
|
47
|
+
cursor: Optional cursor for pagination
|
|
48
|
+
length: Optional number of items per page (default: 10)
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
dict: Parameters for listing models
|
|
52
|
+
"""
|
|
53
|
+
return {
|
|
54
|
+
"datasetId": dataset_id,
|
|
55
|
+
"filter": models_filter.model_dump(
|
|
56
|
+
by_alias=True, exclude_unset=True
|
|
57
|
+
) if models_filter and not isinstance(models_filter, UndefinedType) else None,
|
|
58
|
+
"cursor": cursor,
|
|
59
|
+
"length": length
|
|
60
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
def pin_model_params(
|
|
2
|
+
dataset_id: str,
|
|
3
|
+
model_id: str,
|
|
4
|
+
):
|
|
5
|
+
"""Get parameters for pinning a model.
|
|
6
|
+
|
|
7
|
+
Args:
|
|
8
|
+
dataset_id: The dataset ID
|
|
9
|
+
model_id: The model ID
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
dict: Parameters for pinning a model
|
|
13
|
+
"""
|
|
14
|
+
return {
|
|
15
|
+
"datasetId": dataset_id,
|
|
16
|
+
"id": model_id,
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
def unpin_model_params(
|
|
2
|
+
dataset_id: str,
|
|
3
|
+
model_id: str,
|
|
4
|
+
):
|
|
5
|
+
"""Get parameters for unpinning a model.
|
|
6
|
+
|
|
7
|
+
Args:
|
|
8
|
+
dataset_id: The dataset ID
|
|
9
|
+
model_id: The model ID
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
dict: Parameters for unpinning a model
|
|
13
|
+
"""
|
|
14
|
+
return {
|
|
15
|
+
"datasetId": dataset_id,
|
|
16
|
+
"id": model_id,
|
|
17
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from typing import List, Union, Any
|
|
2
|
+
from spb_onprem.base_types import Undefined, UndefinedType
|
|
3
|
+
from spb_onprem.models.entities.model_train_class import ModelTrainClass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def update_model_params(
|
|
7
|
+
dataset_id: str,
|
|
8
|
+
model_id: str,
|
|
9
|
+
name: Union[str, UndefinedType] = Undefined,
|
|
10
|
+
description: Union[str, UndefinedType] = Undefined,
|
|
11
|
+
training_classes: Union[List[ModelTrainClass], UndefinedType] = Undefined,
|
|
12
|
+
model_content_id: Union[str, UndefinedType] = Undefined,
|
|
13
|
+
is_trained: Union[bool, UndefinedType] = Undefined,
|
|
14
|
+
trained_at: Union[str, UndefinedType] = Undefined,
|
|
15
|
+
meta: Union[Any, UndefinedType] = Undefined,
|
|
16
|
+
):
|
|
17
|
+
"""Get parameters for updating a model.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
dataset_id: The dataset ID
|
|
21
|
+
model_id: The model ID
|
|
22
|
+
name: Optional new name
|
|
23
|
+
description: Optional new description
|
|
24
|
+
training_classes: Optional new training classes
|
|
25
|
+
model_content_id: Optional new model content ID
|
|
26
|
+
is_trained: Optional new trained status
|
|
27
|
+
trained_at: Optional new trained timestamp
|
|
28
|
+
meta: Optional new metadata
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
dict: Parameters for updating a model
|
|
32
|
+
"""
|
|
33
|
+
params = {
|
|
34
|
+
"datasetId": dataset_id,
|
|
35
|
+
"id": model_id,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if not isinstance(name, UndefinedType):
|
|
39
|
+
params["name"] = name
|
|
40
|
+
|
|
41
|
+
if not isinstance(description, UndefinedType):
|
|
42
|
+
params["description"] = description
|
|
43
|
+
|
|
44
|
+
if not isinstance(training_classes, UndefinedType):
|
|
45
|
+
params["trainingClasses"] = [
|
|
46
|
+
tc.model_dump(by_alias=True, exclude_unset=True) for tc in training_classes
|
|
47
|
+
] if training_classes is not None else None
|
|
48
|
+
|
|
49
|
+
if not isinstance(model_content_id, UndefinedType):
|
|
50
|
+
params["modelContentId"] = model_content_id
|
|
51
|
+
|
|
52
|
+
if not isinstance(is_trained, UndefinedType):
|
|
53
|
+
params["isTrained"] = is_trained
|
|
54
|
+
|
|
55
|
+
if not isinstance(trained_at, UndefinedType):
|
|
56
|
+
params["trainedAt"] = trained_at
|
|
57
|
+
|
|
58
|
+
if not isinstance(meta, UndefinedType):
|
|
59
|
+
params["meta"] = meta
|
|
60
|
+
|
|
61
|
+
return params
|
spb_onprem/models/queries.py
CHANGED
|
@@ -1,33 +1,238 @@
|
|
|
1
|
-
from .params import (
|
|
2
|
-
|
|
1
|
+
from spb_onprem.models.params import (
|
|
2
|
+
models_params,
|
|
3
|
+
model_params,
|
|
4
|
+
create_model_params,
|
|
5
|
+
update_model_params,
|
|
6
|
+
pin_model_params,
|
|
7
|
+
unpin_model_params,
|
|
3
8
|
delete_model_params,
|
|
4
9
|
)
|
|
5
10
|
|
|
6
11
|
|
|
7
|
-
class
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
class Schemas:
|
|
13
|
+
MODEL_TRAIN_CLASS = '''
|
|
14
|
+
class
|
|
15
|
+
annotationType
|
|
16
|
+
ap
|
|
17
|
+
trainingAnnotationsCount
|
|
18
|
+
validationAnnotationsCount
|
|
19
|
+
'''
|
|
20
|
+
|
|
21
|
+
MODEL = '''
|
|
22
|
+
id
|
|
23
|
+
datasetId
|
|
24
|
+
baselineModel
|
|
25
|
+
name
|
|
26
|
+
description
|
|
27
|
+
trainingClasses {
|
|
28
|
+
class
|
|
29
|
+
annotationType
|
|
30
|
+
ap
|
|
31
|
+
trainingAnnotationsCount
|
|
32
|
+
validationAnnotationsCount
|
|
33
|
+
}
|
|
34
|
+
trainingDataCount
|
|
35
|
+
validationDataCount
|
|
36
|
+
isPinned
|
|
37
|
+
isTrained
|
|
38
|
+
trainedAt
|
|
39
|
+
modelContent {
|
|
40
|
+
id
|
|
41
|
+
downloadURL
|
|
42
|
+
}
|
|
43
|
+
createdBy
|
|
44
|
+
createdAt
|
|
45
|
+
updatedBy
|
|
46
|
+
updatedAt
|
|
47
|
+
meta
|
|
48
|
+
trainingSlices {
|
|
49
|
+
id
|
|
50
|
+
datasetId
|
|
51
|
+
name
|
|
52
|
+
description
|
|
53
|
+
isPinned
|
|
54
|
+
createdAt
|
|
55
|
+
createdBy
|
|
56
|
+
updatedAt
|
|
57
|
+
updatedBy
|
|
58
|
+
}
|
|
59
|
+
validationSlices {
|
|
60
|
+
id
|
|
61
|
+
datasetId
|
|
62
|
+
name
|
|
63
|
+
description
|
|
64
|
+
isPinned
|
|
65
|
+
createdAt
|
|
66
|
+
createdBy
|
|
67
|
+
updatedAt
|
|
68
|
+
updatedBy
|
|
69
|
+
}
|
|
70
|
+
'''
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class Queries():
|
|
74
|
+
MODELS = {
|
|
75
|
+
"name": "models",
|
|
76
|
+
"query": f'''
|
|
77
|
+
query Models(
|
|
78
|
+
$datasetId: ID!,
|
|
79
|
+
$filter: ModelFilter,
|
|
80
|
+
$cursor: String,
|
|
81
|
+
$length: Int
|
|
82
|
+
) {{
|
|
83
|
+
models(
|
|
84
|
+
datasetId: $datasetId,
|
|
85
|
+
filter: $filter,
|
|
86
|
+
cursor: $cursor,
|
|
87
|
+
length: $length
|
|
88
|
+
) {{
|
|
89
|
+
models {{
|
|
90
|
+
{Schemas.MODEL}
|
|
91
|
+
}}
|
|
17
92
|
next
|
|
18
93
|
totalCount
|
|
19
|
-
}
|
|
20
|
-
}
|
|
94
|
+
}}
|
|
95
|
+
}}
|
|
96
|
+
''',
|
|
97
|
+
"variables": models_params,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
MODEL = {
|
|
101
|
+
"name": "model",
|
|
102
|
+
"query": f'''
|
|
103
|
+
query Model(
|
|
104
|
+
$datasetId: ID!,
|
|
105
|
+
$modelId: ID!
|
|
106
|
+
) {{
|
|
107
|
+
model(
|
|
108
|
+
datasetId: $datasetId,
|
|
109
|
+
id: $modelId
|
|
110
|
+
) {{
|
|
111
|
+
{Schemas.MODEL}
|
|
112
|
+
}}
|
|
113
|
+
}}
|
|
114
|
+
''',
|
|
115
|
+
"variables": model_params,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
CREATE_MODEL = {
|
|
119
|
+
"name": "createModel",
|
|
120
|
+
"query": f'''
|
|
121
|
+
mutation CreateModel(
|
|
122
|
+
$datasetId: ID!,
|
|
123
|
+
$name: String!,
|
|
124
|
+
$description: String,
|
|
125
|
+
$baselineModel: String!,
|
|
126
|
+
$trainingClasses: [ModelTrainClassInput!],
|
|
127
|
+
$trainingSliceIds: [ID!]!,
|
|
128
|
+
$validationSliceIds: [ID!]!,
|
|
129
|
+
$modelContentId: String,
|
|
130
|
+
$isTrained: Boolean,
|
|
131
|
+
$trainedAt: DateTime,
|
|
132
|
+
$isPinned: Boolean,
|
|
133
|
+
$meta: JSONObject
|
|
134
|
+
) {{
|
|
135
|
+
createModel(
|
|
136
|
+
datasetId: $datasetId,
|
|
137
|
+
name: $name,
|
|
138
|
+
description: $description,
|
|
139
|
+
baselineModel: $baselineModel,
|
|
140
|
+
trainingClasses: $trainingClasses,
|
|
141
|
+
trainingSliceIds: $trainingSliceIds,
|
|
142
|
+
validationSliceIds: $validationSliceIds,
|
|
143
|
+
modelContentId: $modelContentId,
|
|
144
|
+
isTrained: $isTrained,
|
|
145
|
+
trainedAt: $trainedAt,
|
|
146
|
+
isPinned: $isPinned,
|
|
147
|
+
meta: $meta
|
|
148
|
+
) {{
|
|
149
|
+
{Schemas.MODEL}
|
|
150
|
+
}}
|
|
151
|
+
}}
|
|
21
152
|
''',
|
|
22
|
-
"variables":
|
|
153
|
+
"variables": create_model_params,
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
UPDATE_MODEL = {
|
|
157
|
+
"name": "updateModel",
|
|
158
|
+
"query": f'''
|
|
159
|
+
mutation UpdateModel(
|
|
160
|
+
$datasetId: ID!,
|
|
161
|
+
$id: ID!,
|
|
162
|
+
$name: String,
|
|
163
|
+
$description: String,
|
|
164
|
+
$trainingClasses: [ModelTrainClassInput!],
|
|
165
|
+
$modelContentId: String,
|
|
166
|
+
$isTrained: Boolean,
|
|
167
|
+
$trainedAt: DateTime,
|
|
168
|
+
$meta: JSONObject
|
|
169
|
+
) {{
|
|
170
|
+
updateModel(
|
|
171
|
+
datasetId: $datasetId,
|
|
172
|
+
id: $id,
|
|
173
|
+
name: $name,
|
|
174
|
+
description: $description,
|
|
175
|
+
trainingClasses: $trainingClasses,
|
|
176
|
+
modelContentId: $modelContentId,
|
|
177
|
+
isTrained: $isTrained,
|
|
178
|
+
trainedAt: $trainedAt,
|
|
179
|
+
meta: $meta
|
|
180
|
+
) {{
|
|
181
|
+
{Schemas.MODEL}
|
|
182
|
+
}}
|
|
183
|
+
}}
|
|
184
|
+
''',
|
|
185
|
+
"variables": update_model_params,
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
PIN_MODEL = {
|
|
189
|
+
"name": "pinModel",
|
|
190
|
+
"query": f'''
|
|
191
|
+
mutation PinModel(
|
|
192
|
+
$datasetId: ID!,
|
|
193
|
+
$id: ID!
|
|
194
|
+
) {{
|
|
195
|
+
pinModel(
|
|
196
|
+
datasetId: $datasetId,
|
|
197
|
+
id: $id
|
|
198
|
+
) {{
|
|
199
|
+
{Schemas.MODEL}
|
|
200
|
+
}}
|
|
201
|
+
}}
|
|
202
|
+
''',
|
|
203
|
+
"variables": pin_model_params,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
UNPIN_MODEL = {
|
|
207
|
+
"name": "unpinModel",
|
|
208
|
+
"query": f'''
|
|
209
|
+
mutation UnpinModel(
|
|
210
|
+
$datasetId: ID!,
|
|
211
|
+
$id: ID!
|
|
212
|
+
) {{
|
|
213
|
+
unpinModel(
|
|
214
|
+
datasetId: $datasetId,
|
|
215
|
+
id: $id
|
|
216
|
+
) {{
|
|
217
|
+
{Schemas.MODEL}
|
|
218
|
+
}}
|
|
219
|
+
}}
|
|
220
|
+
''',
|
|
221
|
+
"variables": unpin_model_params,
|
|
23
222
|
}
|
|
24
223
|
|
|
25
224
|
DELETE_MODEL = {
|
|
26
225
|
"name": "deleteModel",
|
|
27
226
|
"query": '''
|
|
28
|
-
mutation DeleteModel(
|
|
29
|
-
|
|
227
|
+
mutation DeleteModel(
|
|
228
|
+
$datasetId: ID!,
|
|
229
|
+
$id: ID!
|
|
230
|
+
) {
|
|
231
|
+
deleteModel(
|
|
232
|
+
datasetId: $datasetId,
|
|
233
|
+
id: $id
|
|
234
|
+
)
|
|
30
235
|
}
|
|
31
236
|
''',
|
|
32
|
-
"variables": delete_model_params
|
|
33
|
-
}
|
|
237
|
+
"variables": delete_model_params,
|
|
238
|
+
}
|