superb-ai-onprem 0.1.6__py3-none-any.whl → 0.2.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 (30) hide show
  1. spb_onprem/__init__.py +18 -2
  2. spb_onprem/_version.py +2 -2
  3. spb_onprem/activities/__init__.py +0 -0
  4. spb_onprem/activities/entities/__init__.py +10 -0
  5. spb_onprem/activities/entities/activity.py +39 -0
  6. spb_onprem/activities/entities/activity_history.py +31 -0
  7. spb_onprem/activities/params/__init__.py +23 -0
  8. spb_onprem/activities/params/activities.py +53 -0
  9. spb_onprem/activities/params/activity.py +42 -0
  10. spb_onprem/activities/params/create_activity.py +80 -0
  11. spb_onprem/activities/params/delete_activity.py +23 -0
  12. spb_onprem/activities/params/start_activity.py +59 -0
  13. spb_onprem/activities/params/update_activity.py +79 -0
  14. spb_onprem/activities/params/update_activity_history.py +54 -0
  15. spb_onprem/activities/queries.py +226 -0
  16. spb_onprem/activities/service.py +315 -0
  17. spb_onprem/base_model.py +2 -3
  18. spb_onprem/entities.py +12 -0
  19. spb_onprem/searches.py +6 -0
  20. spb_onprem/slices/params/slices.py +1 -1
  21. {superb_ai_onprem-0.1.6.dist-info → superb_ai_onprem-0.2.0.dist-info}/METADATA +1 -1
  22. {superb_ai_onprem-0.1.6.dist-info → superb_ai_onprem-0.2.0.dist-info}/RECORD +30 -11
  23. {superb_ai_onprem-0.1.6.dist-info → superb_ai_onprem-0.2.0.dist-info}/top_level.txt +1 -0
  24. tests/__init__.py +1 -0
  25. tests/activities/__init__.py +1 -0
  26. tests/activities/real_test.py +66 -0
  27. tests/activities/test_params.py +67 -0
  28. tests/activities/test_service.py +139 -0
  29. {superb_ai_onprem-0.1.6.dist-info → superb_ai_onprem-0.2.0.dist-info}/WHEEL +0 -0
  30. {superb_ai_onprem-0.1.6.dist-info → superb_ai_onprem-0.2.0.dist-info}/licenses/LICENSE +0 -0
spb_onprem/__init__.py CHANGED
@@ -7,6 +7,7 @@ except ImportError:
7
7
  from .datasets.service import DatasetService
8
8
  from .data.service import DataService
9
9
  from .slices.service import SliceService
10
+ from .activities.service import ActivityService
10
11
 
11
12
  # Core Entities and Enums
