superb-ai-onprem 0.1.6__py3-none-any.whl → 0.3.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 +26 -3
- spb_onprem/_version.py +2 -2
- spb_onprem/activities/__init__.py +0 -0
- spb_onprem/activities/entities/__init__.py +10 -0
- spb_onprem/activities/entities/activity.py +39 -0
- spb_onprem/activities/entities/activity_history.py +31 -0
- spb_onprem/activities/params/__init__.py +23 -0
- spb_onprem/activities/params/activities.py +53 -0
- spb_onprem/activities/params/activity.py +42 -0
- spb_onprem/activities/params/create_activity.py +80 -0
- spb_onprem/activities/params/delete_activity.py +23 -0
- spb_onprem/activities/params/start_activity.py +59 -0
- spb_onprem/activities/params/update_activity.py +79 -0
- spb_onprem/activities/params/update_activity_history.py +54 -0
- spb_onprem/activities/queries.py +226 -0
- spb_onprem/activities/service.py +315 -0
- spb_onprem/base_model.py +2 -3
- spb_onprem/data/enums/data_type.py +2 -1
- spb_onprem/entities.py +15 -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 +224 -0
- spb_onprem/searches.py +12 -0
- spb_onprem/slices/params/slices.py +1 -1
- {superb_ai_onprem-0.1.6.dist-info → superb_ai_onprem-0.3.0.dist-info}/METADATA +1 -1
- {superb_ai_onprem-0.1.6.dist-info → superb_ai_onprem-0.3.0.dist-info}/RECORD +48 -12
- {superb_ai_onprem-0.1.6.dist-info → superb_ai_onprem-0.3.0.dist-info}/top_level.txt +1 -0
- tests/__init__.py +1 -0
- tests/activities/__init__.py +1 -0
- tests/activities/real_test.py +66 -0
- tests/activities/test_params.py +67 -0
- tests/activities/test_service.py +139 -0
- 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.1.6.dist-info → superb_ai_onprem-0.3.0.dist-info}/WHEEL +0 -0
- {superb_ai_onprem-0.1.6.dist-info → superb_ai_onprem-0.3.0.dist-info}/licenses/LICENSE +0 -0
spb_onprem/searches.py
CHANGED
|
@@ -12,6 +12,14 @@ from .slices.params.slices import (
|
|
|
12
12
|
SlicesFilterOptions,
|
|
13
13
|
SlicesFilter,
|
|
14
14
|
)
|
|
15
|
+
from .activities.params.activities import (
|
|
16
|
+
ActivitiesFilter,
|
|
17
|
+
ActivitiesFilterOptions,
|
|
18
|
+
)
|
|
19
|
+
from .exports.params.exports import (
|
|
20
|
+
ExportFilter,
|
|
21
|
+
ExportFilterOptions,
|
|
22
|
+
)
|
|
15
23
|
|
|
16
24
|
__all__ = [
|
|
17
25
|
"AnnotationFilter",
|
|
@@ -21,4 +29,8 @@ __all__ = [
|
|
|
21
29
|
"DatasetsFilterOptions",
|
|
22
30
|
"SlicesFilter",
|
|
23
31
|
"SlicesFilterOptions",
|
|
32
|
+
"ActivitiesFilter",
|
|
33
|
+
"ActivitiesFilterOptions",
|
|
34
|
+
"ExportFilter",
|
|
35
|
+
"ExportFilterOptions",
|
|
24
36
|
]
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
spb_onprem/__init__.py,sha256=
|
|
2
|
-
spb_onprem/_version.py,sha256=
|
|
3
|
-
spb_onprem/base_model.py,sha256=
|
|
1
|
+
spb_onprem/__init__.py,sha256=Iucr68oU5pQ3lhHlyI36HUaReA7gsanGuLCSAVZh7GI,1761
|
|
2
|
+
spb_onprem/_version.py,sha256=AGmG_Lx0-9ztFw_7d9mYbaYuC-2abxE1oXOUNAY29YY,511
|
|
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
|
+
spb_onprem/activities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
spb_onprem/activities/queries.py,sha256=iXuNVsJuw8yt9QNw8jEBXpUnGLD6LDC1v2_jBBgsmXs,5626
|
|
11
|
+
spb_onprem/activities/service.py,sha256=DI68qkDrvpm1NW_9BzWc37kSzyedfx4xLHqMeyDjp3A,10554
|
|
12
|
+
spb_onprem/activities/entities/__init__.py,sha256=lJXPl4UqurNscZOYBcCMfRZBp27JKbPEbab5iXtL3ME,237
|
|
13
|
+
spb_onprem/activities/entities/activity.py,sha256=xVJCrtU47ZG-ALRxsOauT0fIxc9EzqkTyw1xt5qVqJQ,1358
|
|
14
|
+
spb_onprem/activities/entities/activity_history.py,sha256=rOhUDifY4P6v5rs5eNcuPD9qKkw8fbMIEn-XCWjhqSY,1035
|
|
15
|
+
spb_onprem/activities/params/__init__.py,sha256=2LzVDj92nCneoETaXS7-KM12TRLKbJX2n-7KC1Z35w0,705
|
|
16
|
+
spb_onprem/activities/params/activities.py,sha256=FUsuPIinnk_4yjvcOox5rkmcZHcz2lk2UT1A2pRoOD0,1500
|
|
17
|
+
spb_onprem/activities/params/activity.py,sha256=I1xiXuMsTGL4qYWw_MoqU3ik3j1AKJVepvXETeU_TWI,1075
|
|
18
|
+
spb_onprem/activities/params/create_activity.py,sha256=Cg_7akHgdt447JcPh5yKd7pUu_6NtE_vLF0E9Xk9mxE,2548
|
|
19
|
+
spb_onprem/activities/params/delete_activity.py,sha256=LVWJjRLhEMyQhhzpdb0oSvE_RPjZ_PABsA61V9ZoVS4,532
|
|
20
|
+
spb_onprem/activities/params/start_activity.py,sha256=uBf78FYkjGkM5g8shIoMgz8qoCoujRMRiUdaBZGF7yI,1763
|
|
21
|
+
spb_onprem/activities/params/update_activity.py,sha256=pn2sO7_2Eni1Q3ai6BbnhEInbW__N2Azs6Rmok5vDSw,2461
|
|
22
|
+
spb_onprem/activities/params/update_activity_history.py,sha256=ScWxOG7pZ-7WcTzvJleZIm-TsZVTRkwNrTCyNDyyVSc,1620
|
|
9
23
|
spb_onprem/contents/__init__.py,sha256=9EfIMQxbJuUZVUqsTa3Ji-yDidFPQQB5gnJI4R01YWI,74
|
|
10
24
|
spb_onprem/contents/queries.py,sha256=tGMVH8ixv0CW5bJTWICCjWDM_oAN7jkfEQXdAJUVn4Q,851
|
|
11
25
|
spb_onprem/contents/service.py,sha256=KoPUffr_DEGOMIOwkue0rkidHMPfmAJG0KgJyXN6N_Y,3602
|
|
@@ -23,7 +37,7 @@ spb_onprem/data/entities/prediction.py,sha256=Eb2ldNSezeYDnaLQOfC65XWoDGJ0snlvlc
|
|
|
23
37
|
spb_onprem/data/entities/scene.py,sha256=SJgr5UnGxktyaKjU8FYDaIQmsu7xSJftJOiCgq9uSmo,446
|
|
24
38
|
spb_onprem/data/enums/__init__.py,sha256=IJWaapwesyIiIjuAykZc5fXdMXK2_IiOBa7qNY5cCNk,213
|
|
25
39
|
spb_onprem/data/enums/data_meta_type.py,sha256=9rd12-7C1udbbIGvnuGURKmd5-lndtW7oWQAQwKSf_Q,335
|
|
26
|
-
spb_onprem/data/enums/data_type.py,sha256=
|
|
40
|
+
spb_onprem/data/enums/data_type.py,sha256=BXcmeuWL-y4yIAswI_zsYqH9ozEmgl6uSki7hgbOZ_g,197
|
|
27
41
|
spb_onprem/data/enums/scene_type.py,sha256=ed8fAKfDk9PNG8YgYv3jI59IR9oCr_gkooexAe0448I,187
|
|
28
42
|
spb_onprem/data/params/__init__.py,sha256=IApFFU6t3lHclvbivLSFdUxhrj1BjO50c3OMG6zP2iY,1311
|
|
29
43
|
spb_onprem/data/params/create_data.py,sha256=8DOfbEchf9GSybiYY1cZoNzNYwILokoAkxXRFybJUAU,2038
|
|
@@ -53,6 +67,17 @@ spb_onprem/datasets/params/create_dataset.py,sha256=YGhLvY4arthjZwKQ28HLv7ch0Gd2
|
|
|
53
67
|
spb_onprem/datasets/params/dataset.py,sha256=WTOUl5M5cc6rtTwhLw_z31Cs209LkBq8Ja4LJGzrmGE,668
|
|
54
68
|
spb_onprem/datasets/params/datasets.py,sha256=Hx4YlLxfb-Qwi4Y5AFl5pyyjupvuoVcCtxLPGjIV7UY,1580
|
|
55
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=xlb6QrzoaZYR5ngUEwKcsjp1IBucubPyN9NGhHGF3QM,6992
|
|
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
|
|
56
81
|
spb_onprem/slices/__init__.py,sha256=xgpNGYzqgwQ8C-Bgw9AZWMAgBW38UU-U4Wube8hkodI,69
|
|
57
82
|
spb_onprem/slices/queries.py,sha256=dl_q6Uc2_oeuItgSD6gUL7a3H5VrOW9Ig5Epte7sl78,2732
|
|
58
83
|
spb_onprem/slices/service.py,sha256=byhB9CdxNKV7uLIiL9yI674UVSlgaAwLaYoGQGBCawE,4988
|
|
@@ -62,13 +87,24 @@ spb_onprem/slices/params/__init__.py,sha256=dEUDlOK-iw3Sx7gpkDMnwMqTFE16-856ZdbY
|
|
|
62
87
|
spb_onprem/slices/params/create_slice.py,sha256=qUpX60A72Uht0SzN7b2-QSKvd_MSEV5T9kYIVk_td8A,1009
|
|
63
88
|
spb_onprem/slices/params/delete_slice.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
64
89
|
spb_onprem/slices/params/slice.py,sha256=R8U_RadZLWPeQu6ZWGIvXH6Dxi4ikzoHyDKWGewmUjw,1035
|
|
65
|
-
spb_onprem/slices/params/slices.py,sha256=
|
|
90
|
+
spb_onprem/slices/params/slices.py,sha256=SIe_JfsFb8ULwpRYsQkAO3aIWqqarp3m6uePmUj10tw,1935
|
|
66
91
|
spb_onprem/slices/params/update_slice.py,sha256=kryOmCnRTQ_OU0qDKgugppLrpeUpuLwmn_87M5zKqIA,1209
|
|
67
92
|
spb_onprem/users/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
93
|
spb_onprem/users/entities/__init__.py,sha256=X8HZsCTlQnuPszok3AwI-i7bsQi0Ehul5L_2jZaol5E,57
|
|
69
94
|
spb_onprem/users/entities/auth.py,sha256=_KP-7yUErBxhJMm-dE3ObprPEG6e0JI2qNg6g8aK1qM,3371
|
|
70
|
-
superb_ai_onprem-0.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
95
|
+
superb_ai_onprem-0.3.0.dist-info/licenses/LICENSE,sha256=CdinbFiHKGkGl6cPde6WgXhMuzyUXEG6tzy2-7udZ8o,1066
|
|
96
|
+
tests/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
|
|
97
|
+
tests/activities/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
|
|
98
|
+
tests/activities/real_test.py,sha256=0gQHg7rIEuZndGZyNHMWSD5nUZPMsUGigfCjWFxMthQ,1786
|
|
99
|
+
tests/activities/test_params.py,sha256=L3mcnrN2c8dT0AVTjnGedu6LHF3eZ4sSDzz8eaMHJmg,2369
|
|
100
|
+
tests/activities/test_service.py,sha256=AbWFwjaUjQRs5oDZ2ba0C23XJxCqsFNrxH1LamMtWmU,4698
|
|
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.0.dist-info/METADATA,sha256=re2B_sc7Tx1NXJi3WebSt9yEiSLcie3txLgW3HQoY2A,5817
|
|
108
|
+
superb_ai_onprem-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
109
|
+
superb_ai_onprem-0.3.0.dist-info/top_level.txt,sha256=LbqU6FjWKaxO7FPS5-71e3OIS8VgBi5VrtQMWFOW25Q,17
|
|
110
|
+
superb_ai_onprem-0.3.0.dist-info/RECORD,,
|
tests/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from spb_onprem import (
|
|
2
|
+
DatasetService,
|
|
3
|
+
Dataset,
|
|
4
|
+
ActivityService,
|
|
5
|
+
Activity,
|
|
6
|
+
ActivityHistory,
|
|
7
|
+
ActivityStatus,
|
|
8
|
+
ActivitySchema,
|
|
9
|
+
SchemaType,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_activity_service():
|
|
14
|
+
dataset_service = DatasetService()
|
|
15
|
+
dataset = dataset_service.get_dataset(
|
|
16
|
+
dataset_id="01JPM6NR1APMBXJNC0YW72S1FN"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
print(dataset)
|
|
20
|
+
|
|
21
|
+
activity_service = ActivityService()
|
|
22
|
+
cursor = None
|
|
23
|
+
assign_data_slice_activity = None
|
|
24
|
+
while True:
|
|
25
|
+
(described_activities, cursor, _) = activity_service.get_activities(
|
|
26
|
+
dataset_id=dataset.id,
|
|
27
|
+
cursor=cursor,
|
|
28
|
+
length=50
|
|
29
|
+
)
|
|
30
|
+
for activity in described_activities:
|
|
31
|
+
if activity.activity_type == "ASSIGN_DATA_TO_SLICE":
|
|
32
|
+
assign_data_slice_activity = activity
|
|
33
|
+
break
|
|
34
|
+
if cursor is None:
|
|
35
|
+
break
|
|
36
|
+
|
|
37
|
+
print(assign_data_slice_activity.parameter_schema)
|
|
38
|
+
|
|
39
|
+
activity_history = activity_service.start_activity(
|
|
40
|
+
dataset_id=dataset.id,
|
|
41
|
+
activity_id=assign_data_slice_activity.id,
|
|
42
|
+
parameters={
|
|
43
|
+
"dataset_id": dataset.id,
|
|
44
|
+
"slice_name": "sdk_test_slice",
|
|
45
|
+
"slice_description": "sdk_test_slice_description",
|
|
46
|
+
"filter": {
|
|
47
|
+
"must": {
|
|
48
|
+
"keyContains": "validation_v5/87d37e96-0bab3a63.jpg"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"filter_type": "DATA",
|
|
52
|
+
"is_new_slice": True,
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
print(activity_history)
|
|
56
|
+
|
|
57
|
+
activity_service.update_activity_history_status(
|
|
58
|
+
activity_history_id=activity_history.id,
|
|
59
|
+
status=ActivityStatus.FAILED,
|
|
60
|
+
meta={
|
|
61
|
+
"sdk_test": "sdk_test_value"
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if __name__ == "__main__":
|
|
66
|
+
test_activity_service()
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from spb_onprem.activities.params.update_activity_history import update_activity_history_params
|
|
3
|
+
from spb_onprem.activities.entities import ActivityStatus
|
|
4
|
+
from spb_onprem.exceptions import BadParameterError
|
|
5
|
+
from spb_onprem.base_types import Undefined
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestUpdateActivityHistoryParams:
|
|
9
|
+
def test_update_activity_history_params_with_status(self):
|
|
10
|
+
# Given
|
|
11
|
+
activity_history_id = "test_history_id"
|
|
12
|
+
status = ActivityStatus.SUCCESS
|
|
13
|
+
meta = {"key": "value"}
|
|
14
|
+
|
|
15
|
+
# When
|
|
16
|
+
params = update_activity_history_params(
|
|
17
|
+
activity_history_id=activity_history_id,
|
|
18
|
+
status=status,
|
|
19
|
+
meta=meta
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# Then
|
|
23
|
+
assert params["activity_history_id"] == activity_history_id
|
|
24
|
+
assert params["status"] == status
|
|
25
|
+
assert params["meta"] == meta
|
|
26
|
+
assert "progress" not in params
|
|
27
|
+
|
|
28
|
+
def test_update_activity_history_params_with_progress(self):
|
|
29
|
+
# Given
|
|
30
|
+
activity_history_id = "test_history_id"
|
|
31
|
+
progress = {"current": 50, "total": 100}
|
|
32
|
+
|
|
33
|
+
# When
|
|
34
|
+
params = update_activity_history_params(
|
|
35
|
+
activity_history_id=activity_history_id,
|
|
36
|
+
progress=progress
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# Then
|
|
40
|
+
assert params["activity_history_id"] == activity_history_id
|
|
41
|
+
assert params["progress"] == progress
|
|
42
|
+
assert "status" not in params
|
|
43
|
+
assert "meta" not in params
|
|
44
|
+
|
|
45
|
+
def test_update_activity_history_params_without_required_fields(self):
|
|
46
|
+
# Given
|
|
47
|
+
activity_history_id = None
|
|
48
|
+
|
|
49
|
+
# When/Then
|
|
50
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
51
|
+
update_activity_history_params(
|
|
52
|
+
activity_history_id=activity_history_id
|
|
53
|
+
)
|
|
54
|
+
assert str(exc_info.value) == "Activity history ID is required"
|
|
55
|
+
|
|
56
|
+
def test_update_activity_history_params_without_status_or_progress(self):
|
|
57
|
+
# Given
|
|
58
|
+
activity_history_id = "test_history_id"
|
|
59
|
+
|
|
60
|
+
# When/Then
|
|
61
|
+
with pytest.raises(BadParameterError) as exc_info:
|
|
62
|
+
update_activity_history_params(
|
|
63
|
+
activity_history_id=activity_history_id,
|
|
64
|
+
status=Undefined,
|
|
65
|
+
progress=Undefined
|
|
66
|
+
)
|
|
67
|
+
assert str(exc_info.value) == "Either status or progress must be provided"
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from unittest.mock import MagicMock, patch
|
|
3
|
+
|
|
4
|
+
from spb_onprem.activities.service import ActivityService
|
|
5
|
+
from spb_onprem.activities.entities import Activity, ActivityHistory, ActivityStatus
|
|
6
|
+
from spb_onprem.base_types import Undefined
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.fixture
|
|
10
|
+
def activity_service():
|
|
11
|
+
return ActivityService()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TestActivityService:
|
|
15
|
+
def test_create_activity(self, activity_service):
|
|
16
|
+
# Given
|
|
17
|
+
mock_response = {
|
|
18
|
+
"createJob": {
|
|
19
|
+
"id": "test_id",
|
|
20
|
+
"type": "test_type",
|
|
21
|
+
"name": "test_name",
|
|
22
|
+
"description": "test_description"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
activity_service.request_gql = MagicMock(return_value=mock_response)
|
|
26
|
+
|
|
27
|
+
# When
|
|
28
|
+
activity = activity_service.create_activity(
|
|
29
|
+
activity_type="test_type",
|
|
30
|
+
name="test_name",
|
|
31
|
+
description="test_description"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Then
|
|
35
|
+
assert isinstance(activity, Activity)
|
|
36
|
+
assert activity.id == "test_id"
|
|
37
|
+
assert activity.type == "test_type"
|
|
38
|
+
assert activity.name == "test_name"
|
|
39
|
+
assert activity.description == "test_description"
|
|
40
|
+
|
|
41
|
+
def test_get_activities(self, activity_service):
|
|
42
|
+
# Given
|
|
43
|
+
mock_response = {
|
|
44
|
+
"jobs": {
|
|
45
|
+
"activities": [
|
|
46
|
+
{
|
|
47
|
+
"id": "test_id_1",
|
|
48
|
+
"type": "test_type",
|
|
49
|
+
"name": "test_name_1"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "test_id_2",
|
|
53
|
+
"type": "test_type",
|
|
54
|
+
"name": "test_name_2"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"next": "next_cursor",
|
|
58
|
+
"totalCount": 2
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
activity_service.request_gql = MagicMock(return_value=mock_response)
|
|
62
|
+
|
|
63
|
+
# When
|
|
64
|
+
activities, next_cursor, total_count = activity_service.get_activities(
|
|
65
|
+
dataset_id="test_dataset_id"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Then
|
|
69
|
+
assert len(activities) == 2
|
|
70
|
+
assert all(isinstance(activity, Activity) for activity in activities)
|
|
71
|
+
assert next_cursor == "next_cursor"
|
|
72
|
+
assert total_count == 2
|
|
73
|
+
|
|
74
|
+
def test_start_activity(self, activity_service):
|
|
75
|
+
# Given
|
|
76
|
+
mock_response = {
|
|
77
|
+
"startJob": {
|
|
78
|
+
"id": "test_history_id",
|
|
79
|
+
"jobId": "test_activity_id",
|
|
80
|
+
"status": ActivityStatus.RUNNING.value
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
activity_service.request_gql = MagicMock(return_value=mock_response)
|
|
84
|
+
|
|
85
|
+
# When
|
|
86
|
+
activity_history = activity_service.start_activity(
|
|
87
|
+
dataset_id="test_dataset_id",
|
|
88
|
+
activity_id="test_activity_id"
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
# Then
|
|
92
|
+
assert isinstance(activity_history, ActivityHistory)
|
|
93
|
+
assert activity_history.id == "test_history_id"
|
|
94
|
+
assert activity_history.activity_id == "test_activity_id"
|
|
95
|
+
assert activity_history.status == ActivityStatus.RUNNING
|
|
96
|
+
|
|
97
|
+
def test_update_activity_history_status(self, activity_service):
|
|
98
|
+
# Given
|
|
99
|
+
mock_response = {
|
|
100
|
+
"updateJobHistory": {
|
|
101
|
+
"id": "test_history_id",
|
|
102
|
+
"jobId": "test_activity_id",
|
|
103
|
+
"status": ActivityStatus.SUCCESS.value
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
activity_service.request_gql = MagicMock(return_value=mock_response)
|
|
107
|
+
|
|
108
|
+
# When
|
|
109
|
+
activity_history = activity_service.update_activity_history_status(
|
|
110
|
+
activity_history_id="test_history_id",
|
|
111
|
+
status=ActivityStatus.SUCCESS
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
# Then
|
|
115
|
+
assert isinstance(activity_history, ActivityHistory)
|
|
116
|
+
assert activity_history.id == "test_history_id"
|
|
117
|
+
assert activity_history.status == ActivityStatus.SUCCESS
|
|
118
|
+
|
|
119
|
+
def test_update_activity_history_progress(self, activity_service):
|
|
120
|
+
# Given
|
|
121
|
+
mock_response = {
|
|
122
|
+
"updateJobHistory": {
|
|
123
|
+
"id": "test_history_id",
|
|
124
|
+
"jobId": "test_activity_id",
|
|
125
|
+
"progress": {"current": 50, "total": 100}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
activity_service.request_gql = MagicMock(return_value=mock_response)
|
|
129
|
+
|
|
130
|
+
# When
|
|
131
|
+
activity_history = activity_service.update_activity_history_progress(
|
|
132
|
+
activity_history_id="test_history_id",
|
|
133
|
+
progress={"current": 50, "total": 100}
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
# Then
|
|
137
|
+
assert isinstance(activity_history, ActivityHistory)
|
|
138
|
+
assert activity_history.id == "test_history_id"
|
|
139
|
+
assert activity_history.progress == {"current": 50, "total": 100}
|
|
@@ -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()
|