mantatech-sdk 0.5b0.dev65__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.
Files changed (54) hide show
  1. manta/__init__.light.py +22 -0
  2. manta/__init__.py +83 -0
  3. manta/__main__.py +21 -0
  4. manta/apis/__init__.py +7 -0
  5. manta/apis/async_user_api.py +6458 -0
  6. manta/apis/graph.py +498 -0
  7. manta/apis/module.py +316 -0
  8. manta/apis/results.py +251 -0
  9. manta/apis/swarm.py +206 -0
  10. manta/apis/user_api.py +1016 -0
  11. manta/cli/__init__.py +1 -0
  12. manta/cli/commands/__init__.py +1 -0
  13. manta/cli/commands/base_handler.py +229 -0
  14. manta/cli/commands/doc.py +192 -0
  15. manta/cli/commands/install.py +346 -0
  16. manta/cli/commands/sdk.py +9 -0
  17. manta/cli/commands/sdk_cluster.py +211 -0
  18. manta/cli/commands/sdk_config.py +347 -0
  19. manta/cli/commands/sdk_globals.py +280 -0
  20. manta/cli/commands/sdk_logs.py +174 -0
  21. manta/cli/commands/sdk_main.py +167 -0
  22. manta/cli/commands/sdk_module.py +516 -0
  23. manta/cli/commands/sdk_nodes.py +168 -0
  24. manta/cli/commands/sdk_original.py +3873 -0
  25. manta/cli/commands/sdk_results.py +265 -0
  26. manta/cli/commands/sdk_swarm.py +454 -0
  27. manta/cli/commands/sdk_user.py +234 -0
  28. manta/cli/commands/status.py +292 -0
  29. manta/cli/component_detector.py +112 -0
  30. manta/cli/config_manager.py +445 -0
  31. manta/cli/main.py +265 -0
  32. manta/cli/utils/__init__.py +27 -0
  33. manta/cli/utils/converters.py +140 -0
  34. manta/clients/cluster_management_client.py +486 -0
  35. manta/clients/local_client.py +149 -0
  36. manta/clients/module_management_client.py +217 -0
  37. manta/clients/swarm_management_client.py +562 -0
  38. manta/clients/user_management_client.py +395 -0
  39. manta/clients/world_client.py +195 -0
  40. manta/light/__init__.py +31 -0
  41. manta/light/globals.py +245 -0
  42. manta/light/local.py +407 -0
  43. manta/light/logging_config.py +39 -0
  44. manta/light/path.py +116 -0
  45. manta/light/results.py +236 -0
  46. manta/light/task.py +100 -0
  47. manta/light/utils.py +217 -0
  48. manta/light/world.py +177 -0
  49. mantatech_sdk-0.5b0.dev65.dist-info/METADATA +1039 -0
  50. mantatech_sdk-0.5b0.dev65.dist-info/RECORD +54 -0
  51. mantatech_sdk-0.5b0.dev65.dist-info/WHEEL +5 -0
  52. mantatech_sdk-0.5b0.dev65.dist-info/entry_points.txt +2 -0
  53. mantatech_sdk-0.5b0.dev65.dist-info/licenses/LICENSE +683 -0
  54. mantatech_sdk-0.5b0.dev65.dist-info/top_level.txt +1 -0