12
13
  from .entities import (
@@ -19,12 +20,17 @@ from .entities import (
19
20
  DataMeta,
20
21
  Dataset,
21
22
  Slice,
22
-
23
+ Activity,
24
+ ActivityHistory,
25
+
23
26
  # Enums
24
27
  DataType,
25
28
  SceneType,
26
29
  DataMetaTypes,
27
30
  DataMetaValue,
31
+ ActivityStatus,
32
+ ActivitySchema,
33
+ SchemaType,
28
34
  )
29
35
 
30
36
  # Filters
@@ -36,6 +42,8 @@ from .searches import (
36
42
  DatasetsFilterOptions,
37
43
  SlicesFilter,
38
44
  SlicesFilterOptions,
45
+ ActivitiesFilter,
46
+ ActivitiesFilterOptions,
39
47
  )
40
48
 
41
49
  __all__ = (
@@ -43,7 +51,8 @@ __all__ = (
43
51
  "DatasetService",
44
52
  "DataService",
45
53
  "SliceService",
46
-
54
+ "ActivityService",
55
+
47
56
  # Core Entities
48
57
  "Data",
49
58
  "Scene",
@@ -53,12 +62,17 @@ __all__ = (
53
62
  "DataMeta",
54
63
  "Dataset",
55
64
  "Slice",
65
+ "Activity",
66
+ "ActivityHistory",
56
67
 
57
68
  # Enums
58
69
  "DataType",
59
70
  "SceneType",
60
71
  "DataMetaTypes",
61
72
  "DataMetaValue",
73
+ "ActivityStatus",
74
+ "ActivitySchema",
75
+ "SchemaType",
62
76
 
63
77
  # Filters
64
78
  "AnnotationFilter",
@@ -68,4 +82,6 @@ __all__ = (
68
82
  "DatasetsFilterOptions",
69
83
  "SlicesFilter",
70
84
  "SlicesFilterOptions",
85
+ "ActivitiesFilter",
86
+ "ActivitiesFilterOptions",
71
87
  )
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.1.6'
21
- __version_tuple__ = version_tuple = (0, 1, 6)
20
+ __version__ = version = '0.2.0'
21
+ __version_tuple__ = version_tuple = (0, 2, 0)
File without changes
@@ -0,0 +1,10 @@
1
+ from .activity import Activity, ActivitySchema, SchemaType
2
+ from .activity_history import ActivityHistory, ActivityStatus
3
+
4
+ __all__ = (
5
+ "Activity",
6
+ "ActivityHistory",
7
+ "ActivityStatus",
8
+ "SchemaType",
9
+ "ActivitySchema",
10
+ )
@@ -0,0 +1,39 @@
1
+ from typing import Optional, List, Any
2
+ from enum import Enum
3
+ from spb_onprem.base_model import CustomBaseModel, Field
4
+
5
+
6
+ class SchemaType(str, Enum):
7
+ STRING = "String"
8
+ NUMBER = "Number"
9
+ BOOLEAN = "Boolean"
10
+ JSON_OBJECT = "JSONObject"
11
+ DATETIME = "DateTime"
12
+
13
+
14
+ class ActivitySchema(CustomBaseModel):
15
+ key: Optional[str] = None
16
+ schema_type: Optional[SchemaType] = None
17
+ required: Optional[bool] = None
18
+ default: Optional[Any] = None
19
+
20
+
21
+ class Activity(CustomBaseModel):
22
+ id: Optional[str] = Field(None, alias="id")
23
+ dataset_id: Optional[str] = Field(None, alias="datasetId")
24
+
25
+ name: Optional[str] = Field(None, alias="name")
26
+ description: Optional[str] = Field(None, alias="description")
27
+ activity_type: Optional[str] = Field(None, alias="type")
28
+
29
+ progress_schema: Optional[List[ActivitySchema]] = Field(None, alias="progressSchema")
30
+ parameter_schema: Optional[List[ActivitySchema]] = Field(None, alias="parameterSchema")
31
+
32
+ settings: Optional[dict] = Field(None, alias="settings")
33
+
34
+ meta: Optional[dict] = Field(None, alias="meta")
35
+
36
+ created_at: Optional[str] = Field(None, alias="createdAt")
37
+ created_by: Optional[str] = Field(None, alias="createdBy")
38
+ updated_at: Optional[str] = Field(None, alias="updatedAt")
39
+ updated_by: Optional[str] = Field(None, alias="updatedBy")
@@ -0,0 +1,31 @@
1
+ from typing import Optional, Any
2
+ from enum import Enum
3
+ from spb_onprem.base_model import CustomBaseModel, Field
4
+
5
+
6
+ class ActivityStatus(str, Enum):
7
+ PENDING = "PENDING"
8
+ RUNNING = "RUNNING"
9
+ SUCCESS = "SUCCESS"
10
+ FAILED = "FAILED"
11
+ CANCELLED = "CANCELLED"
12
+
13
+
14
+ class ActivityHistory(CustomBaseModel):
15
+ """
16
+ The activity history.
17
+ """
18
+ id: Optional[str] = Field(None, alias="id")
19
+ dataset_id: Optional[str] = Field(None, alias="datasetId")
20
+ activity_id: Optional[str] = Field(None, alias="jobId")
21
+ status: Optional[ActivityStatus] = Field(None, alias="status")
22
+
23
+ parameters: Optional[Any] = Field(None, alias="parameters")
24
+ progress: Optional[Any] = Field(None, alias="progress")
25
+
26
+ meta: Optional[dict] = Field(None, alias="meta")
27
+
28
+ created_at: Optional[str] = Field(None, alias="createdAt")
29
+ created_by: Optional[str] = Field(None, alias="createdBy")
30
+ updated_at: Optional[str] = Field(None, alias="updatedAt")
31
+ updated_by: Optional[str] = Field(None, alias="updatedBy")
@@ -0,0 +1,23 @@
1
+ from .activities import (
2
+ ActivitiesFilter,
3
+ ActivitiesFilterOptions,
4
+ get_activities_params,
5
+ )
6
+ from .activity import get_activity_params
7
+ from .create_activity import create_activity_params
8
+ from .update_activity import update_activity_params
9
+ from .delete_activity import delete_activity_params
10
+ from .start_activity import start_activity_params
11
+ from .update_activity_history import update_activity_history_params
12
+
13
+ __all__ = (
14
+ "ActivitiesFilter",
15
+ "ActivitiesFilterOptions",
16
+ "get_activities_params",
17
+ "get_activity_params",
18
+ "create_activity_params",
19
+ "update_activity_params",
20
+ "delete_activity_params",
21
+ "start_activity_params",
22
+ "update_activity_history_params",
23
+ )
@@ -0,0 +1,53 @@
1
+ from typing import (
2
+ Union,
3
+ Optional,
4
+ List,
5
+ )
6
+
7
+ from spb_onprem.base_model import CustomBaseModel, Field
8
+ from spb_onprem.base_types import Undefined, UndefinedType
9
+
10
+
11
+ class ActivitiesFilterOptions(CustomBaseModel):
12
+ """Options for filtering activities.
13
+
14
+ """
15
+ id_in: Optional[List[str]] = Field(None, alias="idIn")
16
+ name_contains: Optional[str] = Field(None, alias="nameContains")
17
+ dataset_id_in: Optional[List[str]] = Field(None, alias="datasetIdIn")
18
+ type_in: Optional[List[str]] = Field(None, alias="typeIn")
19
+
20
+
21
+ class ActivitiesFilter(CustomBaseModel):
22
+ """Filter criteria for activity queries.
23
+
24
+ Attributes:
25
+ must_filter: Conditions that must be met
26
+ not_filter: Conditions that must not be met
27
+ """
28
+ must_filter: Optional[ActivitiesFilterOptions] = Field(None, alias="must")
29
+ not_filter: Optional[ActivitiesFilterOptions] = Field(None, alias="not")
30
+
31
+
32
+ def get_activities_params(
33
+ dataset_id: str,
34
+ activity_filter: Union[
35
+ UndefinedType,
36
+ ActivitiesFilter,
37
+ ] = Undefined,
38
+ cursor: Optional[str] = None,
39
+ length: Optional[int] = 10
40
+ ):
41
+ """Get the params for the activities query.
42
+
43
+ """
44
+ params = {
45
+ "datasetId": dataset_id,
46
+ "cursor": cursor,
47
+ "length": length,
48
+ }
49
+ if activity_filter is not Undefined and activity_filter is not None:
50
+ params["filter"] = activity_filter.model_dump(
51
+ by_alias=True, exclude_unset=True
52
+ )
53
+ return params
@@ -0,0 +1,42 @@
1
+ from typing import Union, Optional
2
+
3
+ from spb_onprem.base_types import Undefined, UndefinedType
4
+ from spb_onprem.exceptions import BadParameterError
5
+
6
+
7
+ def get_activity_params(
8
+ activity_id: Optional[str] = None,
9
+ activity_name: Optional[str] = None,
10
+ dataset_id: Union[
11
+ UndefinedType,
12
+ str
13
+ ] = Undefined,
14
+ ):
15
+ """Create parameters for getting an activity.
16
+
17
+ Args:
18
+ activity_id (str): The ID of the activity to get.
19
+ dataset_id (Optional[str]): The ID of the dataset to get the activity for.
20
+
21
+ Returns:
22
+ dict: Parameters for getting an activity
23
+
24
+ Raises:
25
+ BadParameterError: If activity_id is missing
26
+ """
27
+ if activity_id is None and activity_name is None:
28
+ raise BadParameterError("Activity ID or name is required")
29
+
30
+ params = {
31
+ }
32
+
33
+ if activity_id is not None:
34
+ params["id"] = activity_id
35
+
36
+ if activity_name is not None:
37
+ params["name"] = activity_name
38
+
39
+ if dataset_id is not Undefined:
40
+ params["datasetId"] = dataset_id
41
+
42
+ return params
@@ -0,0 +1,80 @@
1
+ from typing import Union, List
2
+
3
+ from spb_onprem.base_types import Undefined, UndefinedType
4
+ from spb_onprem.activities.entities import ActivitySchema
5
+ from spb_onprem.exceptions import BadParameterError
6
+
7
+ def create_activity_params(
8
+ activity_type: str,
9
+ name: str,
10
+ dataset_id: Union[
11
+ UndefinedType,
12
+ str
13
+ ] = Undefined,
14
+ description: Union[
15
+ UndefinedType,
16
+ str
17
+ ] = Undefined,
18
+ progress_schema: Union[
19
+ UndefinedType,
20
+ List[ActivitySchema]
21
+ ] = Undefined,
22
+ parameter_schema: Union[
23
+ UndefinedType,
24
+ List[ActivitySchema]
25
+ ] = Undefined,
26
+ settings: Union[
27
+ UndefinedType,
28
+ dict
29
+ ] = Undefined,
30
+ meta: Union[
31
+ UndefinedType,
32
+ dict
33
+ ] = Undefined,
34
+ ):
35
+ """Create parameters for activity creation.
36
+
37
+ Args:
38
+ activity_type (str): The type of the activity to create.
39
+ name (str): The name of the activity to create.
40
+ dataset_id (Optional[str]): The ID of the dataset to create the activity for.
41
+ description (Optional[str]): The description of the activity to create.
42
+ progress_schema (Optional[List[ActivitySchema]]): The progress schema of the activity to create.
43
+ parameter_schema (Optional[List[ActivitySchema]]): The parameter schema of the activity to create.
44
+ settings (Optional[dict]): The settings of the activity to create.
45
+ meta (Optional[dict]): The meta of the activity to create.
46
+
47
+ Returns:
48
+ dict: Parameters for activity creation
49
+
50
+ Raises:
51
+ BadParameterError: If activity_type is not provided
52
+ """
53
+ if activity_type is None:
54
+ raise BadParameterError("Activity type is required")
55
+ if name is None:
56
+ raise BadParameterError("Activity name is required")
57
+
58
+ params = {
59
+ "datasetId": None,
60
+ "name": name,
61
+ "description": None,
62
+ "progressSchema": None,
63
+ "parameterSchema": None,
64
+ "type": activity_type,
65
+ "settings": None,
66
+ "meta": None,
67
+ }
68
+ if dataset_id is not Undefined:
69
+ params["datasetId"] = dataset_id
70
+ if description is not Undefined:
71
+ params["description"] = description
72
+ if progress_schema is not Undefined:
73
+ params["progressSchema"] = progress_schema
74
+ if parameter_schema is not Undefined:
75
+ params["parameterSchema"] = parameter_schema
76
+ if settings is not Undefined:
77
+ params["settings"] = settings
78
+ if meta is not Undefined:
79
+ params["meta"] = meta
80
+ return params
@@ -0,0 +1,23 @@
1
+ from spb_onprem.exceptions import BadParameterError
2
+
3
+ def delete_activity_params(
4
+ activity_id: str,
5
+ ):
6
+ """Create parameters for activity deletion.
7
+
8
+ Args:
9
+ activity_id (str): The ID of the activity to delete.
10
+
11
+ Returns:
12
+ dict: Parameters for activity deletion
13
+
14
+ Raises:
15
+ BadParameterError: If activity_id is None
16
+ """
17
+ if activity_id is None:
18
+ raise BadParameterError("Activity ID is required")
19
+
20
+ params = {
21
+ "id": activity_id,
22
+ }
23
+ return params
@@ -0,0 +1,59 @@
1
+ from typing import Optional, Union
2
+
3
+ from spb_onprem.base_types import Undefined, UndefinedType
4
+ from spb_onprem.exceptions import BadParameterError
5
+
6
+
7
+ def start_activity_params(
8
+ dataset_id: str,
9
+ activity_id: Optional[str] = None,
10
+ activity_type: Optional[str] = None,
11
+ parameters: Union[
12
+ UndefinedType,
13
+ dict
14
+ ] = Undefined,
15
+ progress: Union[
16
+ UndefinedType,
17
+ dict
18
+ ] = Undefined,
19
+ meta: Union[
20
+ UndefinedType,
21
+ dict
22
+ ] = Undefined,
23
+ ) -> dict:
24
+ """Create parameters for starting an activity.
25
+
26
+ Args:
27
+ dataset_id (str): The ID of the dataset to start the activity for.
28
+ activity_id (Optional[str]): The ID of the activity to start.
29
+ activity_type (Optional[str]): The type of the activity to start.
30
+ parameters (Optional[dict]): The parameters to start the activity with.
31
+ progress (Optional[dict]): The progress to start the activity with.
32
+ meta (Optional[dict]): The meta information to start the activity with.
33
+
34
+ Returns:
35
+ dict: Parameters for starting an activity
36
+
37
+ Raises:
38
+ BadParameterError: If neither activity_id nor activity_type is provided
39
+ """
40
+ if activity_id is None and activity_type is None:
41
+ raise BadParameterError("Either activity_id or activity_type must be provided")
42
+
43
+ params = {
44
+ "datasetId": dataset_id,
45
+ }
46
+
47
+ if activity_id is not None:
48
+ params["id"] = activity_id
49
+ else:
50
+ params["jobType"] = activity_type
51
+
52
+ if parameters is not Undefined:
53
+ params["parameters"] = parameters
54
+ if progress is not Undefined:
55
+ params["progress"] = progress
56
+ if meta is not Undefined:
57
+ params["meta"] = meta
58
+
59
+ return params
@@ -0,0 +1,79 @@
1
+ from typing import Union, List
2
+
3
+ from spb_onprem.base_types import Undefined, UndefinedType
4
+ from spb_onprem.exceptions import BadParameterError
5
+ from spb_onprem.activities.entities import ActivitySchema
6
+
7
+ def update_activity_params(
8
+ activity_id: str,
9
+ activity_type: Union[
10
+ str,
11
+ UndefinedType
12
+ ] = Undefined,
13
+ name: Union[
14
+ str,
15
+ UndefinedType
16
+ ] = Undefined,
17
+ description: Union[
18
+ UndefinedType,
19
+ str
20
+ ] = Undefined,
21
+ progress_schema: Union[
22
+ UndefinedType,
23
+ List[ActivitySchema]
24
+ ] = Undefined,
25
+ parameter_schema: Union[
26
+ UndefinedType,
27
+ List[ActivitySchema]
28
+ ] = Undefined,
29
+ settings: Union[
30
+ UndefinedType,
31
+ dict
32
+ ] = Undefined,
33
+ meta: Union[
34
+ UndefinedType,
35
+ dict
36
+ ] = Undefined,
37
+ ):
38
+ """Create parameters for activity update.
39
+
40
+ Args:
41
+ activity_id (str): The ID of the activity to update.
42
+ activity_type (Optional[str]): The type of the activity to update.
43
+ name (Optional[str]): The name of the activity to update.
44
+ dataset_id (Optional[str]): The ID of the dataset to update the activity for.
45
+ description (Optional[str]): The description of the activity to update.
46
+ progress_schema (Optional[List[ActivitySchema]]): The progress schema of the activity to update.
47
+ parameter_schema (Optional[List[ActivitySchema]]): The parameter schema of the activity to update.
48
+ settings (Optional[dict]): The settings of the activity to update.
49
+ meta (Optional[dict]): The meta of the activity to update.
50
+
51
+ Returns:
52
+ dict: Parameters for activity update
53
+
54
+ Raises:
55
+ BadParameterError: If activity_id is not provided
56
+ """
57
+ if activity_id is None:
58
+ raise BadParameterError("Activity ID is required")
59
+
60
+ params = {
61
+ "id": activity_id
62
+ }
63
+
64
+ if activity_type is not Undefined:
65
+ params["type"] = activity_type
66
+ if name is not Undefined:
67
+ params["name"] = name
68
+ if description is not Undefined:
69
+ params["description"] = description
70
+ if progress_schema is not Undefined:
71
+ params["progressSchema"] = progress_schema
72
+ if parameter_schema is not Undefined:
73
+ params["parameterSchema"] = parameter_schema
74
+ if settings is not Undefined:
75
+ params["settings"] = settings
76
+ if meta is not Undefined:
77
+ params["meta"] = meta
78
+
79
+ return params
@@ -0,0 +1,54 @@
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.activities.entities import ActivityStatus
6
+
7
+
8
+ def update_activity_history_params(
9
+ activity_history_id: str,
10
+ status: Union[
11
+ UndefinedType,
12
+ ActivityStatus
13
+ ] = Undefined,
14
+ progress: Union[
15
+ UndefinedType,
16
+ dict
17
+ ] = Undefined,
18
+ meta: Union[
19
+ UndefinedType,
20
+ dict
21
+ ] = Undefined,
22
+ ) -> dict:
23
+ """Create parameters for updating an activity history.
24
+
25
+ Args:
26
+ activity_history_id (str): The ID of the activity history to update.
27
+ status (Optional[ActivityStatus]): The status to update the activity to.
28
+ progress (Optional[dict]): The progress to update the activity with.
29
+ meta (Optional[dict]): The meta information to update with.
30
+
31
+ Returns:
32
+ dict: Parameters for updating activity history
33
+
34
+ Raises:
35
+ BadParameterError: If activity_history_id is not provided or if neither status nor progress is provided
36
+ """
37
+ if activity_history_id is None:
38
+ raise BadParameterError("Activity history ID is required")
39
+
40
+ if status is Undefined and progress is Undefined:
41
+ raise BadParameterError("Either status or progress must be provided")
42
+
43
+ params = {
44
+ "id": activity_history_id,
45
+ }
46
+
47
+ if status is not Undefined:
48
+ params["status"] = status
49
+ if progress is not Undefined:
50
+ params["progress"] = progress
51
+ if meta is not Undefined:
52
+ params["meta"] = meta
53
+
54
+ return params