superb-ai-onprem 0.2.0__py3-none-any.whl → 0.3.1__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 +8 -1
- spb_onprem/_version.py +2 -2
- spb_onprem/data/enums/data_type.py +2 -1
- spb_onprem/entities.py +3 -1
- spb_onprem/exports/__init__.py +9 -0
- spb_onprem/exports/entities/__init__.py +7 -0
- spb_onprem/exports/entities/export.py +27 -0
- spb_onprem/exports/params/__init__.py +19 -0
- spb_onprem/exports/params/create_export.py +85 -0
- spb_onprem/exports/params/delete_export.py +30 -0
- spb_onprem/exports/params/export.py +30 -0
- spb_onprem/exports/params/exports.py +74 -0
- spb_onprem/exports/params/update_export.py +98 -0
- spb_onprem/exports/queries.py +158 -0
- spb_onprem/exports/service.py +229 -0
- spb_onprem/searches.py +6 -0
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.1.dist-info}/METADATA +1 -1
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.1.dist-info}/RECORD +27 -10
- tests/exports/__init__.py +1 -0
- tests/exports/real_test.py +130 -0
- tests/exports/test_entities.py +236 -0
- tests/exports/test_integration.py +191 -0
- tests/exports/test_params.py +332 -0
- tests/exports/test_service.py +406 -0
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.1.dist-info}/WHEEL +0 -0
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.1.dist-info}/licenses/LICENSE +0 -0
- {superb_ai_onprem-0.2.0.dist-info → superb_ai_onprem-0.3.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
from typing import Optional, List, Union
|
|
2
|
+
|
|
3
|
+
from spb_onprem.base_service import BaseService
|
|
4
|
+
from spb_onprem.base_types import (
|
|
5
|
+
Undefined,
|
|
6
|
+
UndefinedType,
|
|
7
|
+
)
|
|
8
|
+
from spb_onprem.data.params import DataListFilter
|
|
9
|
+
|
|
10
|
+
from .entities import Export
|
|
11
|
+
from .params import (
|
|
12
|
+
ExportFilter,
|
|
13
|
+
)
|
|
14
|
+
from .queries import Queries
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ExportService(BaseService):
|
|
18
|
+
"""Service class for handling export-related operations."""
|
|
19
|
+
|
|
20
|
+
def create_export(
|
|
21
|
+
self,
|
|
22
|
+
dataset_id: str,
|
|
23
|
+
name: Union[
|
|
24
|
+
UndefinedType,
|
|
25
|
+
str
|
|
26
|
+
] = Undefined,
|
|
27
|
+
data_filter: Union[
|
|
28
|
+
UndefinedType,
|
|
29
|
+
DataListFilter,
|
|
30
|
+
dict
|
|
31
|
+
] = Undefined,
|
|
32
|
+
location: Union[
|
|
33
|
+
UndefinedType,
|
|
34
|
+
str
|
|
35
|
+
] = Undefined,
|
|
36
|
+
data_count: Union[
|
|
37
|
+
UndefinedType,
|
|
38
|
+
int
|
|
39
|
+
] = Undefined,
|
|
40
|
+
frame_count: Union[
|
|
41
|
+
UndefinedType,
|
|
42
|
+
int
|
|
43
|
+
] = Undefined,
|
|
44
|
+
annotation_count: Union[
|
|
45
|
+
UndefinedType,
|
|
46
|
+
int
|
|
47
|
+
] = Undefined,
|
|
48
|
+
meta: Union[
|
|
49
|
+
UndefinedType,
|
|
50
|
+
dict
|
|
51
|
+
] = Undefined,
|
|
52
|
+
) -> Export:
|
|
53
|
+
"""Create an export.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
dataset_id (str): The ID of the dataset to create the export for.
|
|
57
|
+
name (Optional[str]): The name of the export.
|
|
58
|
+
data_filter (Optional[DataListFilter | dict]): The search filter of the data.
|
|
59
|
+
data_count (Optional[int]): The number of data items to export.
|
|
60
|
+
frame_count (Optional[int]): The number of frames to export.
|
|
61
|
+
annotation_count (Optional[int]): The number of annotations to export.
|
|
62
|
+
meta (Optional[dict]): The meta information for the export.
|
|
63
|
+
"""
|
|
64
|
+
response = self.request_gql(
|
|
65
|
+
Queries.CREATE_EXPORT,
|
|
66
|
+
Queries.CREATE_EXPORT["variables"](
|
|
67
|
+
dataset_id=dataset_id,
|
|
68
|
+
name=name,
|
|
69
|
+
data_filter=data_filter,
|
|
70
|
+
location=location,
|
|
71
|
+
data_count=data_count,
|
|
72
|
+
frame_count=frame_count,
|
|
73
|
+
annotation_count=annotation_count,
|
|
74
|
+
meta=meta,
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
return Export.model_validate(response)
|
|
78
|
+
|
|
79
|
+
def get_exports(
|
|
80
|
+
self,
|
|
81
|
+
dataset_id: str,
|
|
82
|
+
export_filter: Optional[ExportFilter] = None,
|
|
83
|
+
cursor: Optional[str] = None,
|
|
84
|
+
length: int = 10
|
|
85
|
+
) -> tuple[List[Export], Optional[str], int]:
|
|
86
|
+
"""Get exports.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
dataset_id (str): The ID of the dataset to get exports for.
|
|
90
|
+
export_filter (Optional[ExportsFilterOptions]): The filter to apply to the exports.
|
|
91
|
+
cursor (Optional[str]): The cursor to use for pagination.
|
|
92
|
+
length (int): The number of exports to get.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
tuple[List[Export], Optional[str], int]: A tuple containing the exports, the next cursor, and the total count of exports.
|
|
96
|
+
"""
|
|
97
|
+
response = self.request_gql(
|
|
98
|
+
Queries.GET_EXPORTS,
|
|
99
|
+
Queries.GET_EXPORTS["variables"](
|
|
100
|
+
dataset_id=dataset_id,
|
|
101
|
+
export_filter=export_filter,
|
|
102
|
+
cursor=cursor,
|
|
103
|
+
length=length,
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
exports_dict = response.get("exports", [])
|
|
107
|
+
return (
|
|
108
|
+
[Export.model_validate(export_dict) for export_dict in exports_dict],
|
|
109
|
+
response.get("next"),
|
|
110
|
+
response.get("totalCount"),
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
def get_export(
|
|
114
|
+
self,
|
|
115
|
+
dataset_id: str,
|
|
116
|
+
export_id: str,
|
|
117
|
+
) -> Export:
|
|
118
|
+
"""Get an export.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
dataset_id (str): The ID of the dataset to get the export for.
|
|
122
|
+
export_id (str): The ID of the export to get.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
Export: The export object.
|
|
126
|
+
"""
|
|
127
|
+
response = self.request_gql(
|
|
128
|
+
Queries.GET_EXPORT,
|
|
129
|
+
Queries.GET_EXPORT["variables"](
|
|
130
|
+
dataset_id=dataset_id,
|
|
131
|
+
export_id=export_id,
|
|
132
|
+
)
|
|
133
|
+
)
|
|
134
|
+
return Export.model_validate(response)
|
|
135
|
+
|
|
136
|
+
def update_export(
|
|
137
|
+
self,
|
|
138
|
+
dataset_id: str,
|
|
139
|
+
export_id: str,
|
|
140
|
+
location: Union[
|
|
141
|
+
UndefinedType,
|
|
142
|
+
str
|
|
143
|
+
] = Undefined,
|
|
144
|
+
name: Union[
|
|
145
|
+
UndefinedType,
|
|
146
|
+
str
|
|
147
|
+
] = Undefined,
|
|
148
|
+
data_filter: Union[
|
|
149
|
+
UndefinedType,
|
|
150
|
+
DataListFilter,
|
|
151
|
+
dict
|
|
152
|
+
] = Undefined,
|
|
153
|
+
data_count: Union[
|
|
154
|
+
UndefinedType,
|
|
155
|
+
int
|
|
156
|
+
] = Undefined,
|
|
157
|
+
frame_count: Union[
|
|
158
|
+
UndefinedType,
|
|
159
|
+
int
|
|
160
|
+
] = Undefined,
|
|
161
|
+
annotation_count: Union[
|
|
162
|
+
UndefinedType,
|
|
163
|
+
int
|
|
164
|
+
] = Undefined,
|
|
165
|
+
meta: Union[
|
|
166
|
+
UndefinedType,
|
|
167
|
+
dict
|
|
168
|
+
] = Undefined,
|
|
169
|
+
completed_at: Union[
|
|
170
|
+
UndefinedType,
|
|
171
|
+
str
|
|
172
|
+
] = Undefined,
|
|
173
|
+
) -> Export:
|
|
174
|
+
"""Update an export.
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
dataset_id (str): The ID of the dataset to update the export for.
|
|
178
|
+
export_id (str): The ID of the export to update.
|
|
179
|
+
location (Optional[str]): The location where the export will be stored.
|
|
180
|
+
name (Optional[str]): The name of the export.
|
|
181
|
+
data_filter (Optional[DataListFilter | dict]): The search filter of the data.
|
|
182
|
+
data_count (Optional[int]): The number of data items to export.
|
|
183
|
+
frame_count (Optional[int]): The number of frames to export.
|
|
184
|
+
annotation_count (Optional[int]): The number of annotations to export.
|
|
185
|
+
meta (Optional[dict]): The meta information for the export.
|
|
186
|
+
completed_at (Optional[str]): The completed time of the export.
|
|
187
|
+
|
|
188
|
+
Returns:
|
|
189
|
+
Export: The updated export object.
|
|
190
|
+
"""
|
|
191
|
+
response = self.request_gql(
|
|
192
|
+
Queries.UPDATE_EXPORT,
|
|
193
|
+
Queries.UPDATE_EXPORT["variables"](
|
|
194
|
+
dataset_id=dataset_id,
|
|
195
|
+
export_id=export_id,
|
|
196
|
+
location=location,
|
|
197
|
+
name=name,
|
|
198
|
+
data_filter=data_filter,
|
|
199
|
+
data_count=data_count,
|
|
200
|
+
frame_count=frame_count,
|
|
201
|
+
annotation_count=annotation_count,
|
|
202
|
+
meta=meta,
|
|
203
|
+
completed_at=completed_at,
|
|
204
|
+
)
|
|
205
|
+
)
|
|
206
|
+
return Export.model_validate(response)
|
|
207
|
+
|
|
208
|
+
def delete_export(
|
|
209
|
+
self,
|
|
210
|
+
dataset_id: str,
|
|
211
|
+
export_id: str,
|
|
212
|
+
) -> bool:
|
|
213
|
+
"""Delete an export.
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
dataset_id (str): The ID of the dataset to delete the export for.
|
|
217
|
+
export_id (str): The ID of the export to delete.
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
bool: True if the export was deleted, False otherwise.
|
|
221
|
+
"""
|
|
222
|
+
response = self.request_gql(
|
|
223
|
+
Queries.DELETE_EXPORT,
|
|
224
|
+
Queries.DELETE_EXPORT["variables"](
|
|
225
|
+
dataset_id=dataset_id,
|
|
226
|
+
export_id=export_id,
|
|
227
|
+
)
|
|
228
|
+
)
|
|
229
|
+
return response
|
spb_onprem/searches.py
CHANGED
|
@@ -16,6 +16,10 @@ from .activities.params.activities import (
|
|
|
16
16
|
ActivitiesFilter,
|
|
17
17
|
ActivitiesFilterOptions,
|
|
18
18
|
)
|
|
19
|
+
from .exports.params.exports import (
|
|
20
|
+
ExportFilter,
|
|
21
|
+
ExportFilterOptions,
|
|
22
|
+
)
|
|
19
23
|
|
|
20
24
|
__all__ = [
|
|
21
25
|
"AnnotationFilter",
|
|
@@ -27,4 +31,6 @@ __all__ = [
|
|
|
27
31
|
"SlicesFilterOptions",
|
|
28
32
|
"ActivitiesFilter",
|
|
29
33
|
"ActivitiesFilterOptions",
|
|
34
|
+
"ExportFilter",
|
|
35
|
+
"ExportFilterOptions",
|
|
30
36
|
]
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
spb_onprem/__init__.py,sha256=
|
|
2
|
-
spb_onprem/_version.py,sha256=
|
|
1
|
+
spb_onprem/__init__.py,sha256=Iucr68oU5pQ3lhHlyI36HUaReA7gsanGuLCSAVZh7GI,1761
|
|
2
|
+
spb_onprem/_version.py,sha256=lOWWIGJeBi0KkFopWU_n3GH71C1PsaZ-ZYDfxFkne6c,511
|
|
3
3
|
spb_onprem/base_model.py,sha256=XLtyoxRBs68LrvbFH8V4EvQGPc2W17koC310MnS37jc,442
|
|
4
4
|
spb_onprem/base_service.py,sha256=dPfr3mGXYlqadOXycu6RBFX1HcZ1qzEsskLoOxERLOU,5737
|
|
5
5
|
spb_onprem/base_types.py,sha256=5HO6uy6qf08b4KSElwIaGy7UkoQG2KqVO6gcHbsqqSo,269
|
|
6
|
-
spb_onprem/entities.py,sha256=
|
|
6
|
+
spb_onprem/entities.py,sha256=VFwaSdHIVB6NhxX5-pFRNPzCqVLNEZS-O2JETIYMopk,823
|
|
7
7
|
spb_onprem/exceptions.py,sha256=jx5rTGsVZ5shOdbgQzk8GcSyMWFtb_3xhPq6Sylwc5o,478
|
|
8
|
-
spb_onprem/searches.py,sha256=
|
|
8
|
+
spb_onprem/searches.py,sha256=VRj9vpvKU8iOdBJUA6BwfvOjUbWrKBo9fPJvNlRmKr0,750
|
|
9
9
|
spb_onprem/activities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
spb_onprem/activities/queries.py,sha256=iXuNVsJuw8yt9QNw8jEBXpUnGLD6LDC1v2_jBBgsmXs,5626
|
|
11
11
|
spb_onprem/activities/service.py,sha256=DI68qkDrvpm1NW_9BzWc37kSzyedfx4xLHqMeyDjp3A,10554
|
|
@@ -37,7 +37,7 @@ spb_onprem/data/entities/prediction.py,sha256=Eb2ldNSezeYDnaLQOfC65XWoDGJ0snlvlc
|
|
|
37
37
|
spb_onprem/data/entities/scene.py,sha256=SJgr5UnGxktyaKjU8FYDaIQmsu7xSJftJOiCgq9uSmo,446
|
|
38
38
|
spb_onprem/data/enums/__init__.py,sha256=IJWaapwesyIiIjuAykZc5fXdMXK2_IiOBa7qNY5cCNk,213
|
|
39
39
|
spb_onprem/data/enums/data_meta_type.py,sha256=9rd12-7C1udbbIGvnuGURKmd5-lndtW7oWQAQwKSf_Q,335
|
|
40
|
-
spb_onprem/data/enums/data_type.py,sha256=
|
|
40
|
+
spb_onprem/data/enums/data_type.py,sha256=BXcmeuWL-y4yIAswI_zsYqH9ozEmgl6uSki7hgbOZ_g,197
|
|
41
41
|
spb_onprem/data/enums/scene_type.py,sha256=ed8fAKfDk9PNG8YgYv3jI59IR9oCr_gkooexAe0448I,187
|
|
42
42
|
spb_onprem/data/params/__init__.py,sha256=IApFFU6t3lHclvbivLSFdUxhrj1BjO50c3OMG6zP2iY,1311
|
|
43
43
|
spb_onprem/data/params/create_data.py,sha256=8DOfbEchf9GSybiYY1cZoNzNYwILokoAkxXRFybJUAU,2038
|
|
@@ -67,6 +67,17 @@ spb_onprem/datasets/params/create_dataset.py,sha256=YGhLvY4arthjZwKQ28HLv7ch0Gd2
|
|
|
67
67
|
spb_onprem/datasets/params/dataset.py,sha256=WTOUl5M5cc6rtTwhLw_z31Cs209LkBq8Ja4LJGzrmGE,668
|
|
68
68
|
spb_onprem/datasets/params/datasets.py,sha256=Hx4YlLxfb-Qwi4Y5AFl5pyyjupvuoVcCtxLPGjIV7UY,1580
|
|
69
69
|
spb_onprem/datasets/params/update_dataset.py,sha256=1oaj2qB9hvnypl4-WtcTNCa4iSuEkJjEalq2JsTm5Ro,924
|
|
70
|
+
spb_onprem/exports/__init__.py,sha256=l_eUjnrFJXs-vdOeMNiWYK-UdJkxArv7hxmKDG4Dfio,181
|
|
71
|
+
spb_onprem/exports/queries.py,sha256=sFT6VX2UwAYyVNkiBteQ_JtKYnhMrt64ww_NuXhUhLM,4084
|
|
72
|
+
spb_onprem/exports/service.py,sha256=dYdi-X03A8YuKxxvQhMsyzJ8r95DxXQr5KZ818g0vSk,7118
|
|
73
|
+
spb_onprem/exports/entities/__init__.py,sha256=_w5Qs_9Dvmy8_tweOmEpGmlMHx8m70rDSl94o7oTfmk,94
|
|
74
|
+
spb_onprem/exports/entities/export.py,sha256=awE2xASCarLcmxNwvjjs6CqWXKptz2M-sGE-AUf74bI,1084
|
|
75
|
+
spb_onprem/exports/params/__init__.py,sha256=F4X2go6V1vZ_pts5thKwW8Gal8otgv6FlLYSMDmPaMg,471
|
|
76
|
+
spb_onprem/exports/params/create_export.py,sha256=vC6qmGETQNQ9PIbe7ayarEe0KuBwylWupBqQOlsDD8E,2594
|
|
77
|
+
spb_onprem/exports/params/delete_export.py,sha256=EusUB86HNLtFYu4gIDJqZsODRETtTYhgxznjFHfxywc,664
|
|
78
|
+
spb_onprem/exports/params/export.py,sha256=0EP6nkQc6vFI-f8218Yq4NxfFcw8MQtHMNkYlGOXqo4,799
|
|
79
|
+
spb_onprem/exports/params/exports.py,sha256=oOQo-2Cqsm3Th3s-0gNcVGjbOyZqB6ujPRLXipulB4Y,2417
|
|
80
|
+
spb_onprem/exports/params/update_export.py,sha256=iOlZoHEN2iiY83hCZWdgTn-O9J8hcSUqd5K7_gEzvP4,3057
|
|
70
81
|
spb_onprem/slices/__init__.py,sha256=xgpNGYzqgwQ8C-Bgw9AZWMAgBW38UU-U4Wube8hkodI,69
|
|
71
82
|
spb_onprem/slices/queries.py,sha256=dl_q6Uc2_oeuItgSD6gUL7a3H5VrOW9Ig5Epte7sl78,2732
|
|
72
83
|
spb_onprem/slices/service.py,sha256=byhB9CdxNKV7uLIiL9yI674UVSlgaAwLaYoGQGBCawE,4988
|
|
@@ -81,13 +92,19 @@ spb_onprem/slices/params/update_slice.py,sha256=kryOmCnRTQ_OU0qDKgugppLrpeUpuLwm
|
|
|
81
92
|
spb_onprem/users/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
82
93
|
spb_onprem/users/entities/__init__.py,sha256=X8HZsCTlQnuPszok3AwI-i7bsQi0Ehul5L_2jZaol5E,57
|
|
83
94
|
spb_onprem/users/entities/auth.py,sha256=_KP-7yUErBxhJMm-dE3ObprPEG6e0JI2qNg6g8aK1qM,3371
|
|
84
|
-
superb_ai_onprem-0.
|
|
95
|
+
superb_ai_onprem-0.3.1.dist-info/licenses/LICENSE,sha256=CdinbFiHKGkGl6cPde6WgXhMuzyUXEG6tzy2-7udZ8o,1066
|
|
85
96
|
tests/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
|
|
86
97
|
tests/activities/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
|
|
87
98
|
tests/activities/real_test.py,sha256=0gQHg7rIEuZndGZyNHMWSD5nUZPMsUGigfCjWFxMthQ,1786
|
|
88
99
|
tests/activities/test_params.py,sha256=L3mcnrN2c8dT0AVTjnGedu6LHF3eZ4sSDzz8eaMHJmg,2369
|
|
89
100
|
tests/activities/test_service.py,sha256=AbWFwjaUjQRs5oDZ2ba0C23XJxCqsFNrxH1LamMtWmU,4698
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
tests/exports/__init__.py,sha256=iBqr781TtnT1Tm5wLTCsdftpuRgQifIibxWrB_I7tiw,23
|
|
102
|
+
tests/exports/real_test.py,sha256=KeHWvQP-vHCvFWvD4_7qFmreAX9o_Dd_YowaGFogZu8,3765
|
|
103
|
+
tests/exports/test_entities.py,sha256=hG7G4kVkyHKT3mv4lvrzUqOW8ILeHiYj87QZjQcmg9E,8836
|
|
104
|
+
tests/exports/test_integration.py,sha256=cCcEgwIIHyQRlc04EAXSKz7RcblQvhI2GBR3uVaOOq8,6201
|
|
105
|
+
tests/exports/test_params.py,sha256=oRRa6nEru_FImlB3TrmFiBidz6ZstCx4rVaCK-EMGfQ,11070
|
|
106
|
+
tests/exports/test_service.py,sha256=IDcKxrmByh00jk9142P2ThuGureMoijTHNdU0rERGG8,14628
|
|
107
|
+
superb_ai_onprem-0.3.1.dist-info/METADATA,sha256=wRZVOqPK9ul6lYcUgGgFd9Yaf9zWvnfqEhJND6JACOA,5817
|
|
108
|
+
superb_ai_onprem-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
109
|
+
superb_ai_onprem-0.3.1.dist-info/top_level.txt,sha256=LbqU6FjWKaxO7FPS5-71e3OIS8VgBi5VrtQMWFOW25Q,17
|
|
110
|
+
superb_ai_onprem-0.3.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Export tests package
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
from spb_onprem import (
|
|
2
|
+
DatasetService,
|
|
3
|
+
Dataset,
|
|
4
|
+
ExportService,
|
|
5
|
+
Export,
|
|
6
|
+
ExportFilter,
|
|
7
|
+
ExportFilterOptions,
|
|
8
|
+
)
|
|
9
|
+
from spb_onprem.data.params import DataListFilter, DataFilterOptions
|
|
10
|
+
from spb_onprem.data.enums import DataType
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_export_service():
|
|
14
|
+
# Initialize services
|
|
15
|
+
dataset_service = DatasetService()
|
|
16
|
+
dataset = dataset_service.get_dataset(
|
|
17
|
+
dataset_id="01JPM6NR1APMBXJNC0YW72S1FN"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
print(f"Dataset: {dataset}")
|
|
21
|
+
|
|
22
|
+
export_service = ExportService()
|
|
23
|
+
|
|
24
|
+
# Test 1: Create an export with DataListFilter
|
|
25
|
+
print("\n=== Creating Export ===")
|
|
26
|
+
data_filter = DataListFilter(
|
|
27
|
+
must_filter=DataFilterOptions(key_contains="validation")
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
new_export = export_service.create_export(
|
|
31
|
+
dataset_id=dataset.id,
|
|
32
|
+
name="SDK Test Export",
|
|
33
|
+
data_filter=data_filter,
|
|
34
|
+
meta={
|
|
35
|
+
"created_by": "sdk_test",
|
|
36
|
+
"purpose": "real_test"
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
print(f"Created export: {new_export}")
|
|
40
|
+
|
|
41
|
+
# Test 2: Get exports with pagination
|
|
42
|
+
print("\n=== Getting Exports ===")
|
|
43
|
+
cursor = None
|
|
44
|
+
all_exports = []
|
|
45
|
+
while True:
|
|
46
|
+
exports, cursor, total_count = export_service.get_exports(
|
|
47
|
+
dataset_id=dataset.id,
|
|
48
|
+
cursor=cursor,
|
|
49
|
+
length=10
|
|
50
|
+
)
|
|
51
|
+
all_exports.extend(exports)
|
|
52
|
+
print(f"Fetched {len(exports)} exports, total: {total_count}")
|
|
53
|
+
|
|
54
|
+
if cursor is None:
|
|
55
|
+
break
|
|
56
|
+
|
|
57
|
+
print(f"Total exports found: {len(all_exports)}")
|
|
58
|
+
|
|
59
|
+
# Test 3: Get exports with filter
|
|
60
|
+
print("\n=== Getting Exports with Filter ===")
|
|
61
|
+
export_filter = ExportFilter(
|
|
62
|
+
must_filter=ExportFilterOptions(
|
|
63
|
+
name_contains="SDK Test"
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
filtered_exports, _, filtered_count = export_service.get_exports(
|
|
68
|
+
dataset_id=dataset.id,
|
|
69
|
+
export_filter=export_filter,
|
|
70
|
+
length=50
|
|
71
|
+
)
|
|
72
|
+
print(f"Filtered exports: {len(filtered_exports)}, total: {filtered_count}")
|
|
73
|
+
|
|
74
|
+
# Test 4: Get specific export
|
|
75
|
+
if all_exports:
|
|
76
|
+
print("\n=== Getting Specific Export ===")
|
|
77
|
+
specific_export = export_service.get_export(
|
|
78
|
+
dataset_id=dataset.id,
|
|
79
|
+
export_id=all_exports[0].id
|
|
80
|
+
)
|
|
81
|
+
print(f"Specific export: {specific_export}")
|
|
82
|
+
|
|
83
|
+
# Test 5: Update the created export with complex DataListFilter
|
|
84
|
+
print("\n=== Updating Export ===")
|
|
85
|
+
complex_data_filter = DataListFilter(
|
|
86
|
+
must_filter=DataFilterOptions(
|
|
87
|
+
key_contains="validation",
|
|
88
|
+
type_in=[DataType.SUPERB_IMAGE]
|
|
89
|
+
),
|
|
90
|
+
not_filter=DataFilterOptions(
|
|
91
|
+
key_contains="test"
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
updated_export = export_service.update_export(
|
|
96
|
+
dataset_id=dataset.id,
|
|
97
|
+
export_id=new_export.id,
|
|
98
|
+
name="SDK Test Export - Updated",
|
|
99
|
+
data_filter=complex_data_filter,
|
|
100
|
+
meta={
|
|
101
|
+
"created_by": "sdk_test",
|
|
102
|
+
"purpose": "real_test",
|
|
103
|
+
"updated": True,
|
|
104
|
+
"status": "completed"
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
print(f"Updated export: {updated_export}")
|
|
108
|
+
|
|
109
|
+
# Test 6: Delete the created export
|
|
110
|
+
print("\n=== Deleting Export ===")
|
|
111
|
+
delete_result = export_service.delete_export(
|
|
112
|
+
dataset_id=dataset.id,
|
|
113
|
+
export_id=new_export.id
|
|
114
|
+
)
|
|
115
|
+
print(f"Delete result: {delete_result}")
|
|
116
|
+
|
|
117
|
+
# Test 7: Verify deletion
|
|
118
|
+
print("\n=== Verifying Deletion ===")
|
|
119
|
+
try:
|
|
120
|
+
deleted_export = export_service.get_export(
|
|
121
|
+
dataset_id=dataset.id,
|
|
122
|
+
export_id=new_export.id
|
|
123
|
+
)
|
|
124
|
+
print(f"Export still exists: {deleted_export}")
|
|
125
|
+
except Exception as e:
|
|
126
|
+
print(f"Export successfully deleted (expected error): {e}")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if __name__ == "__main__":
|
|
130
|
+
test_export_service()
|