@@ -0,0 +1,149 @@
1
+ from __future__ import annotations
2
+
3
+ from logging import getLogger
4
+ from typing import AsyncIterator, Optional, Type, TypeVar
5
+
6
+ from manta_common.base_client import GrpcClientBase
7
+ from manta_common.build.common.system import Binary
8
+ from manta_common.build.node.light_service import (
9
+ DataRequest,
10
+ DirRequest,
11
+ ExistsResponse,
12
+ ListDirResponse,
13
+ LocalStub,
14
+ ReadText,
15
+ )
16
+ from manta_common.retry import RetryPolicy, StreamingRetryPolicy
17
+
18
+ __all__ = ["LocalClient"]
19
+
20
+ T = TypeVar("T")
21
+
22
+
23
+ class LocalClient(GrpcClientBase):
24
+ """
25
+ Local client facilitates access to the local (Node) data with retry
26
+ and connection management capabilities.
27
+ """
28
+
29
+ __slots__ = ()
30
+
31
+ #: Default retry policy for regular methods
32
+ DEFAULT_RETRY_POLICY = RetryPolicy(
33
+ max_retries=3,
34
+ initial_delay=0.2,
35
+ max_delay=10.0,
36
+ backoff_factor=2.0,
37
+ jitter_factor=0.2,
38
+ )
39
+
40
+ #: Default retry policy for streaming methods
41
+ DEFAULT_STREAMING_RETRY_POLICY = StreamingRetryPolicy(
42
+ max_retries=3,
43
+ initial_delay=0.2,
44
+ max_delay=10.0,
45
+ backoff_factor=2.0,
46
+ jitter_factor=0.2,
47
+ retry_if_no_items_processed=True,
48
+ )
49
+
50
+ def _get_stub_class(self) -> Type[LocalStub]:
51
+ """
52
+ Get the stub class for this client.
53
+ """
54
+ return LocalStub
55
+
56
+ def __init__(
57
+ self,
58
+ host: str = "localhost",
59
+ port: int = 50051,
60
+ retry_policy: Optional[RetryPolicy] = None,
61
+ streaming_retry_policy: Optional[StreamingRetryPolicy] = None,
62
+ ) -> None:
63
+ """
64
+ Initialize Local client
65
+
66
+ Parameters
67
+ ----------
68
+ host : str
69
+ Node hostname
70
+ port : int
71
+ Node port
72
+ retry_policy : Optional[RetryPolicy]
73
+ Custom retry policy for operations
74
+ streaming_retry_policy : Optional[StreamingRetryPolicy]
75
+ Custom retry policy for streaming operations
76
+ """
77
+ super().__init__(
78
+ host=host,
79
+ port=port,
80
+ retry_policy=retry_policy,
81
+ streaming_retry_policy=streaming_retry_policy,
82
+ tracer=getLogger(__name__),
83
+ )
84
+
85
+ async def get_binary_data(self, request: DataRequest) -> AsyncIterator[Binary]:
86
+ """
87
+ Get binary data from the node.
88
+
89
+ Parameters
90
+ ----------
91
+ request : DataRequest
92
+ Request containing task_id, swarm_id, and name
93
+
94
+ Returns
95
+ -------
96
+ AsyncIterator[Binary]
97
+ Stream of binary data chunks
98
+ """
99
+ async for chunk in self.stream_service_method("get_binary_data", request):
100
+ yield chunk
101
+
102
+ async def list_dir(self, request: DirRequest) -> ListDirResponse:
103
+ """
104
+ List directory contents on the node.
105
+
106
+ Parameters
107
+ ----------
108
+ request : DirRequest
109
+ Directory request containing data_request and path
110
+
111
+ Returns
112
+ -------
113
+ ListDirResponse
114
+ Response containing list of paths
115
+ """
116
+ return await self.call_service_method("list_dir", request)
117
+
118
+ async def read_file_lines(self, request: ReadText) -> AsyncIterator[Binary]:
119
+ """
120
+ Read file lines from the node.
121
+
122
+ Parameters
123
+ ----------
124
+ request : ReadText
125
+ Request containing data_request, path, encoding, errors, and newline
126
+
127
+ Returns
128
+ -------
129
+ AsyncIterator[Binary]
130
+ Stream of file lines as binary chunks
131
+ """
132
+ async for chunk in self.stream_service_method("read_file_lines", request):
133
+ yield chunk
134
+
135
+ async def exists(self, request: DirRequest) -> ExistsResponse:
136
+ """
137
+ Check if a file or directory exists on the node.
138
+
139
+ Parameters
140
+ ----------
141
+ request : DirRequest
142
+ Directory request containing data_request and path
143
+
144
+ Returns
145
+ -------
146
+ ExistsResponse
147
+ Response indicating whether the path exists
148
+ """
149
+ return await self.call_service_method("exists", request)
@@ -0,0 +1,217 @@
1
+ """
2
+ Module Management Client implementation.
3
+
4
+ This module provides the ModuleManagementClient class for interacting with the ModuleManagement service.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from logging import Logger
10
+ from pathlib import Path
11
+ from typing import Any, AsyncIterator, Dict, Optional, Type, TypeVar
12
+
13
+ from manta_common.base_client import GrpcClientBase, MetadataDict
14
+ from manta_common.build.common.system import CollectionIds, Empty, Response, StrId
15
+ from manta_common.build.common.tasks import Module
16
+ from manta_common.build.core.user_services import ( # Request/Response messages; Service stub
17
+ ModuleManagementStub,
18
+ ModuleRequest,
19
+ )
20
+ from manta_common.retry import RetryPolicy
21
+
22
+ T = TypeVar("T")
23
+
24
+
25
+ class ModuleManagementClient(GrpcClientBase):
26
+ """
27
+ Client for interacting with the ModuleManagement Service.
28
+
29
+ This client provides a high-level interface for making gRPC calls to the ModuleManagement service,
30
+ handling module management and versioning operations.
31
+ """
32
+
33
+ __slots__ = ("_secure", "cafile", "certfile", "keyfile")
34
+
35
+ def __init__(
36
+ self,
37
+ host: str,
38
+ port: int,
39
+ jwt_token: str,
40
+ secure: bool = False,
41
+ cafile: Optional[str] = None,
42
+ certfile: Optional[str] = None,
43
+ keyfile: Optional[str] = None,
44
+ channel_options: Optional[Dict[str, Any]] = None,
45
+ logger: Optional[Logger] = None,
46
+ retry_policy: Optional[RetryPolicy] = None,
47
+ streaming_retry_policy: Optional[RetryPolicy] = None,
48
+ ):
49
+ """
50
+ Initialize the ModuleManagementClient.
51
+
52
+ Parameters
53
+ ----------
54
+ host : str
55
+ The host of the ModuleManagement service
56
+ port : int
57
+ The port of the ModuleManagement service
58
+ jwt_token : str
59
+ JWT token for authentication
60
+ secure : bool
61
+ Whether to use a secure connection
62
+ cafile : Optional[str]
63
+ Path to the CA certificate file for verifying the server
64
+ certfile : Optional[str]
65
+ Path to the client certificate file
66
+ keyfile : Optional[str]
67
+ Path to the client private key file
68
+ channel_options : Optional[Dict[str, Any]]
69
+ The channel options
70
+ logger : Optional[Logger]
71
+ The logger
72
+ retry_policy : Optional[RetryPolicy]
73
+ The retry policy
74
+ streaming_retry_policy : Optional[RetryPolicy]
75
+ The streaming retry policy
76
+ """
77
+ super().__init__(
78
+ host=host,
79
+ port=port,
80
+ secure=secure,
81
+ channel_options=channel_options,
82
+ tracer=logger,
83
+ retry_policy=retry_policy,
84
+ streaming_retry_policy=streaming_retry_policy,
85
+ )
86
+ self.jwt_token = jwt_token
87
+ self._secure = secure
88
+ self.cafile = Path(cafile) if cafile is not None else None
89
+ self.certfile = Path(certfile) if certfile is not None else None
90
+ self.keyfile = Path(keyfile) if keyfile is not None else None
91
+
92
+ @property
93
+ def metadata(self) -> MetadataDict:
94
+ return {"authorization": self.jwt_token}
95
+
96
+ def _get_stub_class(self) -> Type[ModuleManagementStub]:
97
+ """Get the stub class for the ModuleManagement service."""
98
+ return ModuleManagementStub
99
+
100
+ async def is_available(self) -> Response:
101
+ """
102
+ Check if the ModuleManagement service is available.
103
+
104
+ Returns
105
+ -------
106
+ Response
107
+ Service availability status
108
+ """
109
+ return await self.call_service_method(
110
+ "is_available",
111
+ Empty(),
112
+ )
113
+
114
+ async def send_module(self, module: Module) -> StrId:
115
+ """
116
+ Send/create a new module.
117
+
118
+ Parameters
119
+ ----------
120
+ module : Module
121
+ Module to create
122
+
123
+ Returns
124
+ -------
125
+ StrId
126
+ Module ID
127
+ """
128
+ return await self.call_service_method(
129
+ "send_module",
130
+ module,
131
+ )
132
+
133
+ async def list_module_ids(self) -> CollectionIds:
134
+ """
135
+ List all module IDs for the authenticated user.
136
+
137
+ Returns
138
+ -------
139
+ CollectionIds
140
+ Collection of module IDs
141
+ """
142
+ return await self.call_service_method(
143
+ "list_module_ids",
144
+ Empty(),
145
+ )
146
+
147
+ async def stream_modules(self) -> AsyncIterator[ModuleRequest]:
148
+ """
149
+ Stream all modules for the authenticated user.
150
+
151
+ Yields
152
+ ------
153
+ ModuleRequest
154
+ Module details wrapped in ModuleRequest
155
+ """
156
+ async for module_request in self.stream_service_method(
157
+ "stream_modules",
158
+ Empty(),
159
+ ):
160
+ yield module_request
161
+
162
+ async def get_module(self, module_id: str) -> ModuleRequest:
163
+ """
164
+ Get a module by its ID.
165
+
166
+ Parameters
167
+ ----------
168
+ module_id : str
169
+ ID of the module
170
+
171
+ Returns
172
+ -------
173
+ ModuleRequest
174
+ Module details wrapped in ModuleRequest
175
+ """
176
+ return await self.call_service_method(
177
+ "get_module",
178
+ StrId(id=module_id),
179
+ )
180
+
181
+ async def update_module(self, module_request: ModuleRequest) -> StrId:
182
+ """
183
+ Update an existing module.
184
+
185
+ Parameters
186
+ ----------
187
+ module_request : ModuleRequest
188
+ Module request containing module data and module_id
189
+
190
+ Returns
191
+ -------
192
+ StrId
193
+ Module ID
194
+ """
195
+ return await self.call_service_method(
196
+ "update_module",
197
+ module_request,
198
+ )
199
+
200
+ async def remove_module(self, module_id: str) -> Response:
201
+ """
202
+ Remove a module from the system.
203
+
204
+ Parameters
205
+ ----------
206
+ module_id : str
207
+ ID of the module to remove
208
+
209
+ Returns
210
+ -------
211
+ Response
212
+ Removal confirmation response
213
+ """
214
+ return await self.call_service_method(
215
+ "remove_module",
216
+ StrId(id=module_id),
217
+ )