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 CHANGED
@@ -8,6 +8,7 @@ from .datasets.service import DatasetService
8
8
  from .data.service import DataService
9
9
  from .slices.service import SliceService
10
10
  from .activities.service import ActivityService
11
+ from .exports.service import ExportService
11
12
 
12
13
  # Core Entities and Enums
13
14
  from .entities import (
@@ -22,6 +23,7 @@ from .entities import (
22
23
  Slice,
23
24
  Activity,
24
25
  ActivityHistory,
26
+ Export,
25
27
 
26
28
  # Enums
27
29
  DataType,
@@ -44,6 +46,8 @@ from .searches import (
44
46
  SlicesFilterOptions,
45
47
  ActivitiesFilter,
46
48
  ActivitiesFilterOptions,
49
+ ExportFilter,
50
+ ExportFilterOptions,
47
51
  )
48
52
 
49
53
  __all__ = (
@@ -52,6 +56,7 @@ __all__ = (
52
56
  "DataService",
53
57
  "SliceService",
54
58
  "ActivityService",
59
+ "ExportService",
55
60
 
56
61
  # Core Entities
57
62
  "Data",
@@ -64,7 +69,7 @@ __all__ = (
64
69
  "Slice",
65
70
  "Activity",
66
71
  "ActivityHistory",
67
-
72
+ "Export",
68
73
  # Enums
69
74
  "DataType",
70
75
  "SceneType",
@@ -84,4 +89,6 @@ __all__ = (
84
89
  "SlicesFilterOptions",
85
90
  "ActivitiesFilter",
86
91
  "ActivitiesFilterOptions",
92
+ "ExportFilter",
93
+ "ExportFilterOptions",
87
94
  )
spb_onprem/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.2.0'
21
- __version_tuple__ = version_tuple = (0, 2, 0)
20
+ __version__ = version = '0.3.1'
21
+ __version_tuple__ = version_tuple = (0, 3, 1)
@@ -6,4 +6,5 @@ class DataType(str, Enum):
6
6
  The type of the data.
7
7
  This is used to determine the type of the data.
8
8
  """
9
- SUPERB_IMAGE = "SUPERB_IMAGE"
9
+ SUPERB_IMAGE = "SUPERB_IMAGE"
10
+ MCAP = "MCAP"
spb_onprem/entities.py CHANGED
@@ -21,6 +21,7 @@ from .activities.entities import (
21
21
  ActivitySchema,
22
22
  SchemaType,
23
23
  )
24
+ from .exports.entities import Export
24
25
 
25
26
  __all__ = [
26
27
  # Core Entities
@@ -34,7 +35,8 @@ __all__ = [
34
35
  "Slice",
35
36
  "Activity",
36
37
  "ActivityHistory",
37
-
38
+ "Export",
39
+
38
40
  # Enums
39
41
  "DataType",
40
42
  "SceneType",
@@ -0,0 +1,9 @@
1
+ from .service import ExportService
2
+ from .entities import Export
3
+ from .params import ExportFilterOptions
4
+
5
+ __all__ = (
6
+ "ExportService",
7
+ "Export",
8
+ "ExportFilterOptions",
9
+ )
@@ -0,0 +1,7 @@
1
+ from .export import Export
2
+
3
+ __all__ = (
4
+ "Export",
5
+ "ExportStatus",
6
+ "ExportType",
7
+ )
@@ -0,0 +1,27 @@
1
+ from typing import Optional, Any
2
+ from spb_onprem.base_model import CustomBaseModel, Field
3
+ from spb_onprem.data.params import DataListFilter
4
+
5
+
6
+ class Export(CustomBaseModel):
7
+ """
8
+ The export entity.
9
+ """
10
+ id: str = Field(..., alias="id")
11
+ dataset_id: str = Field(..., alias="datasetId")
12
+
13
+ name: Optional[str] = Field(None, alias="name")
14
+ data_filter: Optional[DataListFilter] = Field(None, alias="dataFilter")
15
+ location: Optional[str] = Field(None, alias="location")
16
+
17
+ data_count: Optional[int] = Field(None, alias="dataCount")
18
+ annotation_count: Optional[int] = Field(None, alias="annotationCount")
19
+ frame_count: Optional[int] = Field(None, alias="frameCount")
20
+
21
+ meta: Optional[dict] = Field(None, alias="meta")
22
+
23
+ created_at: Optional[str] = Field(None, alias="createdAt")
24
+ created_by: Optional[str] = Field(None, alias="createdBy")
25
+ updated_at: Optional[str] = Field(None, alias="updatedAt")
26
+ updated_by: Optional[str] = Field(None, alias="updatedBy")
27
+ completed_at: Optional[str] = Field(None, alias="completedAt")
@@ -0,0 +1,19 @@
1
+ from .exports import (
2
+ ExportFilter,
3
+ ExportFilterOptions,
4
+ get_exports_params,
5
+ )
6
+ from .export import get_export_params
7
+ from .create_export import create_export_params
8
+ from .delete_export import delete_export_params
9
+ from .update_export import update_export_params
10
+
11
+ __all__ = (
12
+ "ExportFilter",
13
+ "ExportFilterOptions",
14
+ "get_exports_params",
15
+ "get_export_params",
16
+ "create_export_params",
17
+ "delete_export_params",
18
+ "update_export_params",
19
+ )
@@ -0,0 +1,85 @@
1
+ from typing import Union
2
+
3
+ from spb_onprem.base_types import Undefined, UndefinedType
4
+ from spb_onprem.exceptions import BadParameterError
5
+ from spb_onprem.data.params import DataListFilter
6
+
7
+
8
+ def create_export_params(
9
+ dataset_id: str,
10
+ location: Union[
11
+ UndefinedType,
12
+ str
13
+ ] = Undefined,
14
+ name: Union[
15
+ UndefinedType,
16
+ str
17
+ ] = Undefined,
18
+ data_filter: Union[
19
+ UndefinedType,
20
+ DataListFilter,
21
+ dict
22
+ ] = Undefined,
23
+ data_count: Union[
24
+ UndefinedType,
25
+ int
26
+ ] = Undefined,
27
+ frame_count: Union[
28
+ UndefinedType,
29
+ int
30
+ ] = Undefined,
31
+ annotation_count: Union[
32
+ UndefinedType,
33
+ int
34
+ ] = Undefined,
35
+ meta: Union[
36
+ UndefinedType,
37
+ dict
38
+ ] = Undefined,
39
+ ):
40
+ """Create parameters for export creation.
41
+
42
+ Args:
43
+ dataset_id (str): The ID of the dataset to create the export for.
44
+ location (Optional[str]): The location where the export will be stored.
45
+ name (Optional[str]): The name of the export.
46
+ data_filter (Optional[DataListFilter | dict]): The search filter of the data.
47
+ data_count (Optional[int]): The number of data items to export.
48
+ frame_count (Optional[int]): The number of frames to export.
49
+ annotation_count (Optional[int]): The number of annotations to export.
50
+ meta (Optional[dict]): The meta information for the export.
51
+
52
+ Returns:
53
+ dict: Parameters for export creation
54
+
55
+ Raises:
56
+ BadParameterError: If required parameters are missing
57
+ """
58
+ if dataset_id is None:
59
+ raise BadParameterError("Dataset ID is required")
60
+
61
+ params = {
62
+ "dataset_id": dataset_id,
63
+ }
64
+
65
+ if location is not Undefined:
66
+ params["location"] = location
67
+ if name is not Undefined:
68
+ params["name"] = name
69
+ if data_filter is not Undefined and data_filter is not None:
70
+ # Handle both DataListFilter objects and plain dicts
71
+ if isinstance(data_filter, DataListFilter):
72
+ params["data_filter"] = data_filter.model_dump(by_alias=True, exclude_unset=True)
73
+ else:
74
+ # Assume it's a dict and use it directly
75
+ params["data_filter"] = data_filter
76
+ if data_count is not Undefined:
77
+ params["data_count"] = data_count
78
+ if frame_count is not Undefined:
79
+ params["frame_count"] = frame_count
80
+ if annotation_count is not Undefined:
81
+ params["annotation_count"] = annotation_count
82
+ if meta is not Undefined:
83
+ params["meta"] = meta
84
+
85
+ return params
@@ -0,0 +1,30 @@
1
+ from spb_onprem.exceptions import BadParameterError
2
+
3
+
4
+ def delete_export_params(
5
+ dataset_id: str,
6
+ export_id: str,
7
+ ):
8
+ """Create parameters for export deletion.
9
+
10
+ Args:
11
+ export_id (str): The ID of the export to delete.
12
+
13
+ Returns:
14
+ dict: Parameters for export deletion
15
+
16
+ Raises:
17
+ BadParameterError: If export_id is missing
18
+ """
19
+ if dataset_id is None:
20
+ raise BadParameterError("Dataset ID is required")
21
+
22
+ if export_id is None:
23
+ raise BadParameterError("Export ID is required")
24
+
25
+ params = {
26
+ "dataset_id": dataset_id,
27
+ "export_id": export_id,
28
+ }
29
+
30
+ return params
@@ -0,0 +1,30 @@
1
+ from spb_onprem.exceptions import BadParameterError
2
+
3
+
4
+ def get_export_params(
5
+ dataset_id: str,
6
+ export_id: str,
7
+ ):
8
+ """Create parameters for getting an export.
9
+
10
+ Args:
11
+ export_id (str): The ID of the export to get.
12
+ dataset_id (Optional[str]): The ID of the dataset to get the export for.
13
+ slice_id (Optional[str]): The ID of the slice to get the export for.
14
+
15
+ Returns:
16
+ dict: Parameters for getting an export
17
+
18
+ Raises:
19
+ BadParameterError: If export_id is missing
20
+ """
21
+ if dataset_id is None:
22
+ raise BadParameterError("Dataset ID is required")
23
+
24
+ if export_id is None:
25
+ raise BadParameterError("Export ID is required")
26
+
27
+ return {
28
+ "dataset_id": dataset_id,
29
+ "export_id": export_id
30
+ }
@@ -0,0 +1,74 @@
1
+ from typing import Optional, List, Union
2
+ from spb_onprem.base_model import CustomBaseModel, Field
3
+ from spb_onprem.base_types import Undefined, UndefinedType
4
+ from spb_onprem.exceptions import BadParameterError
5
+
6
+
7
+ class ExportFilterOptions(CustomBaseModel):
8
+ """Options for filtering exports.
9
+
10
+ Attributes:
11
+ id_in: Filter exports by list of IDs
12
+ name_contains: Filter exports by name containing this string
13
+ name: Filter exports by exact name match
14
+ location_contains: Filter exports by location containing this string
15
+ location: Filter exports by exact location match
16
+ """
17
+ id_in: Optional[List[str]] = Field(None, alias="idIn")
18
+ name_contains: Optional[str] = Field(None, alias="nameContains")
19
+ name: Optional[str] = Field(None, alias="name")
20
+ location_contains: Optional[str] = Field(None, alias="locationContains")
21
+ location: Optional[str] = Field(None, alias="location")
22
+
23
+
24
+ class ExportFilter(CustomBaseModel):
25
+ """Filter criteria for export queries.
26
+
27
+ Attributes:
28
+ must_filter: Conditions that must be met
29
+ not_filter: Conditions that must not be met
30
+ """
31
+ must_filter: Optional[ExportFilterOptions] = Field(None, alias="must")
32
+ not_filter: Optional[ExportFilterOptions] = Field(None, alias="not")
33
+
34
+
35
+ def get_exports_params(
36
+ dataset_id: str,
37
+ export_filter: Union[
38
+ UndefinedType,
39
+ ExportFilter
40
+ ] = Undefined,
41
+ cursor: Union[
42
+ UndefinedType,
43
+ str
44
+ ] = Undefined,
45
+ length: int = 10,
46
+ ):
47
+ """Create parameters for getting exports.
48
+
49
+ Args:
50
+ dataset_id (str): The ID of the dataset to get exports for.
51
+ export_filter (Optional[ExportFilter]): The filter to apply to the exports.
52
+ cursor (Optional[str]): The cursor to use for pagination.
53
+ length (int): The number of exports to get.
54
+
55
+ Returns:
56
+ dict: Parameters for getting exports
57
+
58
+ Raises:
59
+ BadParameterError: If dataset_id is missing
60
+ """
61
+ if dataset_id is None:
62
+ raise BadParameterError("Dataset ID is required")
63
+
64
+ params = {
65
+ "dataset_id": dataset_id,
66
+ "length": length
67
+ }
68
+
69
+ if export_filter is not Undefined and export_filter is not None:
70
+ params["filter"] = export_filter.model_dump(by_alias=True, exclude_unset=True)
71
+ if cursor is not Undefined:
72
+ params["cursor"] = cursor
73
+
74
+ return params
@@ -0,0 +1,98 @@
1
+ from typing import Union
2
+ from datetime import datetime
3
+
4
+ from spb_onprem.base_types import Undefined, UndefinedType
5
+ from spb_onprem.exceptions import BadParameterError
6
+ from spb_onprem.data.params import DataListFilter
7
+
8
+
9
+ def update_export_params(
10
+ dataset_id: str,
11
+ export_id: str,
12
+ location: Union[
13
+ UndefinedType,
14
+ str
15
+ ] = Undefined,
16
+ name: Union[
17
+ UndefinedType,
18
+ str
19
+ ] = Undefined,
20
+ data_filter: Union[
21
+ UndefinedType,
22
+ DataListFilter,
23
+ dict
24
+ ] = Undefined,
25
+ data_count: Union[
26
+ UndefinedType,
27
+ int
28
+ ] = Undefined,
29
+ frame_count: Union[
30
+ UndefinedType,
31
+ int
32
+ ] = Undefined,
33
+ annotation_count: Union[
34
+ UndefinedType,
35
+ int
36
+ ] = Undefined,
37
+ meta: Union[
38
+ UndefinedType,
39
+ dict
40
+ ] = Undefined,
41
+ completed_at: Union[
42
+ UndefinedType,
43
+ datetime
44
+ ] = Undefined,
45
+ ):
46
+ """Create parameters for export update.
47
+
48
+ Args:
49
+ dataset_id (str): The ID of the dataset to update the export for.
50
+ export_id (str): The ID of the export to update.
51
+ location (Optional[str]): The location where the export will be stored.
52
+ name (Optional[str]): The name of the export.
53
+ data_filter (Optional[DataListFilter | dict]): The search filter of the data.
54
+ data_count (Optional[int]): The number of data items to export.
55
+ frame_count (Optional[int]): The number of frames to export.
56
+ annotation_count (Optional[int]): The number of annotations to export.
57
+ meta (Optional[dict]): The meta information for the export.
58
+ completed_at (Optional[datetime]): The completed time of the export.
59
+
60
+ Returns:
61
+ dict: Parameters for export update
62
+
63
+ Raises:
64
+ BadParameterError: If required parameters are missing
65
+ """
66
+ if dataset_id is None:
67
+ raise BadParameterError("Dataset ID is required")
68
+ if export_id is None:
69
+ raise BadParameterError("Export ID is required")
70
+
71
+ params = {
72
+ "dataset_id": dataset_id,
73
+ "export_id": export_id,
74
+ }
75
+
76
+ if location is not Undefined:
77
+ params["location"] = location
78
+ if name is not Undefined:
79
+ params["name"] = name
80
+ if data_filter is not Undefined and data_filter is not None:
81
+ # Handle both DataListFilter objects and plain dicts
82
+ if isinstance(data_filter, DataListFilter):
83
+ params["data_filter"] = data_filter.model_dump(by_alias=True, exclude_unset=True)
84
+ else:
85
+ # Assume it's a dict and use it directly
86
+ params["data_filter"] = data_filter
87
+ if data_count is not Undefined:
88
+ params["data_count"] = data_count
89
+ if frame_count is not Undefined:
90
+ params["frame_count"] = frame_count
91
+ if annotation_count is not Undefined:
92
+ params["annotation_count"] = annotation_count
93
+ if meta is not Undefined:
94
+ params["meta"] = meta
95
+ if completed_at is not Undefined:
96
+ params["completed_at"] = completed_at
97
+
98
+ return params
@@ -0,0 +1,158 @@
1
+ from spb_onprem.exports.params import (
2
+ get_exports_params,
3
+ get_export_params,
4
+ create_export_params,
5
+ delete_export_params,
6
+ update_export_params,
7
+ )
8
+
9
+
10
+ class Schemas:
11
+ """Schemas for exports queries
12
+ """
13
+ EXPORT = '''
14
+ id
15
+ datasetId
16
+ name
17
+ dataFilter
18
+ location
19
+ dataCount
20
+ annotationCount
21
+ frameCount
22
+ meta
23
+ createdAt
24
+ createdBy
25
+ updatedAt
26
+ updatedBy
27
+ completedAt
28
+ '''
29
+
30
+ EXPORT_PAGE = f'''
31
+ exports {{
32
+ {EXPORT}
33
+ }}
34
+ next
35
+ totalCount
36
+ '''
37
+
38
+
39
+ class Queries:
40
+ '''
41
+ Queries for exports
42
+ '''
43
+
44
+ GET_EXPORTS = {
45
+ "name": "exports",
46
+ "query": f'''
47
+ query exports(
48
+ $dataset_id: ID!,
49
+ $filter: ExportFilter,
50
+ $cursor: String,
51
+ $length: Int
52
+ $orderBy: ExportOrderBy
53
+ ) {{
54
+ exports(
55
+ datasetId: $dataset_id,
56
+ filter: $filter,
57
+ cursor: $cursor,
58
+ length: $length,
59
+ orderBy: $orderBy
60
+ ) {{
61
+ {Schemas.EXPORT_PAGE}
62
+ }}
63
+ }}
64
+ ''',
65
+ "variables": get_exports_params
66
+ }
67
+
68
+ GET_EXPORT = {
69
+ "name": "export",
70
+ "query": f'''
71
+ query export(
72
+ $dataset_id: ID!,
73
+ $export_id: ID!
74
+ ) {{
75
+ export(datasetId: $dataset_id, id: $export_id) {{
76
+ {Schemas.EXPORT}
77
+ }}
78
+ }}
79
+ ''',
80
+ "variables": get_export_params
81
+ }
82
+
83
+ CREATE_EXPORT = {
84
+ "name": "createExport",
85
+ "query": f'''
86
+ mutation createExport(
87
+ $dataset_id: ID!,
88
+ $location: String,
89
+ $name: String,
90
+ $data_filter: JSONObject,
91
+ $data_count: Int,
92
+ $frame_count: Int,
93
+ $annotation_count: Int,
94
+ $meta: JSONObject
95
+ ) {{
96
+ createExport(
97
+ datasetId: $dataset_id,
98
+ location: $location,
99
+ name: $name,
100
+ dataFilter: $data_filter,
101
+ dataCount: $data_count,
102
+ frameCount: $frame_count,
103
+ annotationCount: $annotation_count,
104
+ meta: $meta
105
+ ) {{
106
+ {Schemas.EXPORT}
107
+ }}
108
+ }}
109
+ ''',
110
+ "variables": create_export_params
111
+ }
112
+
113
+ UPDATE_EXPORT = {
114
+ "name": "updateExport",
115
+ "query": f'''
116
+ mutation updateExport(
117
+ $dataset_id: ID!,
118
+ $export_id: ID!,
119
+ $location: String,
120
+ $name: String,
121
+ $data_filter: JSONObject,
122
+ $data_count: Int,
123
+ $frame_count: Int,
124
+ $annotation_count: Int,
125
+ $meta: JSONObject,
126
+ $completed_at: DateTime
127
+ ) {{
128
+ updateExport(
129
+ datasetId: $dataset_id,
130
+ id: $export_id,
131
+ location: $location,
132
+ name: $name,
133
+ dataFilter: $data_filter,
134
+ dataCount: $data_count,
135
+ frameCount: $frame_count,
136
+ annotationCount: $annotation_count,
137
+ meta: $meta,
138
+ completedAt: $completed_at
139
+ ) {{
140
+ {Schemas.EXPORT}
141
+ }}
142
+ }}
143
+ ''',
144
+ "variables": update_export_params
145
+ }
146
+
147
+ DELETE_EXPORT = {
148
+ "name": "deleteExport",
149
+ "query": '''
150
+ mutation deleteExport(
151
+ $dataset_id: ID!,
152
+ $export_id: ID!
153
+ ) {
154
+ deleteExport(datasetId: $dataset_id, id: $export_id)
155
+ }
156
+ ''',
157
+ "variables": delete_export_params
158
+ }