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
manta/apis/user_api.py
ADDED
|
@@ -0,0 +1,1016 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Any, Dict, List, Optional
|
|
3
|
+
|
|
4
|
+
from manta_common.event_loop import EventLoopManager, call_async
|
|
5
|
+
from .async_user_api import AsyncUserAPI
|
|
6
|
+
from .module import Module
|
|
7
|
+
from .results import Results
|
|
8
|
+
from .swarm import Swarm
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class UserAPI:
|
|
12
|
+
"""
|
|
13
|
+
User API
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
token : str
|
|
18
|
+
The JWT token for the user
|
|
19
|
+
host : str
|
|
20
|
+
The host of the user servicer
|
|
21
|
+
port : int
|
|
22
|
+
The port of the user servicer
|
|
23
|
+
cert_folder : Optional[str], optional
|
|
24
|
+
The folder containing the certificates, by default None
|
|
25
|
+
|
|
26
|
+
See Also
|
|
27
|
+
--------
|
|
28
|
+
AsyncUserAPI : Asynchronous User API
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
__slots__ = ["async_api", "event_loop"]
|
|
32
|
+
|
|
33
|
+
def __init__(
|
|
34
|
+
self,
|
|
35
|
+
token: str,
|
|
36
|
+
host: str,
|
|
37
|
+
port: int,
|
|
38
|
+
cert_folder: Optional[str] = None,
|
|
39
|
+
):
|
|
40
|
+
"""Initialize the UserAPI."""
|
|
41
|
+
# Convert cert_folder to individual certificate files for AsyncUserAPI
|
|
42
|
+
# If cert_folder is provided, construct paths to individual cert files
|
|
43
|
+
cafile = None
|
|
44
|
+
certfile = None
|
|
45
|
+
keyfile = None
|
|
46
|
+
|
|
47
|
+
if cert_folder:
|
|
48
|
+
from pathlib import Path
|
|
49
|
+
|
|
50
|
+
cert_path = Path(cert_folder)
|
|
51
|
+
# Common certificate file names
|
|
52
|
+
cafile = (
|
|
53
|
+
str(cert_path / "ca.crt") if (cert_path / "ca.crt").exists() else None
|
|
54
|
+
)
|
|
55
|
+
certfile = (
|
|
56
|
+
str(cert_path / "client.crt")
|
|
57
|
+
if (cert_path / "client.crt").exists()
|
|
58
|
+
else None
|
|
59
|
+
)
|
|
60
|
+
keyfile = (
|
|
61
|
+
str(cert_path / "client.key")
|
|
62
|
+
if (cert_path / "client.key").exists()
|
|
63
|
+
else None
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
self.async_api = AsyncUserAPI(token, host, port, cafile, certfile, keyfile)
|
|
67
|
+
self.event_loop = EventLoopManager.get_instance()
|
|
68
|
+
|
|
69
|
+
@call_async
|
|
70
|
+
def is_available(self) -> bool:
|
|
71
|
+
"""
|
|
72
|
+
Check if the User service is available.
|
|
73
|
+
|
|
74
|
+
Returns
|
|
75
|
+
-------
|
|
76
|
+
bool
|
|
77
|
+
Service availability status
|
|
78
|
+
"""
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
@call_async
|
|
82
|
+
def get_user(self) -> Dict[str, Any]:
|
|
83
|
+
"""
|
|
84
|
+
Get the currently authenticated user's details.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
Dict[str, Any]
|
|
89
|
+
User details for the authenticated user.
|
|
90
|
+
"""
|
|
91
|
+
pass
|
|
92
|
+
|
|
93
|
+
@call_async
|
|
94
|
+
def logout(self) -> str:
|
|
95
|
+
"""
|
|
96
|
+
Logout the currently authenticated user (invalidate the JWT token).
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
str
|
|
101
|
+
Success message
|
|
102
|
+
"""
|
|
103
|
+
pass
|
|
104
|
+
|
|
105
|
+
@call_async
|
|
106
|
+
def list_cluster_ids(self) -> List[str]:
|
|
107
|
+
"""
|
|
108
|
+
List all cluster IDs for the authenticated user.
|
|
109
|
+
|
|
110
|
+
Returns
|
|
111
|
+
-------
|
|
112
|
+
List[str]
|
|
113
|
+
List of cluster IDs
|
|
114
|
+
"""
|
|
115
|
+
pass
|
|
116
|
+
|
|
117
|
+
@call_async
|
|
118
|
+
def stream_and_fetch_clusters(self) -> List[Dict[str, Any]]:
|
|
119
|
+
"""
|
|
120
|
+
Stream all clusters for the authenticated user and fetch them.
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
List[Dict[str, Any]]
|
|
125
|
+
List of cluster details
|
|
126
|
+
"""
|
|
127
|
+
pass
|
|
128
|
+
|
|
129
|
+
def get_clusters(self) -> List[Dict[str, Any]]:
|
|
130
|
+
"""
|
|
131
|
+
Get all clusters for the authenticated user.
|
|
132
|
+
|
|
133
|
+
Returns
|
|
134
|
+
-------
|
|
135
|
+
List[Dict[str, Any]]
|
|
136
|
+
List of cluster details
|
|
137
|
+
|
|
138
|
+
Notes
|
|
139
|
+
-----
|
|
140
|
+
This method is not recommended for large number of clusters.
|
|
141
|
+
Use :code:`stream_clusters` instead.
|
|
142
|
+
"""
|
|
143
|
+
return self.stream_and_fetch_clusters()
|
|
144
|
+
|
|
145
|
+
@call_async
|
|
146
|
+
def get_cluster(self, cluster_id: str) -> dict:
|
|
147
|
+
"""
|
|
148
|
+
Get cluster info
|
|
149
|
+
|
|
150
|
+
Parameters
|
|
151
|
+
----------
|
|
152
|
+
cluster_id : str
|
|
153
|
+
ID of the cluster
|
|
154
|
+
|
|
155
|
+
Returns
|
|
156
|
+
-------
|
|
157
|
+
dict
|
|
158
|
+
Cluster Info
|
|
159
|
+
"""
|
|
160
|
+
pass
|
|
161
|
+
|
|
162
|
+
@call_async
|
|
163
|
+
def create_cluster(self, name: Optional[str] = None) -> str:
|
|
164
|
+
"""
|
|
165
|
+
Create a new cluster.
|
|
166
|
+
|
|
167
|
+
Parameters
|
|
168
|
+
----------
|
|
169
|
+
name : Optional[str]
|
|
170
|
+
Name for the cluster. If not provided, a default name will be generated.
|
|
171
|
+
|
|
172
|
+
Returns
|
|
173
|
+
-------
|
|
174
|
+
str
|
|
175
|
+
The cluster ID of the newly created cluster
|
|
176
|
+
"""
|
|
177
|
+
pass
|
|
178
|
+
|
|
179
|
+
@call_async
|
|
180
|
+
def start_cluster(self, cluster_id: str) -> Dict[str, Any]:
|
|
181
|
+
"""
|
|
182
|
+
Start a cluster.
|
|
183
|
+
|
|
184
|
+
Parameters
|
|
185
|
+
----------
|
|
186
|
+
cluster_id : str
|
|
187
|
+
ID of the cluster to start
|
|
188
|
+
|
|
189
|
+
Returns
|
|
190
|
+
-------
|
|
191
|
+
Dict[str, Any]
|
|
192
|
+
Cluster information including connection details (nodeHost, nodePort, jwtToken)
|
|
193
|
+
"""
|
|
194
|
+
pass
|
|
195
|
+
|
|
196
|
+
@call_async
|
|
197
|
+
def stop_cluster(self, cluster_id: str) -> str:
|
|
198
|
+
"""
|
|
199
|
+
Stop a cluster.
|
|
200
|
+
|
|
201
|
+
Parameters
|
|
202
|
+
----------
|
|
203
|
+
cluster_id : str
|
|
204
|
+
ID of the cluster to stop
|
|
205
|
+
|
|
206
|
+
Returns
|
|
207
|
+
-------
|
|
208
|
+
str
|
|
209
|
+
Success message
|
|
210
|
+
"""
|
|
211
|
+
pass
|
|
212
|
+
|
|
213
|
+
@call_async
|
|
214
|
+
def delete_cluster(self, cluster_id: str) -> str:
|
|
215
|
+
"""
|
|
216
|
+
Delete a cluster.
|
|
217
|
+
|
|
218
|
+
Parameters
|
|
219
|
+
----------
|
|
220
|
+
cluster_id : str
|
|
221
|
+
ID of the cluster to delete
|
|
222
|
+
|
|
223
|
+
Returns
|
|
224
|
+
-------
|
|
225
|
+
str
|
|
226
|
+
Success message
|
|
227
|
+
"""
|
|
228
|
+
pass
|
|
229
|
+
|
|
230
|
+
@call_async
|
|
231
|
+
def list_module_ids(self) -> List[str]:
|
|
232
|
+
"""
|
|
233
|
+
List all module IDs for the authenticated user.
|
|
234
|
+
|
|
235
|
+
Returns
|
|
236
|
+
-------
|
|
237
|
+
List[str]
|
|
238
|
+
List of module IDs
|
|
239
|
+
"""
|
|
240
|
+
pass
|
|
241
|
+
|
|
242
|
+
@call_async
|
|
243
|
+
def stream_and_fetch_modules(self) -> List[Module]:
|
|
244
|
+
"""
|
|
245
|
+
Stream all modules for the authenticated user and fetch them.
|
|
246
|
+
|
|
247
|
+
Returns
|
|
248
|
+
-------
|
|
249
|
+
List[Module]
|
|
250
|
+
List of Module objects
|
|
251
|
+
"""
|
|
252
|
+
pass
|
|
253
|
+
|
|
254
|
+
def get_modules(self) -> List[Module]:
|
|
255
|
+
"""
|
|
256
|
+
Get all modules for the authenticated user.
|
|
257
|
+
|
|
258
|
+
Returns
|
|
259
|
+
-------
|
|
260
|
+
List[Module]
|
|
261
|
+
List of Module objects
|
|
262
|
+
|
|
263
|
+
Notes
|
|
264
|
+
-----
|
|
265
|
+
This method is not recommended for large number of modules.
|
|
266
|
+
Use :code:`stream_modules` instead.
|
|
267
|
+
"""
|
|
268
|
+
return self.stream_and_fetch_modules()
|
|
269
|
+
|
|
270
|
+
@call_async
|
|
271
|
+
def get_module(self, module_id: str) -> Module:
|
|
272
|
+
"""
|
|
273
|
+
Get a module by its ID.
|
|
274
|
+
|
|
275
|
+
Parameters
|
|
276
|
+
----------
|
|
277
|
+
module_id : str
|
|
278
|
+
ID of the module
|
|
279
|
+
|
|
280
|
+
Returns
|
|
281
|
+
-------
|
|
282
|
+
Module
|
|
283
|
+
Module object
|
|
284
|
+
"""
|
|
285
|
+
pass
|
|
286
|
+
|
|
287
|
+
@call_async
|
|
288
|
+
def send_module(self, module: Module) -> str:
|
|
289
|
+
"""
|
|
290
|
+
Send/create a new module.
|
|
291
|
+
|
|
292
|
+
Parameters
|
|
293
|
+
----------
|
|
294
|
+
module : Module
|
|
295
|
+
Module object to create
|
|
296
|
+
|
|
297
|
+
Returns
|
|
298
|
+
-------
|
|
299
|
+
str
|
|
300
|
+
Module ID
|
|
301
|
+
"""
|
|
302
|
+
pass
|
|
303
|
+
|
|
304
|
+
@call_async
|
|
305
|
+
def update_module(self, module: Module, module_id: str) -> str:
|
|
306
|
+
"""
|
|
307
|
+
Update an existing module.
|
|
308
|
+
|
|
309
|
+
Parameters
|
|
310
|
+
----------
|
|
311
|
+
module : Module
|
|
312
|
+
Module object with updated data
|
|
313
|
+
module_id : str
|
|
314
|
+
ID of the module to update
|
|
315
|
+
|
|
316
|
+
Returns
|
|
317
|
+
-------
|
|
318
|
+
str
|
|
319
|
+
Module ID
|
|
320
|
+
"""
|
|
321
|
+
pass
|
|
322
|
+
|
|
323
|
+
@call_async
|
|
324
|
+
def remove_module(self, module_id: str) -> str:
|
|
325
|
+
"""
|
|
326
|
+
Remove a module by its ID.
|
|
327
|
+
|
|
328
|
+
Parameters
|
|
329
|
+
----------
|
|
330
|
+
module_id : str
|
|
331
|
+
ID of the module to remove
|
|
332
|
+
|
|
333
|
+
Returns
|
|
334
|
+
-------
|
|
335
|
+
str
|
|
336
|
+
Response message confirming removal
|
|
337
|
+
"""
|
|
338
|
+
pass
|
|
339
|
+
|
|
340
|
+
@call_async
|
|
341
|
+
def list_swarm_ids(self) -> List[str]:
|
|
342
|
+
"""
|
|
343
|
+
List all swarm IDs for the authenticated user.
|
|
344
|
+
|
|
345
|
+
Returns
|
|
346
|
+
-------
|
|
347
|
+
List[str]
|
|
348
|
+
List of swarm IDs
|
|
349
|
+
"""
|
|
350
|
+
pass
|
|
351
|
+
|
|
352
|
+
@call_async
|
|
353
|
+
def stream_and_fetch_swarms(self) -> List[Dict[str, Any]]:
|
|
354
|
+
"""
|
|
355
|
+
Stream all swarms for the authenticated user and fetch them.
|
|
356
|
+
|
|
357
|
+
Returns
|
|
358
|
+
-------
|
|
359
|
+
List[Dict[str, Any]]
|
|
360
|
+
List of swarm details
|
|
361
|
+
"""
|
|
362
|
+
pass
|
|
363
|
+
|
|
364
|
+
def get_swarms(self) -> List[Dict[str, Any]]:
|
|
365
|
+
"""
|
|
366
|
+
Get all swarms for the authenticated user.
|
|
367
|
+
|
|
368
|
+
Returns
|
|
369
|
+
-------
|
|
370
|
+
List[Dict[str, Any]]
|
|
371
|
+
List of swarm details
|
|
372
|
+
"""
|
|
373
|
+
return self.stream_and_fetch_swarms()
|
|
374
|
+
|
|
375
|
+
@call_async
|
|
376
|
+
def get_swarm(self, swarm_id: str) -> Dict[str, Any]:
|
|
377
|
+
"""
|
|
378
|
+
Get a swarm by its ID.
|
|
379
|
+
|
|
380
|
+
Parameters
|
|
381
|
+
----------
|
|
382
|
+
swarm_id : str
|
|
383
|
+
ID of the swarm
|
|
384
|
+
|
|
385
|
+
Returns
|
|
386
|
+
-------
|
|
387
|
+
Dict[str, Any]
|
|
388
|
+
Swarm details
|
|
389
|
+
"""
|
|
390
|
+
pass
|
|
391
|
+
|
|
392
|
+
@call_async
|
|
393
|
+
def stream_and_fetch_tasks(self, swarm_id: str) -> List[Dict[str, Any]]:
|
|
394
|
+
"""
|
|
395
|
+
Get all tasks for a swarm by its ID.
|
|
396
|
+
|
|
397
|
+
Parameters
|
|
398
|
+
----------
|
|
399
|
+
swarm_id : str
|
|
400
|
+
ID of the swarm
|
|
401
|
+
|
|
402
|
+
Returns
|
|
403
|
+
-------
|
|
404
|
+
List[Dict[str, Any]]
|
|
405
|
+
List of task details
|
|
406
|
+
"""
|
|
407
|
+
pass
|
|
408
|
+
|
|
409
|
+
def get_tasks(self, swarm_id: str) -> List[Dict[str, Any]]:
|
|
410
|
+
"""
|
|
411
|
+
Get all tasks for a swarm by its ID.
|
|
412
|
+
|
|
413
|
+
Parameters
|
|
414
|
+
----------
|
|
415
|
+
swarm_id : str
|
|
416
|
+
ID of the swarm
|
|
417
|
+
|
|
418
|
+
Returns
|
|
419
|
+
-------
|
|
420
|
+
List[Dict[str, Any]]
|
|
421
|
+
List of task details
|
|
422
|
+
"""
|
|
423
|
+
return self.stream_and_fetch_tasks(swarm_id)
|
|
424
|
+
|
|
425
|
+
@call_async
|
|
426
|
+
def send_swarm(self, cluster_id: str, swarm: Swarm) -> Dict[str, Any]:
|
|
427
|
+
"""
|
|
428
|
+
Send a Swarm to the server to be inserted into its database
|
|
429
|
+
|
|
430
|
+
Parameters
|
|
431
|
+
----------
|
|
432
|
+
cluster_id : str
|
|
433
|
+
Cluster ID
|
|
434
|
+
swarm : Swarm
|
|
435
|
+
Any class which inherit from the :code:`Swarm` class
|
|
436
|
+
|
|
437
|
+
Returns
|
|
438
|
+
-------
|
|
439
|
+
Dict[str, Any]
|
|
440
|
+
Swarm overview
|
|
441
|
+
|
|
442
|
+
Examples
|
|
443
|
+
--------
|
|
444
|
+
|
|
445
|
+
>>> swarm = FLSwarm()
|
|
446
|
+
>>> swarm_overview = user_api.send_swarm(cluster_id, swarm)
|
|
447
|
+
{'swarm_id': '9415dfd18edc45c9a6ffdf2055007bf9', 'status': 'ACTIVE', 'datetime': '2024-09-13 10:18:06'}
|
|
448
|
+
|
|
449
|
+
Notes
|
|
450
|
+
-----
|
|
451
|
+
|
|
452
|
+
The argument :code:`service` is managed by a decorator under the hood.
|
|
453
|
+
"""
|
|
454
|
+
pass
|
|
455
|
+
|
|
456
|
+
@call_async
|
|
457
|
+
def start_swarm(self, swarm_id: str) -> str:
|
|
458
|
+
"""
|
|
459
|
+
Start a Swarm given its ID if it is found in the database
|
|
460
|
+
|
|
461
|
+
Parameters
|
|
462
|
+
----------
|
|
463
|
+
swarm_id : str
|
|
464
|
+
Swarm ID
|
|
465
|
+
|
|
466
|
+
Returns
|
|
467
|
+
-------
|
|
468
|
+
str
|
|
469
|
+
Response of the server
|
|
470
|
+
|
|
471
|
+
Examples
|
|
472
|
+
--------
|
|
473
|
+
|
|
474
|
+
>>> swarm_id = '9415dfd18edc45c9a6ffdf2055007bf9'
|
|
475
|
+
>>> user_api.start_swarm(swarm_id)
|
|
476
|
+
'Swarm 9415dfd18edc45c9a6ffdf2055007bf9 has started.'
|
|
477
|
+
|
|
478
|
+
Notes
|
|
479
|
+
-----
|
|
480
|
+
|
|
481
|
+
The argument :code:`service` is managed by a decorator under the hood.
|
|
482
|
+
"""
|
|
483
|
+
pass
|
|
484
|
+
|
|
485
|
+
@call_async
|
|
486
|
+
def deploy_swarm(self, cluster_id: str, swarm: Swarm) -> Dict[str, Any]:
|
|
487
|
+
"""
|
|
488
|
+
Deploy a Swarm
|
|
489
|
+
|
|
490
|
+
Parameters
|
|
491
|
+
----------
|
|
492
|
+
cluster_id : str
|
|
493
|
+
Cluster ID
|
|
494
|
+
swarm : Swarm
|
|
495
|
+
Any class which inherit from the :code:`Swarm` class
|
|
496
|
+
|
|
497
|
+
Returns
|
|
498
|
+
-------
|
|
499
|
+
Dict[str, Any]
|
|
500
|
+
Swarm overview
|
|
501
|
+
|
|
502
|
+
Examples
|
|
503
|
+
--------
|
|
504
|
+
|
|
505
|
+
>>> swarm = FLSwarm()
|
|
506
|
+
>>> swarm_overview = user_api.deploy_swarm(cluster_id, swarm)
|
|
507
|
+
{'swarm_id': '9415dfd18edc45c9a6ffdf2055007bf9', 'status': 'ACTIVE', 'datetime': '2024-09-13 10:18:06'}
|
|
508
|
+
|
|
509
|
+
Notes
|
|
510
|
+
-----
|
|
511
|
+
|
|
512
|
+
The argument :code:`service` is managed by a decorator under the hood.
|
|
513
|
+
"""
|
|
514
|
+
pass
|
|
515
|
+
|
|
516
|
+
@call_async
|
|
517
|
+
def stop_swarm(self, swarm_id: str, force: bool = False) -> str:
|
|
518
|
+
"""
|
|
519
|
+
Stop a Swarm given its ID if it is found in the database
|
|
520
|
+
|
|
521
|
+
Parameters
|
|
522
|
+
----------
|
|
523
|
+
swarm_id : str
|
|
524
|
+
Swarm ID
|
|
525
|
+
force : bool
|
|
526
|
+
Force the stop of all the running tasks
|
|
527
|
+
|
|
528
|
+
Returns
|
|
529
|
+
-------
|
|
530
|
+
str
|
|
531
|
+
Response of the server
|
|
532
|
+
|
|
533
|
+
Examples
|
|
534
|
+
--------
|
|
535
|
+
|
|
536
|
+
>>> swarm_id = '9415dfd18edc45c9a6ffdf2055007bf9'
|
|
537
|
+
>>> user_api.stop_swarm(swarm_id)
|
|
538
|
+
'Swarm 9415dfd18edc45c9a6ffdf2055007bf9 has stopped.'
|
|
539
|
+
|
|
540
|
+
Notes
|
|
541
|
+
-----
|
|
542
|
+
|
|
543
|
+
The argument :code:`service` is managed by a decorator under the hood.
|
|
544
|
+
"""
|
|
545
|
+
pass
|
|
546
|
+
|
|
547
|
+
@call_async
|
|
548
|
+
def remove_swarm(self, swarm_id: str) -> str:
|
|
549
|
+
"""
|
|
550
|
+
Remove a swarm on the cluster
|
|
551
|
+
|
|
552
|
+
Parameters
|
|
553
|
+
----------
|
|
554
|
+
swarm_id : str
|
|
555
|
+
Id of the swarm
|
|
556
|
+
|
|
557
|
+
Returns
|
|
558
|
+
-------
|
|
559
|
+
str
|
|
560
|
+
Response of the server
|
|
561
|
+
|
|
562
|
+
Examples
|
|
563
|
+
--------
|
|
564
|
+
|
|
565
|
+
>>> swarm_id = '9415dfd18edc45c9a6ffdf2055007bf9'
|
|
566
|
+
>>> user_api.remove_swarm(swarm_id)
|
|
567
|
+
'9415dfd18edc45c9a6ffdf2055007bf9 deleted.'
|
|
568
|
+
|
|
569
|
+
Notes
|
|
570
|
+
-----
|
|
571
|
+
|
|
572
|
+
The argument :code:`service` is managed by a decorator under the hood.
|
|
573
|
+
"""
|
|
574
|
+
pass
|
|
575
|
+
|
|
576
|
+
@call_async
|
|
577
|
+
def select_tasks(self, cluster_id: str, node_id: str) -> List[Dict[str, Any]]:
|
|
578
|
+
"""
|
|
579
|
+
Select tasks given node ID.
|
|
580
|
+
Tasks are sorted by progression of the swarm from the end
|
|
581
|
+
to the beginning.
|
|
582
|
+
|
|
583
|
+
Parameters
|
|
584
|
+
----------
|
|
585
|
+
cluster_id : str
|
|
586
|
+
Cluster ID
|
|
587
|
+
node_id : str
|
|
588
|
+
Node ID
|
|
589
|
+
|
|
590
|
+
Returns
|
|
591
|
+
-------
|
|
592
|
+
List[Dict[str, Any]]
|
|
593
|
+
List of several informations containing tasks
|
|
594
|
+
|
|
595
|
+
Examples
|
|
596
|
+
--------
|
|
597
|
+
|
|
598
|
+
>>> node_id = 'a2ff3abc76e045d7bb4a04a5ac416318'
|
|
599
|
+
>>> user_api.select_tasks(cluster_id, node_id)
|
|
600
|
+
[{'task_id': 'adcc83a14d8642bbb6413d196fb0b5b8', 'swarm_id': '435709c73c5344c5a3d5754c7eb2ab6d', 'status': ...}, ...]
|
|
601
|
+
|
|
602
|
+
.. warning::
|
|
603
|
+
|
|
604
|
+
The server is not returning the payloads in the response.
|
|
605
|
+
Ask the Manta team to add this feature.
|
|
606
|
+
"""
|
|
607
|
+
pass
|
|
608
|
+
|
|
609
|
+
@call_async
|
|
610
|
+
def collect_errors(
|
|
611
|
+
self,
|
|
612
|
+
cluster_id: str,
|
|
613
|
+
start_time: Optional[datetime] = None,
|
|
614
|
+
end_time: Optional[datetime] = None,
|
|
615
|
+
limit: Optional[int] = None,
|
|
616
|
+
sort_order: Optional[str] = None,
|
|
617
|
+
) -> List[Dict[str, Any]]:
|
|
618
|
+
"""
|
|
619
|
+
Collect errors from a node
|
|
620
|
+
|
|
621
|
+
Parameters
|
|
622
|
+
----------
|
|
623
|
+
cluster_id: str
|
|
624
|
+
Cluster ID
|
|
625
|
+
start_time : Optional[datetime]
|
|
626
|
+
Start time
|
|
627
|
+
end_time : Optional[datetime]
|
|
628
|
+
End time
|
|
629
|
+
limit : Optional[int]
|
|
630
|
+
Limit
|
|
631
|
+
sort_order : Optional[str]
|
|
632
|
+
Sort order
|
|
633
|
+
|
|
634
|
+
Returns
|
|
635
|
+
-------
|
|
636
|
+
List[Dict[str, Any]]
|
|
637
|
+
List of several informations containing errors
|
|
638
|
+
|
|
639
|
+
Examples
|
|
640
|
+
--------
|
|
641
|
+
|
|
642
|
+
>>> node_id = 'a2ff3abc76e045d7bb4a04a5ac416318'
|
|
643
|
+
>>> user_api.collect_errors(cluster_id, node_id)
|
|
644
|
+
[{'error_id': '1234567890', 'error_message': 'Error message', 'datetime': '2024-09-13 10:18:06'}, ...]
|
|
645
|
+
"""
|
|
646
|
+
pass
|
|
647
|
+
|
|
648
|
+
@call_async
|
|
649
|
+
def stop_node(self, cluster_id: str, node_id: str) -> str:
|
|
650
|
+
"""
|
|
651
|
+
Stop a node given its ID
|
|
652
|
+
|
|
653
|
+
Parameters
|
|
654
|
+
----------
|
|
655
|
+
cluster_id: str
|
|
656
|
+
ID of the cluster
|
|
657
|
+
node_id : str
|
|
658
|
+
ID of the node to stop
|
|
659
|
+
|
|
660
|
+
Returns
|
|
661
|
+
-------
|
|
662
|
+
str
|
|
663
|
+
Response of the server
|
|
664
|
+
|
|
665
|
+
Examples
|
|
666
|
+
--------
|
|
667
|
+
|
|
668
|
+
>>> node_id = 'a2ff3abc76e045d7bb4a04a5ac416318'
|
|
669
|
+
>>> user_api.stop_node(cluster_id, node_id)
|
|
670
|
+
"""
|
|
671
|
+
pass
|
|
672
|
+
|
|
673
|
+
@call_async
|
|
674
|
+
def remove_node(self, cluster_id: str, node_id: str) -> str:
|
|
675
|
+
"""
|
|
676
|
+
Remove a node from the cluster
|
|
677
|
+
|
|
678
|
+
Parameters
|
|
679
|
+
----------
|
|
680
|
+
cluster_id: str
|
|
681
|
+
ID of the cluster
|
|
682
|
+
node_id : str
|
|
683
|
+
ID of the node to remove
|
|
684
|
+
|
|
685
|
+
Returns
|
|
686
|
+
-------
|
|
687
|
+
str
|
|
688
|
+
Message of the server
|
|
689
|
+
|
|
690
|
+
Examples
|
|
691
|
+
--------
|
|
692
|
+
|
|
693
|
+
>>> node_id = 'a2ff3abc76e045d7bb4a04a5ac416318'
|
|
694
|
+
>>> user_api.remove_node(cluster_id, node_id)
|
|
695
|
+
'Node a2ff3abc76e045d7bb4a04a5ac416318 has been removed from the cluster.'
|
|
696
|
+
"""
|
|
697
|
+
pass
|
|
698
|
+
|
|
699
|
+
@call_async
|
|
700
|
+
def list_node_ids(self, cluster_id: str, available: bool = False) -> List[str]:
|
|
701
|
+
"""
|
|
702
|
+
Get node IDs
|
|
703
|
+
|
|
704
|
+
Parameters
|
|
705
|
+
----------
|
|
706
|
+
cluster_id: str
|
|
707
|
+
ID of the cluster
|
|
708
|
+
available : bool
|
|
709
|
+
Get only available nodes
|
|
710
|
+
|
|
711
|
+
Returns
|
|
712
|
+
-------
|
|
713
|
+
List[str]
|
|
714
|
+
List of node IDs
|
|
715
|
+
|
|
716
|
+
Examples
|
|
717
|
+
--------
|
|
718
|
+
|
|
719
|
+
>>> user_api.list_node_ids(cluster_id, available=True)
|
|
720
|
+
['a2ff3abc76e045d7bb4a04a5ac416318', 'f8a7c1d7f9d44f6b9d0d3d5d9c7b3c9d']
|
|
721
|
+
"""
|
|
722
|
+
pass
|
|
723
|
+
|
|
724
|
+
@call_async
|
|
725
|
+
def list_available_node_ids(self, cluster_id: str) -> List[str]:
|
|
726
|
+
"""
|
|
727
|
+
List all available (connected and ready) node IDs for a cluster.
|
|
728
|
+
|
|
729
|
+
Parameters
|
|
730
|
+
----------
|
|
731
|
+
cluster_id : str
|
|
732
|
+
Cluster ID
|
|
733
|
+
|
|
734
|
+
Returns
|
|
735
|
+
-------
|
|
736
|
+
List[str]
|
|
737
|
+
List of available node IDs
|
|
738
|
+
|
|
739
|
+
Examples
|
|
740
|
+
--------
|
|
741
|
+
>>> user_api.list_available_node_ids(cluster_id)
|
|
742
|
+
['node1', 'node2', 'node3']
|
|
743
|
+
"""
|
|
744
|
+
pass
|
|
745
|
+
|
|
746
|
+
@call_async
|
|
747
|
+
def stream_and_fetch_nodes(self, cluster_id: str) -> List[Dict[str, Any]]:
|
|
748
|
+
"""
|
|
749
|
+
Stream all nodes in the cluster and fetch their resources.
|
|
750
|
+
|
|
751
|
+
Parameters
|
|
752
|
+
----------
|
|
753
|
+
cluster_id : str
|
|
754
|
+
Cluster ID
|
|
755
|
+
|
|
756
|
+
Returns
|
|
757
|
+
-------
|
|
758
|
+
List[Dict[str, Any]]
|
|
759
|
+
List of nodes
|
|
760
|
+
|
|
761
|
+
Examples
|
|
762
|
+
--------
|
|
763
|
+
|
|
764
|
+
>>> user_api.stream_and_fetch_nodes(cluster_id)
|
|
765
|
+
[{'node_id': 'a2ff3abc76e045d7bb4a04a5ac416318', 'resources': {'cpu': 1, 'memory': 1024, 'disk': 1024}, ...}, ...]
|
|
766
|
+
"""
|
|
767
|
+
pass
|
|
768
|
+
|
|
769
|
+
def get_nodes(self, cluster_id: str) -> List[Dict[str, Any]]:
|
|
770
|
+
"""
|
|
771
|
+
Stream all nodes in the cluster and fetch their resources.
|
|
772
|
+
|
|
773
|
+
Parameters
|
|
774
|
+
----------
|
|
775
|
+
cluster_id : str
|
|
776
|
+
Cluster ID
|
|
777
|
+
|
|
778
|
+
Returns
|
|
779
|
+
-------
|
|
780
|
+
List[Dict[str, Any]]
|
|
781
|
+
List of nodes
|
|
782
|
+
|
|
783
|
+
Examples
|
|
784
|
+
--------
|
|
785
|
+
|
|
786
|
+
>>> user_api.get_nodes(cluster_id)
|
|
787
|
+
[{'node_id': 'a2ff3abc76e045d7bb4a04a5ac416318', 'resources': {'cpu': 1, 'memory': 1024, 'disk': 1024}, ...}, ...]
|
|
788
|
+
"""
|
|
789
|
+
pass
|
|
790
|
+
|
|
791
|
+
@call_async
|
|
792
|
+
def get_node(self, cluster_id: str, node_id: str) -> Dict[str, Any]:
|
|
793
|
+
"""
|
|
794
|
+
Get a node by its ID.
|
|
795
|
+
|
|
796
|
+
Parameters
|
|
797
|
+
----------
|
|
798
|
+
cluster_id : str
|
|
799
|
+
Cluster ID
|
|
800
|
+
node_id : str
|
|
801
|
+
Node ID
|
|
802
|
+
|
|
803
|
+
Returns
|
|
804
|
+
-------
|
|
805
|
+
Dict[str, Any]
|
|
806
|
+
Node details
|
|
807
|
+
|
|
808
|
+
Examples
|
|
809
|
+
--------
|
|
810
|
+
|
|
811
|
+
>>> node_id = 'a2ff3abc76e045d7bb4a04a5ac416318'
|
|
812
|
+
>>> user_api.get_node(cluster_id, node_id)
|
|
813
|
+
{'node_id': 'a2ff3abc76e045d7bb4a04a5ac416318', 'resources': {'cpu': 1, 'memory': 1024, 'disk': 1024}, ...}
|
|
814
|
+
"""
|
|
815
|
+
pass
|
|
816
|
+
|
|
817
|
+
@call_async
|
|
818
|
+
def get_node_resources(self, cluster_id: str, node_id: str) -> Dict[str, Any]:
|
|
819
|
+
"""
|
|
820
|
+
Get node resources for a specific node.
|
|
821
|
+
|
|
822
|
+
Parameters
|
|
823
|
+
----------
|
|
824
|
+
cluster_id : str
|
|
825
|
+
Cluster ID
|
|
826
|
+
node_id : str
|
|
827
|
+
Node ID
|
|
828
|
+
|
|
829
|
+
Returns
|
|
830
|
+
-------
|
|
831
|
+
Dict[str, Any]
|
|
832
|
+
Node resources
|
|
833
|
+
|
|
834
|
+
Examples
|
|
835
|
+
--------
|
|
836
|
+
>>> node_id = 'a2ff3abc76e045d7bb4a04a5ac416318'
|
|
837
|
+
>>> user_api.get_node_resources(cluster_id, node_id)
|
|
838
|
+
{'cpu': 1, 'memory': 1024, 'disk': 1024}
|
|
839
|
+
"""
|
|
840
|
+
pass
|
|
841
|
+
|
|
842
|
+
@call_async
|
|
843
|
+
def select_results(self, swarm_id: str, tag: str) -> Dict[str, Results]:
|
|
844
|
+
"""
|
|
845
|
+
Select results from the database given the queries
|
|
846
|
+
|
|
847
|
+
Parameters
|
|
848
|
+
----------
|
|
849
|
+
swarm_id: str
|
|
850
|
+
Swarm ID
|
|
851
|
+
tag: str
|
|
852
|
+
Tag
|
|
853
|
+
|
|
854
|
+
Returns
|
|
855
|
+
-------
|
|
856
|
+
Dict[str, Results]
|
|
857
|
+
Dictionary of :code:`(swarm_id, results)`
|
|
858
|
+
|
|
859
|
+
Examples
|
|
860
|
+
--------
|
|
861
|
+
|
|
862
|
+
>>> swarm_id = '9415dfd18edc45c9a6ffdf2055007bf9'
|
|
863
|
+
>>> tags = ["accuracy", "loss"]
|
|
864
|
+
>>> user_api.select_results(swarm_id, tags)
|
|
865
|
+
{'9415dfd18edc45c9a6ffdf2055007bf9': Results(len(iteration)=10, len(nodes)=8, len(tags)=2)}
|
|
866
|
+
|
|
867
|
+
Notes
|
|
868
|
+
-----
|
|
869
|
+
|
|
870
|
+
The argument :code:`service` is managed by a decorator under the hood.
|
|
871
|
+
"""
|
|
872
|
+
pass
|
|
873
|
+
|
|
874
|
+
@call_async
|
|
875
|
+
def delete_results(
|
|
876
|
+
self,
|
|
877
|
+
swarm_id: str,
|
|
878
|
+
tag: str,
|
|
879
|
+
node_id: Optional[str] = None,
|
|
880
|
+
task_id: Optional[str] = None,
|
|
881
|
+
iteration: Optional[int] = None,
|
|
882
|
+
) -> str:
|
|
883
|
+
"""
|
|
884
|
+
Delete results for a specific swarm and tag.
|
|
885
|
+
|
|
886
|
+
Parameters
|
|
887
|
+
----------
|
|
888
|
+
swarm_id : str
|
|
889
|
+
Swarm ID
|
|
890
|
+
tag : str
|
|
891
|
+
Tag of the results to delete
|
|
892
|
+
node_id : str, optional
|
|
893
|
+
Filter by node ID
|
|
894
|
+
task_id : str, optional
|
|
895
|
+
Filter by task ID
|
|
896
|
+
iteration : int, optional
|
|
897
|
+
Filter by iteration number
|
|
898
|
+
|
|
899
|
+
Returns
|
|
900
|
+
-------
|
|
901
|
+
str
|
|
902
|
+
Deletion confirmation message
|
|
903
|
+
"""
|
|
904
|
+
pass
|
|
905
|
+
|
|
906
|
+
@call_async
|
|
907
|
+
def collect_logs(
|
|
908
|
+
self,
|
|
909
|
+
swarm_id: str,
|
|
910
|
+
node_ids: Optional[List[str]] = None,
|
|
911
|
+
task_ids: Optional[List[str]] = None,
|
|
912
|
+
iteration: Optional[int] = None,
|
|
913
|
+
circular: Optional[int] = None,
|
|
914
|
+
start_time: Optional[datetime] = None,
|
|
915
|
+
end_time: Optional[datetime] = None,
|
|
916
|
+
severity: Optional[List[str]] = None,
|
|
917
|
+
limit: Optional[int] = None,
|
|
918
|
+
sort_order: Optional[str] = None,
|
|
919
|
+
) -> List[Dict[str, Any]]:
|
|
920
|
+
"""
|
|
921
|
+
Collect the logs stored in the :code:`Manager` database
|
|
922
|
+
with optional filtering parameters
|
|
923
|
+
|
|
924
|
+
Parameters
|
|
925
|
+
----------
|
|
926
|
+
swarm_id : str
|
|
927
|
+
Swarm ID
|
|
928
|
+
node_ids : List[str]
|
|
929
|
+
Node IDs
|
|
930
|
+
task_ids : List[str]
|
|
931
|
+
Task IDs
|
|
932
|
+
iteration : int
|
|
933
|
+
Iteration
|
|
934
|
+
circular : int
|
|
935
|
+
Circular
|
|
936
|
+
start_time : int
|
|
937
|
+
Start time
|
|
938
|
+
end_time : int
|
|
939
|
+
End time
|
|
940
|
+
severity : List[str]
|
|
941
|
+
Severity
|
|
942
|
+
limit : int
|
|
943
|
+
Limit
|
|
944
|
+
sort_order : str
|
|
945
|
+
Sort order ("asc" or "desc")
|
|
946
|
+
|
|
947
|
+
Returns
|
|
948
|
+
-------
|
|
949
|
+
List[Dict[str, Any]]
|
|
950
|
+
List of several informations containing logs
|
|
951
|
+
|
|
952
|
+
Examples
|
|
953
|
+
--------
|
|
954
|
+
|
|
955
|
+
>>> swarm_id = '9415dfd18edc45c9a6ffdf2055007bf9'
|
|
956
|
+
>>> user_api.collect_logs(swarm_id)
|
|
957
|
+
[{'swarm_id': '9415dfd18edc45c9a6ffdf2055007bf9', 'task_id': 'a2ff3abc76e045d7bb4a04a5ac416318', 'message': ..., 'datetime': '2024-09-13 10:18:06', 'iteration': '1'}, ...]
|
|
958
|
+
|
|
959
|
+
Notes
|
|
960
|
+
-----
|
|
961
|
+
The argument :code:`service` is managed by a decorator under the hood.
|
|
962
|
+
"""
|
|
963
|
+
pass
|
|
964
|
+
|
|
965
|
+
@call_async
|
|
966
|
+
def list_result_tags(self, swarm_id: str) -> Dict[str, Any]:
|
|
967
|
+
"""
|
|
968
|
+
List result tags for a specific swarm.
|
|
969
|
+
|
|
970
|
+
Parameters
|
|
971
|
+
----------
|
|
972
|
+
swarm_id : str
|
|
973
|
+
The swarm ID
|
|
974
|
+
|
|
975
|
+
Returns
|
|
976
|
+
-------
|
|
977
|
+
Dict[str, Any]
|
|
978
|
+
Tags with usage information
|
|
979
|
+
"""
|
|
980
|
+
pass
|
|
981
|
+
|
|
982
|
+
@call_async
|
|
983
|
+
def list_global_tags(self, swarm_id: str) -> Dict[str, Any]:
|
|
984
|
+
"""
|
|
985
|
+
List global tags for a specific swarm.
|
|
986
|
+
|
|
987
|
+
Parameters
|
|
988
|
+
----------
|
|
989
|
+
swarm_id : str
|
|
990
|
+
The swarm ID
|
|
991
|
+
|
|
992
|
+
Returns
|
|
993
|
+
-------
|
|
994
|
+
Dict[str, Any]
|
|
995
|
+
Tags with usage information
|
|
996
|
+
"""
|
|
997
|
+
pass
|
|
998
|
+
|
|
999
|
+
@call_async
|
|
1000
|
+
def select_global(self, swarm_id: str, tag: str) -> List[Dict[str, Any]]:
|
|
1001
|
+
"""
|
|
1002
|
+
Select global data for a specific swarm and tag.
|
|
1003
|
+
|
|
1004
|
+
Parameters
|
|
1005
|
+
----------
|
|
1006
|
+
swarm_id : str
|
|
1007
|
+
The swarm ID
|
|
1008
|
+
tag : str
|
|
1009
|
+
The tag
|
|
1010
|
+
|
|
1011
|
+
Returns
|
|
1012
|
+
-------
|
|
1013
|
+
List[Dict[str, Any]]
|
|
1014
|
+
List of global data
|
|
1015
|
+
"""
|
|
1016
|
+
pass
|