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.
- manta/__init__.light.py +22 -0
- manta/__init__.py +83 -0
- manta/__main__.py +21 -0
- manta/apis/__init__.py +7 -0
- manta/apis/async_user_api.py +6458 -0
- manta/apis/graph.py +498 -0
- manta/apis/module.py +316 -0
- manta/apis/results.py +251 -0
- manta/apis/swarm.py +206 -0
- manta/apis/user_api.py +1016 -0
- manta/cli/__init__.py +1 -0
- manta/cli/commands/__init__.py +1 -0
- manta/cli/commands/base_handler.py +229 -0
- manta/cli/commands/doc.py +192 -0
- manta/cli/commands/install.py +346 -0
- manta/cli/commands/sdk.py +9 -0
- manta/cli/commands/sdk_cluster.py +211 -0
- manta/cli/commands/sdk_config.py +347 -0
- manta/cli/commands/sdk_globals.py +280 -0
- manta/cli/commands/sdk_logs.py +174 -0
- manta/cli/commands/sdk_main.py +167 -0
- manta/cli/commands/sdk_module.py +516 -0
- manta/cli/commands/sdk_nodes.py +168 -0
- manta/cli/commands/sdk_original.py +3873 -0
- manta/cli/commands/sdk_results.py +265 -0
- manta/cli/commands/sdk_swarm.py +454 -0
- manta/cli/commands/sdk_user.py +234 -0
- manta/cli/commands/status.py +292 -0
- manta/cli/component_detector.py +112 -0
- manta/cli/config_manager.py +445 -0
- manta/cli/main.py +265 -0
- manta/cli/utils/__init__.py +27 -0
- manta/cli/utils/converters.py +140 -0
- manta/clients/cluster_management_client.py +486 -0
- manta/clients/local_client.py +149 -0
- manta/clients/module_management_client.py +217 -0
- manta/clients/swarm_management_client.py +562 -0
- manta/clients/user_management_client.py +395 -0
- manta/clients/world_client.py +195 -0
- manta/light/__init__.py +31 -0
- manta/light/globals.py +245 -0
- manta/light/local.py +407 -0
- manta/light/logging_config.py +39 -0
- manta/light/path.py +116 -0
- manta/light/results.py +236 -0
- manta/light/task.py +100 -0
- manta/light/utils.py +217 -0
- manta/light/world.py +177 -0
- mantatech_sdk-0.5b0.dev65.dist-info/METADATA +1039 -0
- mantatech_sdk-0.5b0.dev65.dist-info/RECORD +54 -0
- mantatech_sdk-0.5b0.dev65.dist-info/WHEEL +5 -0
- mantatech_sdk-0.5b0.dev65.dist-info/entry_points.txt +2 -0
- mantatech_sdk-0.5b0.dev65.dist-info/licenses/LICENSE +683 -0
- mantatech_sdk-0.5b0.dev65.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"""
|
|
2
|
+
User Management Client implementation.
|
|
3
|
+
|
|
4
|
+
This module provides the UserManagementClient class for interacting with the UserManagement 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, List, Optional, Type, TypeVar
|
|
12
|
+
|
|
13
|
+
from manta_common.base_client import GrpcClientBase, MetadataDict
|
|
14
|
+
from manta_common.build.common.permissions import (
|
|
15
|
+
UserAuthorization,
|
|
16
|
+
UserPermission,
|
|
17
|
+
UserQuotas,
|
|
18
|
+
)
|
|
19
|
+
from manta_common.build.common.system import CollectionIds, Empty, Response
|
|
20
|
+
from manta_common.build.common.user import User
|
|
21
|
+
from manta_common.build.core.user_services import ( # Request/Response messages; Service stub
|
|
22
|
+
AddUserRequest,
|
|
23
|
+
DeleteUserRequest,
|
|
24
|
+
GetUserRequest,
|
|
25
|
+
RegisterUserRequest,
|
|
26
|
+
RegisterUserResponse,
|
|
27
|
+
RequestPasswordResetRequest,
|
|
28
|
+
RequestPasswordResetResponse,
|
|
29
|
+
ResendVerificationRequest,
|
|
30
|
+
ResendVerificationResponse,
|
|
31
|
+
ResetPasswordRequest,
|
|
32
|
+
ResetPasswordResponse,
|
|
33
|
+
SignInRequest,
|
|
34
|
+
UserManagementStub,
|
|
35
|
+
ValidateUserRequest,
|
|
36
|
+
ValidateUserResponse,
|
|
37
|
+
)
|
|
38
|
+
from manta_common.retry import RetryPolicy
|
|
39
|
+
|
|
40
|
+
T = TypeVar("T")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class UserManagementClient(GrpcClientBase):
|
|
44
|
+
"""
|
|
45
|
+
Client for interacting with the UserManagement Service.
|
|
46
|
+
|
|
47
|
+
This client provides a high-level interface for making gRPC calls to the UserManagement service,
|
|
48
|
+
handling user registration, authentication, and account management operations.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
__slots__ = ("_secure", "cafile", "certfile", "keyfile")
|
|
52
|
+
|
|
53
|
+
def __init__(
|
|
54
|
+
self,
|
|
55
|
+
host: str,
|
|
56
|
+
port: int,
|
|
57
|
+
jwt_token: Optional[str] = None,
|
|
58
|
+
secure: bool = False,
|
|
59
|
+
cafile: Optional[str] = None,
|
|
60
|
+
certfile: Optional[str] = None,
|
|
61
|
+
keyfile: Optional[str] = None,
|
|
62
|
+
channel_options: Optional[Dict[str, Any]] = None,
|
|
63
|
+
logger: Optional[Logger] = None,
|
|
64
|
+
retry_policy: Optional[RetryPolicy] = None,
|
|
65
|
+
streaming_retry_policy: Optional[RetryPolicy] = None,
|
|
66
|
+
):
|
|
67
|
+
"""
|
|
68
|
+
Initialize the UserManagementClient.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
host : str
|
|
73
|
+
The host of the UserManagement service
|
|
74
|
+
port : int
|
|
75
|
+
The port of the UserManagement service
|
|
76
|
+
jwt_token : Optional[str]
|
|
77
|
+
JWT token for authentication (not required for SignIn/RegisterUser)
|
|
78
|
+
secure : bool
|
|
79
|
+
Whether to use a secure connection
|
|
80
|
+
cafile : Optional[str]
|
|
81
|
+
Path to the CA certificate file for verifying the server
|
|
82
|
+
certfile : Optional[str]
|
|
83
|
+
Path to the client certificate file
|
|
84
|
+
keyfile : Optional[str]
|
|
85
|
+
Path to the client private key file
|
|
86
|
+
channel_options : Optional[Dict[str, Any]]
|
|
87
|
+
The channel options
|
|
88
|
+
logger : Optional[Logger]
|
|
89
|
+
The logger
|
|
90
|
+
retry_policy : Optional[RetryPolicy]
|
|
91
|
+
The retry policy
|
|
92
|
+
streaming_retry_policy : Optional[RetryPolicy]
|
|
93
|
+
The streaming retry policy
|
|
94
|
+
"""
|
|
95
|
+
super().__init__(
|
|
96
|
+
host=host,
|
|
97
|
+
port=port,
|
|
98
|
+
secure=secure,
|
|
99
|
+
channel_options=channel_options,
|
|
100
|
+
tracer=logger,
|
|
101
|
+
retry_policy=retry_policy,
|
|
102
|
+
streaming_retry_policy=streaming_retry_policy,
|
|
103
|
+
)
|
|
104
|
+
self.jwt_token = jwt_token
|
|
105
|
+
self._secure = secure
|
|
106
|
+
self.cafile = Path(cafile) if cafile is not None else None
|
|
107
|
+
self.certfile = Path(certfile) if certfile is not None else None
|
|
108
|
+
self.keyfile = Path(keyfile) if keyfile is not None else None
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def metadata(self) -> MetadataDict:
|
|
112
|
+
if self.jwt_token:
|
|
113
|
+
return {"authorization": self.jwt_token}
|
|
114
|
+
return {}
|
|
115
|
+
|
|
116
|
+
def _get_stub_class(self) -> Type[UserManagementStub]:
|
|
117
|
+
"""Get the stub class for the UserManagement service."""
|
|
118
|
+
return UserManagementStub
|
|
119
|
+
|
|
120
|
+
async def is_available(self) -> Response:
|
|
121
|
+
"""
|
|
122
|
+
Check if the UserManagement service is available.
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
Response
|
|
127
|
+
Service availability status
|
|
128
|
+
"""
|
|
129
|
+
return await self.call_service_method(
|
|
130
|
+
"is_available",
|
|
131
|
+
Empty(),
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
async def register_user(self, username: str, password: str) -> RegisterUserResponse:
|
|
135
|
+
"""
|
|
136
|
+
Register a new user account.
|
|
137
|
+
|
|
138
|
+
Parameters
|
|
139
|
+
----------
|
|
140
|
+
username : str
|
|
141
|
+
Username for the new user
|
|
142
|
+
password : str
|
|
143
|
+
Password for the new user
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
RegisterUserResponse
|
|
148
|
+
Registration response with user info and email status
|
|
149
|
+
"""
|
|
150
|
+
return await self.call_service_method(
|
|
151
|
+
"register_user",
|
|
152
|
+
RegisterUserRequest(username=username, password=password),
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
async def validate_user(self, email_token: str) -> ValidateUserResponse:
|
|
156
|
+
"""
|
|
157
|
+
Validate a user's email address with a token.
|
|
158
|
+
|
|
159
|
+
Parameters
|
|
160
|
+
----------
|
|
161
|
+
email_token : str
|
|
162
|
+
Email validation token
|
|
163
|
+
|
|
164
|
+
Returns
|
|
165
|
+
-------
|
|
166
|
+
ValidateUserResponse
|
|
167
|
+
Validation response with success status and user ID
|
|
168
|
+
"""
|
|
169
|
+
return await self.call_service_method(
|
|
170
|
+
"validate_user",
|
|
171
|
+
ValidateUserRequest(email_token=email_token),
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
async def sign_in(self, username: str, password: str) -> User:
|
|
175
|
+
"""
|
|
176
|
+
Authenticate a user and receive JWT token.
|
|
177
|
+
|
|
178
|
+
Parameters
|
|
179
|
+
----------
|
|
180
|
+
username : str
|
|
181
|
+
Username for authentication
|
|
182
|
+
password : str
|
|
183
|
+
Password for authentication
|
|
184
|
+
|
|
185
|
+
Returns
|
|
186
|
+
-------
|
|
187
|
+
User
|
|
188
|
+
User details with JWT token
|
|
189
|
+
"""
|
|
190
|
+
return await self.call_service_method(
|
|
191
|
+
"sign_in",
|
|
192
|
+
SignInRequest(username=username, password=password),
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
async def logout(self) -> Response:
|
|
196
|
+
"""
|
|
197
|
+
Logout the current user and invalidate the session.
|
|
198
|
+
|
|
199
|
+
Returns
|
|
200
|
+
-------
|
|
201
|
+
Response
|
|
202
|
+
Logout confirmation response
|
|
203
|
+
"""
|
|
204
|
+
return await self.call_service_method(
|
|
205
|
+
"logout",
|
|
206
|
+
Empty(),
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
async def get_user(self, user_id: Optional[str] = None) -> User:
|
|
210
|
+
"""
|
|
211
|
+
Get user details for the current user or a specific user.
|
|
212
|
+
|
|
213
|
+
Parameters
|
|
214
|
+
----------
|
|
215
|
+
user_id : Optional[str]
|
|
216
|
+
User ID to retrieve. If not provided, returns current user.
|
|
217
|
+
|
|
218
|
+
Returns
|
|
219
|
+
-------
|
|
220
|
+
User
|
|
221
|
+
User details
|
|
222
|
+
"""
|
|
223
|
+
request = GetUserRequest()
|
|
224
|
+
if user_id:
|
|
225
|
+
request.user_id = user_id
|
|
226
|
+
return await self.call_service_method(
|
|
227
|
+
"get_user",
|
|
228
|
+
request,
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
async def list_user_ids(self) -> CollectionIds:
|
|
232
|
+
"""
|
|
233
|
+
List all user IDs (admin only).
|
|
234
|
+
|
|
235
|
+
Returns
|
|
236
|
+
-------
|
|
237
|
+
CollectionIds
|
|
238
|
+
Collection of user IDs
|
|
239
|
+
"""
|
|
240
|
+
return await self.call_service_method(
|
|
241
|
+
"list_user_ids",
|
|
242
|
+
Empty(),
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
async def stream_users(self) -> AsyncIterator[User]:
|
|
246
|
+
"""
|
|
247
|
+
Stream all users (admin only).
|
|
248
|
+
|
|
249
|
+
Yields
|
|
250
|
+
------
|
|
251
|
+
User
|
|
252
|
+
User details
|
|
253
|
+
"""
|
|
254
|
+
async for user in self.stream_service_method(
|
|
255
|
+
"stream_users",
|
|
256
|
+
Empty(),
|
|
257
|
+
):
|
|
258
|
+
yield user
|
|
259
|
+
|
|
260
|
+
async def delete_user(self, user_id: str) -> Response:
|
|
261
|
+
"""
|
|
262
|
+
Delete a user account (admin only).
|
|
263
|
+
|
|
264
|
+
Parameters
|
|
265
|
+
----------
|
|
266
|
+
user_id : str
|
|
267
|
+
ID of the user to delete
|
|
268
|
+
|
|
269
|
+
Returns
|
|
270
|
+
-------
|
|
271
|
+
Response
|
|
272
|
+
Deletion confirmation response
|
|
273
|
+
"""
|
|
274
|
+
return await self.call_service_method(
|
|
275
|
+
"delete_user",
|
|
276
|
+
DeleteUserRequest(user_id=user_id),
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
async def add_user(
|
|
280
|
+
self,
|
|
281
|
+
username: str,
|
|
282
|
+
email: str,
|
|
283
|
+
permissions: Optional[List[UserPermission]] = None,
|
|
284
|
+
quotas: Optional[UserQuotas] = None,
|
|
285
|
+
) -> User:
|
|
286
|
+
"""
|
|
287
|
+
Add a new user (admin only).
|
|
288
|
+
|
|
289
|
+
Parameters
|
|
290
|
+
----------
|
|
291
|
+
username : str
|
|
292
|
+
Username for the new user
|
|
293
|
+
email : str
|
|
294
|
+
Email address for the new user
|
|
295
|
+
permissions : Optional[List[UserPermission]]
|
|
296
|
+
Specific permissions to grant
|
|
297
|
+
quotas : Optional[UserQuotas]
|
|
298
|
+
User quotas to set
|
|
299
|
+
|
|
300
|
+
Returns
|
|
301
|
+
-------
|
|
302
|
+
User
|
|
303
|
+
Created user details
|
|
304
|
+
"""
|
|
305
|
+
request = AddUserRequest(username=username, email=email)
|
|
306
|
+
if permissions:
|
|
307
|
+
request.permissions.extend(permissions)
|
|
308
|
+
if quotas:
|
|
309
|
+
request.quotas = quotas
|
|
310
|
+
return await self.call_service_method(
|
|
311
|
+
"add_user",
|
|
312
|
+
request,
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
async def update_user_authorization(
|
|
316
|
+
self, authorization: UserAuthorization
|
|
317
|
+
) -> Response:
|
|
318
|
+
"""
|
|
319
|
+
Update user authorization settings (admin only).
|
|
320
|
+
|
|
321
|
+
Parameters
|
|
322
|
+
----------
|
|
323
|
+
authorization : UserAuthorization
|
|
324
|
+
Updated authorization settings
|
|
325
|
+
|
|
326
|
+
Returns
|
|
327
|
+
-------
|
|
328
|
+
Response
|
|
329
|
+
Update confirmation response
|
|
330
|
+
"""
|
|
331
|
+
return await self.call_service_method(
|
|
332
|
+
"update_user_authorization",
|
|
333
|
+
authorization,
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
async def request_password_reset(self, email: str) -> RequestPasswordResetResponse:
|
|
337
|
+
"""
|
|
338
|
+
Request a password reset for a user.
|
|
339
|
+
|
|
340
|
+
Parameters
|
|
341
|
+
----------
|
|
342
|
+
email : str
|
|
343
|
+
Email address to send reset link to
|
|
344
|
+
|
|
345
|
+
Returns
|
|
346
|
+
-------
|
|
347
|
+
RequestPasswordResetResponse
|
|
348
|
+
Password reset request response
|
|
349
|
+
"""
|
|
350
|
+
return await self.call_service_method(
|
|
351
|
+
"request_password_reset",
|
|
352
|
+
RequestPasswordResetRequest(email=email),
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
async def reset_password(
|
|
356
|
+
self, reset_token: str, new_password: str
|
|
357
|
+
) -> ResetPasswordResponse:
|
|
358
|
+
"""
|
|
359
|
+
Reset password using a reset token.
|
|
360
|
+
|
|
361
|
+
Parameters
|
|
362
|
+
----------
|
|
363
|
+
reset_token : str
|
|
364
|
+
Token from the reset email
|
|
365
|
+
new_password : str
|
|
366
|
+
New password to set
|
|
367
|
+
|
|
368
|
+
Returns
|
|
369
|
+
-------
|
|
370
|
+
ResetPasswordResponse
|
|
371
|
+
Password reset response
|
|
372
|
+
"""
|
|
373
|
+
return await self.call_service_method(
|
|
374
|
+
"reset_password",
|
|
375
|
+
ResetPasswordRequest(reset_token=reset_token, new_password=new_password),
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
async def resend_verification(self, email: str) -> ResendVerificationResponse:
|
|
379
|
+
"""
|
|
380
|
+
Resend verification email to a user.
|
|
381
|
+
|
|
382
|
+
Parameters
|
|
383
|
+
----------
|
|
384
|
+
email : str
|
|
385
|
+
Email to resend verification to
|
|
386
|
+
|
|
387
|
+
Returns
|
|
388
|
+
-------
|
|
389
|
+
ResendVerificationResponse
|
|
390
|
+
Resend verification response
|
|
391
|
+
"""
|
|
392
|
+
return await self.call_service_method(
|
|
393
|
+
"resend_verification",
|
|
394
|
+
ResendVerificationRequest(email=email),
|
|
395
|
+
)
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from logging import getLogger
|
|
4
|
+
from typing import (
|
|
5
|
+
AsyncIterable,
|
|
6
|
+
AsyncIterator,
|
|
7
|
+
Iterable,
|
|
8
|
+
Optional,
|
|
9
|
+
Type,
|
|
10
|
+
TypeVar,
|
|
11
|
+
Union,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from manta_common.base_client import GrpcClientBase
|
|
15
|
+
from manta_common.build.common.results import ChunkResultValues, GlobalValue
|
|
16
|
+
from manta_common.build.common.system import EnvId, Ok
|
|
17
|
+
from manta_common.build.common.tasks import TaskScheduling
|
|
18
|
+
from manta_common.build.node.light_service import (
|
|
19
|
+
GetGlobalRequest,
|
|
20
|
+
LightResult,
|
|
21
|
+
LightResultQuery,
|
|
22
|
+
SetGlobalRequest,
|
|
23
|
+
WorldStub,
|
|
24
|
+
)
|
|
25
|
+
from manta_common.retry import RetryPolicy, StreamingRetryPolicy
|
|
26
|
+
|
|
27
|
+
__all__ = ["WorldClient"]
|
|
28
|
+
|
|
29
|
+
T = TypeVar("T")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class WorldClient(GrpcClientBase):
|
|
33
|
+
"""
|
|
34
|
+
World client facilitates access to the world (Session) data with retry
|
|
35
|
+
and connection management capabilities.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
__slots__ = ()
|
|
39
|
+
|
|
40
|
+
#: Default retry policy for regular methods
|
|
41
|
+
DEFAULT_RETRY_POLICY = RetryPolicy(
|
|
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
|
+
)
|
|
48
|
+
|
|
49
|
+
#: Default retry policy for streaming methods
|
|
50
|
+
DEFAULT_STREAMING_RETRY_POLICY = StreamingRetryPolicy(
|
|
51
|
+
max_retries=3,
|
|
52
|
+
initial_delay=0.2,
|
|
53
|
+
max_delay=10.0,
|
|
54
|
+
backoff_factor=2.0,
|
|
55
|
+
jitter_factor=0.2,
|
|
56
|
+
retry_if_no_items_processed=True,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def _get_stub_class(self) -> Type[WorldStub]:
|
|
60
|
+
"""
|
|
61
|
+
Get the stub class for this client.
|
|
62
|
+
"""
|
|
63
|
+
return WorldStub
|
|
64
|
+
|
|
65
|
+
def __init__(
|
|
66
|
+
self,
|
|
67
|
+
host: str = "localhost",
|
|
68
|
+
port: int = 50051,
|
|
69
|
+
retry_policy: Optional[RetryPolicy] = None,
|
|
70
|
+
streaming_retry_policy: Optional[StreamingRetryPolicy] = None,
|
|
71
|
+
) -> None:
|
|
72
|
+
"""
|
|
73
|
+
Initialize World client
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
host : str
|
|
78
|
+
Manager hostname
|
|
79
|
+
port : int
|
|
80
|
+
Manager port
|
|
81
|
+
retry_policy : Optional[RetryPolicy]
|
|
82
|
+
Custom retry policy for operations
|
|
83
|
+
streaming_retry_policy : Optional[StreamingRetryPolicy]
|
|
84
|
+
Custom retry policy for streaming operations
|
|
85
|
+
"""
|
|
86
|
+
super().__init__(
|
|
87
|
+
host=host,
|
|
88
|
+
port=port,
|
|
89
|
+
retry_policy=retry_policy,
|
|
90
|
+
streaming_retry_policy=streaming_retry_policy,
|
|
91
|
+
tracer=getLogger(__name__),
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
async def get_task_result(
|
|
95
|
+
self, request: LightResultQuery
|
|
96
|
+
) -> AsyncIterator[ChunkResultValues]:
|
|
97
|
+
"""
|
|
98
|
+
Get task results from the manager.
|
|
99
|
+
|
|
100
|
+
Parameters
|
|
101
|
+
----------
|
|
102
|
+
request : LightResultQuery
|
|
103
|
+
Query containing task_id, swarm_id, tag, size, and method
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
AsyncIterator[ChunkResultValues]
|
|
108
|
+
Stream of result chunks
|
|
109
|
+
"""
|
|
110
|
+
async for chunk in self.stream_service_method("get_task_result", request):
|
|
111
|
+
yield chunk
|
|
112
|
+
|
|
113
|
+
async def add_task_result(self, request: AsyncIterable[LightResult]) -> Ok:
|
|
114
|
+
"""
|
|
115
|
+
Add task result to the manager.
|
|
116
|
+
|
|
117
|
+
Parameters
|
|
118
|
+
----------
|
|
119
|
+
request : AsyncIterable[LightResult]
|
|
120
|
+
Stream of light results containing task_id, swarm_id, tag, and data
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
Ok
|
|
125
|
+
Response indicating success
|
|
126
|
+
"""
|
|
127
|
+
return await self.call_service_method("add_task_result", request)
|
|
128
|
+
|
|
129
|
+
async def get_global(self, request: GetGlobalRequest) -> AsyncIterator[GlobalValue]:
|
|
130
|
+
"""
|
|
131
|
+
Get global values from the manager.
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
request : GetGlobalRequest
|
|
136
|
+
Global tag to query
|
|
137
|
+
|
|
138
|
+
Returns
|
|
139
|
+
-------
|
|
140
|
+
AsyncIterator[GlobalValue]
|
|
141
|
+
Stream of global values
|
|
142
|
+
"""
|
|
143
|
+
async for value in self.stream_service_method("get_global", request):
|
|
144
|
+
yield value
|
|
145
|
+
|
|
146
|
+
async def set_global(
|
|
147
|
+
self,
|
|
148
|
+
request: Union[AsyncIterable[SetGlobalRequest], Iterable[SetGlobalRequest]],
|
|
149
|
+
) -> Ok:
|
|
150
|
+
"""
|
|
151
|
+
Set global values in the manager.
|
|
152
|
+
|
|
153
|
+
Parameters
|
|
154
|
+
----------
|
|
155
|
+
request : Union[AsyncIterable[SetGlobalRequest], Iterable[SetGlobalRequest]]
|
|
156
|
+
Stream of global updates
|
|
157
|
+
|
|
158
|
+
Returns
|
|
159
|
+
-------
|
|
160
|
+
Ok
|
|
161
|
+
Response indicating success
|
|
162
|
+
"""
|
|
163
|
+
return await self.call_service_method("set_global", request)
|
|
164
|
+
|
|
165
|
+
async def stop_swarm(self, request: EnvId) -> Ok:
|
|
166
|
+
"""
|
|
167
|
+
Stop a swarm.
|
|
168
|
+
|
|
169
|
+
Parameters
|
|
170
|
+
----------
|
|
171
|
+
request : EnvID
|
|
172
|
+
Swarm ID to stop
|
|
173
|
+
|
|
174
|
+
Returns
|
|
175
|
+
-------
|
|
176
|
+
Ok
|
|
177
|
+
Response indicating success
|
|
178
|
+
"""
|
|
179
|
+
return await self.call_service_method("stop_swarm", request)
|
|
180
|
+
|
|
181
|
+
async def schedule_task(self, request: TaskScheduling) -> Ok:
|
|
182
|
+
"""
|
|
183
|
+
Schedule a task.
|
|
184
|
+
|
|
185
|
+
Parameters
|
|
186
|
+
----------
|
|
187
|
+
request : TaskScheduling
|
|
188
|
+
Task scheduling information
|
|
189
|
+
|
|
190
|
+
Returns
|
|
191
|
+
-------
|
|
192
|
+
Ok
|
|
193
|
+
Response indicating success
|
|
194
|
+
"""
|
|
195
|
+
return await self.call_service_method("schedule_task", request)
|
manta/light/__init__.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from manta_common.conversions import bytes_to_dict, dict_to_bytes
|
|
2
|
+
from .globals import Globals
|
|
3
|
+
from .local import Local
|
|
4
|
+
from .path import MantaPath
|
|
5
|
+
from .results import Results
|
|
6
|
+
from .task import Task
|
|
7
|
+
from .utils import (
|
|
8
|
+
bytes_to_numpy,
|
|
9
|
+
bytes_to_torchmodel,
|
|
10
|
+
numpy_to_bytes,
|
|
11
|
+
torchmodel_to_bytes,
|
|
12
|
+
)
|
|
13
|
+
from .world import World
|
|
14
|
+
|
|
15
|
+
# __version__ = importlib.metadata.version(str(__package__))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"Globals",
|
|
20
|
+
"Local",
|
|
21
|
+
"MantaPath",
|
|
22
|
+
"Results",
|
|
23
|
+
"Task",
|
|
24
|
+
"bytes_to_numpy",
|
|
25
|
+
"bytes_to_torchmodel",
|
|
26
|
+
"numpy_to_bytes",
|
|
27
|
+
"torchmodel_to_bytes",
|
|
28
|
+
"World",
|
|
29
|
+
"bytes_to_dict",
|
|
30
|
+
"dict_to_bytes",
|
|
31
|
+
]
|