ZBoost 1.0.5__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 ZBoost might be problematic. Click here for more details.

Files changed (101) hide show
  1. boost/__init__.py +10 -0
  2. boost/cli/__init__.py +2 -0
  3. boost/cli/wrapper.py +823 -0
  4. boost/common/__init__.py +2 -0
  5. boost/common/global_.py +8 -0
  6. boost/core/__init__.py +2 -0
  7. boost/core/agent/__init__.py +2 -0
  8. boost/core/agent/agent_info.py +12 -0
  9. boost/core/agent/agent_list.py +12 -0
  10. boost/core/agent/agent_provision.py +22 -0
  11. boost/core/agent/agent_query.py +22 -0
  12. boost/core/agent/agent_run.py +55 -0
  13. boost/core/agent/agent_service_disable.py +12 -0
  14. boost/core/agent/agent_service_enable.py +12 -0
  15. boost/core/agent/agent_service_install.py +12 -0
  16. boost/core/agent/agent_service_restart.py +12 -0
  17. boost/core/agent/agent_service_start.py +12 -0
  18. boost/core/agent/agent_service_status.py +12 -0
  19. boost/core/agent/agent_service_stop.py +12 -0
  20. boost/core/agent/agent_service_uninstall.py +12 -0
  21. boost/core/client/__init__.py +2 -0
  22. boost/core/client/client_service_disable.py +20 -0
  23. boost/core/client/client_service_enable.py +20 -0
  24. boost/core/client/client_service_install.py +20 -0
  25. boost/core/client/client_service_restart.py +20 -0
  26. boost/core/client/client_service_run.py +20 -0
  27. boost/core/client/client_service_start.py +20 -0
  28. boost/core/client/client_service_status.py +20 -0
  29. boost/core/client/client_service_stop.py +20 -0
  30. boost/core/client/client_service_uninstall.py +20 -0
  31. boost/core/config/__init__.py +2 -0
  32. boost/core/config/config_get.py +21 -0
  33. boost/core/config/config_list.py +20 -0
  34. boost/core/config/config_set.py +22 -0
  35. boost/core/config/config_unset.py +21 -0
  36. boost/core/context/__init__.py +2 -0
  37. boost/core/context/context_activate.py +21 -0
  38. boost/core/context/context_list.py +20 -0
  39. boost/core/context/context_remove.py +21 -0
  40. boost/core/debug/__init__.py +2 -0
  41. boost/core/debug/debug_flags.py +21 -0
  42. boost/core/debug/debug_gather_logs.py +23 -0
  43. boost/core/gpu/__init__.py +2 -0
  44. boost/core/gpu/gpu_data.py +24 -0
  45. boost/core/gpu/gpu_info.py +21 -0
  46. boost/core/gpu/gpu_list.py +18 -0
  47. boost/core/gpu/gpu_query.py +22 -0
  48. boost/core/help.py +13 -0
  49. boost/core/m2m/__init__.py +2 -0
  50. boost/core/m2m/m2m_create.py +13 -0
  51. boost/core/m2m/m2m_list.py +17 -0
  52. boost/core/m2m/m2m_login.py +15 -0
  53. boost/core/m2m/m2m_remove.py +12 -0
  54. boost/core/organization/__init__.py +2 -0
  55. boost/core/organization/organization_list.py +21 -0
  56. boost/core/pool_list.py +16 -0
  57. boost/core/release/__init__.py +2 -0
  58. boost/core/release/check_install.py +12 -0
  59. boost/core/release/release_admin_create.py +23 -0
  60. boost/core/release/release_admin_list.py +22 -0
  61. boost/core/release/release_admin_update.py +26 -0
  62. boost/core/release/release_download.py +16 -0
  63. boost/core/release/release_list.py +20 -0
  64. boost/core/session/__init__.py +2 -0
  65. boost/core/session/login.py +23 -0
  66. boost/core/session/logout.py +12 -0
  67. boost/core/session/session_add_path.py +12 -0
  68. boost/core/session/session_list.py +13 -0
  69. boost/core/session/session_list_paths.py +20 -0
  70. boost/core/session/session_release.py +12 -0
  71. boost/core/session/session_remove_path.py +21 -0
  72. boost/core/session/session_request.py +37 -0
  73. boost/core/user_info.py +17 -0
  74. boost/data/__init__.py +2 -0
  75. boost/data/boost_cli.json +766 -0
  76. boost/py.typed +0 -0
  77. boost/scheduling/__init__.py +2 -0
  78. boost/scheduling/add_task.py +22 -0
  79. boost/scheduling/decorators.py +102 -0
  80. boost/scheduling/rescheduling.py +25 -0
  81. boost/scheduling/scheduler.py +429 -0
  82. boost/utils/__init__.py +2 -0
  83. boost/utils/boostchk.py +25 -0
  84. boost/utils/envar.py +10 -0
  85. boost/utils/exceptions.py +20 -0
  86. boost/utils/gpu/__init__.py +2 -0
  87. boost/utils/gpu/gpu_detect.py +27 -0
  88. boost/utils/gpu/gpu_info.py +85 -0
  89. boost/utils/logger.py +64 -0
  90. boost/utils/run_async.py +36 -0
  91. boost/utils/timer.py +55 -0
  92. boost/utils/torch/__init__.py +2 -0
  93. boost/utils/torch/pytorch_cuda_sysinfo.py +211 -0
  94. boost/utils/torch/torch_memory_allocation.py +45 -0
  95. boost/workload/__init__.py +2 -0
  96. boost/workload/runner.py +121 -0
  97. zboost-1.0.5.dist-info/METADATA +226 -0
  98. zboost-1.0.5.dist-info/RECORD +101 -0
  99. zboost-1.0.5.dist-info/WHEEL +5 -0
  100. zboost-1.0.5.dist-info/licenses/LICENSE +3 -0
  101. zboost-1.0.5.dist-info/top_level.txt +1 -0
boost/cli/wrapper.py ADDED
@@ -0,0 +1,823 @@
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ # Import Standard Python Libraries.
5
+ import os
6
+ import sys
7
+ import subprocess
8
+ from typing import List, Dict, Any, Optional
9
+
10
+ # Ensure the src directory is in the Python path for imports.
11
+ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
12
+
13
+ # Import Custom Boost Modules.
14
+ from boost.utils.exceptions import handle_exceptions
15
+
16
+ class BoostCli:
17
+ """
18
+ Boost CLI Class: Provides methods for all Boost CLI functionality
19
+ with proper flag support.
20
+ """
21
+ def __init__(self, quiet: bool = True) -> None:
22
+ """Initialize the Boost CLI Wrapper Class."""
23
+ self.quiet = quiet
24
+ self.base_cmd = ["boost"]
25
+
26
+ def _build_command(self, subcommands: List[str], args: Optional[List[str]] = None,
27
+ flags: Optional[Dict[str, Any]] = None, quiet: Optional[bool] = None) -> List[str]:
28
+ """Build a command list from subcommands, arguments, and flags."""
29
+ cmd = self.base_cmd + subcommands
30
+ if args:
31
+ cmd.extend(args)
32
+ if flags:
33
+ for flag, value in flags.items():
34
+ if value is True:
35
+ cmd.append(f"--{flag}")
36
+ elif value is not False and value is not None:
37
+ cmd.extend([f"--{flag}", str(value)])
38
+ use_quiet = quiet if quiet is not None else self.quiet
39
+ if use_quiet and "--quiet" not in cmd and "-q" not in cmd:
40
+ cmd.append("-q")
41
+ return cmd
42
+
43
+ def _run_command(self, cmd: List[str]) -> str:
44
+ """Execute a command and return stdout."""
45
+ result = subprocess.run(
46
+ cmd,
47
+ capture_output=True,
48
+ text=True,
49
+ encoding="utf-8"
50
+ )
51
+ # If there's an error (non-zero exit code), include both stdout and stderr.
52
+ if result.returncode != 0:
53
+ # Combine stdout and stderr for complete error information
54
+ error_output = ""
55
+ if result.stdout.strip():
56
+ error_output += result.stdout.strip()
57
+ if result.stderr.strip():
58
+ if error_output:
59
+ error_output += "\n" + result.stderr.strip()
60
+ else:
61
+ error_output = result.stderr.strip()
62
+ return error_output if error_output else f"Command failed with exit code {result.returncode}"
63
+ return result.stdout
64
+
65
+ @handle_exceptions
66
+ def login(self, controller: Optional[str] = None, token: Optional[str] = None,
67
+ insecure_skip_tls_verify: bool = False, quiet: Optional[bool] = None) -> str:
68
+ """Log in to a controller."""
69
+ args = [controller] if controller else []
70
+ flags: Dict[str, Any] = {}
71
+ if token:
72
+ flags["token"] = token
73
+ if insecure_skip_tls_verify:
74
+ flags["insecure-skip-tls-verify"] = True
75
+ cmd = self._build_command(["login"], args, flags, quiet)
76
+ return self._run_command(cmd)
77
+
78
+ @handle_exceptions
79
+ def logout(self, quiet: Optional[bool] = None) -> str:
80
+ """Log the current user out of the controller."""
81
+ cmd = self._build_command(["logout"], quiet=quiet)
82
+ return self._run_command(cmd)
83
+
84
+ @handle_exceptions
85
+ def login_m2m_token(self, token_name: str, quiet: Optional[bool] = None) -> str:
86
+ """Log in using a M2M token."""
87
+ flags: Dict[str, Any] = {"token": token_name}
88
+ cmd = self._build_command(["login"], flags=flags, quiet=quiet)
89
+ return self._run_command(cmd)
90
+
91
+ @handle_exceptions
92
+ def check(self, json_format: bool = False, quiet: Optional[bool] = None) -> str:
93
+ """Check the installation for common issues."""
94
+ flags: Dict[str, Any] = {}
95
+ if json_format:
96
+ flags["json"] = True
97
+ cmd = self._build_command(["check"], flags=flags, quiet=quiet)
98
+ return self._run_command(cmd)
99
+
100
+ @handle_exceptions
101
+ def gpu_list(self, fields: Optional[str] = None, json_format: bool = False,
102
+ sort_cols: Optional[str] = None, quiet: Optional[bool] = None) -> str:
103
+ """
104
+ List all GPUs accessible to the user.
105
+ """
106
+ flags: Dict[str, Any] = {}
107
+ if fields:
108
+ flags["fields"] = fields
109
+ if json_format:
110
+ flags["json"] = True
111
+ if sort_cols:
112
+ flags["sort-cols"] = sort_cols
113
+ cmd = self._build_command(["gpu", "list"], flags=flags, quiet=quiet)
114
+ return self._run_command(cmd)
115
+
116
+ @handle_exceptions
117
+ def pool_list(self, fields: Optional[str] = None, json_format: bool = False,
118
+ sort_cols: Optional[str] = None, with_permission: Optional[str] = None,
119
+ quiet: Optional[bool] = None) -> str:
120
+ """
121
+ List all pools accessible to the user.
122
+ """
123
+ flags: Dict[str, Any] = {}
124
+ if fields:
125
+ flags["fields"] = fields
126
+ if json_format:
127
+ flags["json"] = True
128
+ if sort_cols:
129
+ flags["sort-cols"] = sort_cols
130
+ if with_permission:
131
+ flags["with-permission"] = with_permission
132
+ cmd = self._build_command(["pool", "list"], flags=flags, quiet=quiet)
133
+ return self._run_command(cmd)
134
+
135
+ @handle_exceptions
136
+ def session_request(self, gpu_ids: Optional[str] = None, num_gpus: Optional[int] = None,
137
+ pool_ids: Optional[str] = None, match_labels: Optional[str] = None,
138
+ tolerates: Optional[str] = None, wait_for: Optional[int] = None,
139
+ session_timeout: Optional[int] = None, watch_pid: Optional[int] = None,
140
+ disable_cache: bool = False, disable_compression: bool = False,
141
+ disable_readbacks: bool = False, disable_uvm_kernel_synchronization: bool = False,
142
+ dry_run: bool = False, dump_config: bool = False, enable_sentry: bool = False,
143
+ log_file: Optional[str] = None, log_level: Optional[str] = None,
144
+ log_level_session_service: Optional[str] = None, no_version_check: bool = False,
145
+ relaxed_api: bool = False, quiet: Optional[bool] = None) -> str:
146
+ """
147
+ Request a new session.
148
+ """
149
+ flags: Dict[str, Any] = {}
150
+ if gpu_ids:
151
+ flags["gpu-ids"] = gpu_ids
152
+ if num_gpus:
153
+ flags["num-gpus"] = num_gpus
154
+ if pool_ids:
155
+ flags["pool-ids"] = pool_ids
156
+ if match_labels:
157
+ flags["match-labels"] = match_labels
158
+ if tolerates:
159
+ flags["tolerates"] = tolerates
160
+ if wait_for:
161
+ flags["wait-for"] = wait_for
162
+ if session_timeout:
163
+ flags["session-timeout"] = session_timeout
164
+ if watch_pid:
165
+ flags["watch-pid"] = watch_pid
166
+ if disable_cache:
167
+ flags["disable-cache"] = True
168
+ if disable_compression:
169
+ flags["disable-compression"] = True
170
+ if disable_readbacks:
171
+ flags["disable-readbacks"] = True
172
+ if disable_uvm_kernel_synchronization:
173
+ flags["disable-uvm-kernel-synchronization"] = True
174
+ if dry_run:
175
+ flags["dry-run"] = True
176
+ if dump_config:
177
+ flags["dump-config"] = True
178
+ if enable_sentry:
179
+ flags["enable-sentry"] = True
180
+ if log_file:
181
+ flags["log-file"] = log_file
182
+ if log_level:
183
+ flags["log-level"] = log_level
184
+ if log_level_session_service:
185
+ flags["log-level-session-service"] = log_level_session_service
186
+ if no_version_check:
187
+ flags["no-version-check"] = True
188
+ if relaxed_api:
189
+ flags["relaxed-api"] = True
190
+ cmd = self._build_command(["session", "request"], flags=flags, quiet=quiet)
191
+ return self._run_command(cmd)
192
+
193
+ @handle_exceptions
194
+ def session_list(self, all_sessions: bool = False, allow_ephemeral: bool = False,
195
+ fields: Optional[str] = None, json_format: bool = False,
196
+ sort_cols: Optional[str] = None, quiet: Optional[bool] = None) -> str:
197
+ """
198
+ List all user sessions.
199
+ """
200
+ flags: Dict[str, Any] = {}
201
+ if all_sessions:
202
+ flags["all"] = True
203
+ if allow_ephemeral:
204
+ flags["allow-ephemeral"] = True
205
+ if fields:
206
+ flags["fields"] = fields
207
+ if json_format:
208
+ flags["json"] = True
209
+ if sort_cols:
210
+ flags["sort-cols"] = sort_cols
211
+ cmd = self._build_command(["session", "list"], flags=flags, quiet=quiet)
212
+ return self._run_command(cmd)
213
+
214
+ @handle_exceptions
215
+ def session_release(self, force: bool = False, quiet: Optional[bool] = None) -> str:
216
+ """
217
+ Release the active session.
218
+ """
219
+ flags: Dict[str, Any] = {}
220
+ if force:
221
+ flags["force"] = True
222
+ cmd = self._build_command(["session", "release"], flags=flags, quiet=quiet)
223
+ return self._run_command(cmd)
224
+
225
+ @handle_exceptions
226
+ def session_add_path(self, path: str, quiet: Optional[bool] = None) -> str:
227
+ """
228
+ Add Application Path to the active session.
229
+ """
230
+ cmd = self._build_command(["session", "add-path"], [path], quiet=quiet)
231
+ return self._run_command(cmd)
232
+
233
+ @handle_exceptions
234
+ def run(self, application: List[str], gpu_ids: Optional[str] = None, num_gpus: Optional[int] = None,
235
+ pool_ids: Optional[str] = None, match_labels: Optional[str] = None,
236
+ tolerates: Optional[str] = None, wait_for: Optional[int] = None,
237
+ session_timeout: Optional[int] = None, watch_pid: Optional[int] = None,
238
+ session: Optional[str] = None, ephemeral: bool = False,
239
+ disable_cache: bool = False, disable_compression: bool = False,
240
+ disable_readbacks: bool = False, disable_uvm_kernel_synchronization: bool = False,
241
+ dump_config: bool = False, enable_sentry: bool = False,
242
+ log_file: Optional[str] = None, log_level: Optional[str] = None,
243
+ log_level_session_service: Optional[str] = None, no_version_check: bool = False,
244
+ relaxed_api: bool = False, on_connection_error: Optional[str] = None,
245
+ on_queue_timeout: Optional[str] = None, quiet: Optional[bool] = None) -> str:
246
+ """
247
+ Start an application using the GPU(s) available to the user.
248
+ """
249
+ flags: Dict[str, Any] = {}
250
+ if gpu_ids:
251
+ flags["gpu-ids"] = gpu_ids
252
+ if num_gpus:
253
+ flags["num-gpus"] = num_gpus
254
+ if pool_ids:
255
+ flags["pool-ids"] = pool_ids
256
+ if match_labels:
257
+ flags["match-labels"] = match_labels
258
+ if tolerates:
259
+ flags["tolerates"] = tolerates
260
+ if wait_for:
261
+ flags["wait-for"] = wait_for
262
+ if session_timeout:
263
+ flags["session-timeout"] = session_timeout
264
+ if watch_pid:
265
+ flags["watch-pid"] = watch_pid
266
+ if session:
267
+ flags["session"] = session
268
+ if ephemeral:
269
+ flags["ephemeral"] = True
270
+ if disable_cache:
271
+ flags["disable-cache"] = True
272
+ if disable_compression:
273
+ flags["disable-compression"] = True
274
+ if disable_readbacks:
275
+ flags["disable-readbacks"] = True
276
+ if disable_uvm_kernel_synchronization:
277
+ flags["disable-uvm-kernel-synchronization"] = True
278
+ if dump_config:
279
+ flags["dump-config"] = True
280
+ if enable_sentry:
281
+ flags["enable-sentry"] = True
282
+ if log_file:
283
+ flags["log-file"] = log_file
284
+ if log_level:
285
+ flags["log-level"] = log_level
286
+ if log_level_session_service:
287
+ flags["log-level-session-service"] = log_level_session_service
288
+ if no_version_check:
289
+ flags["no-version-check"] = True
290
+ if relaxed_api:
291
+ flags["relaxed-api"] = True
292
+ if on_connection_error:
293
+ flags["on-connection-error"] = on_connection_error
294
+ if on_queue_timeout:
295
+ flags["on-queue-timeout"] = on_queue_timeout
296
+ if quiet:
297
+ flags["quiet"] = True
298
+ cmd = self._build_command(["run"], application, flags, quiet)
299
+ return self._run_command(cmd)
300
+
301
+ @handle_exceptions
302
+ def agent_list(self, fields: Optional[str] = None, json_format: bool = False,
303
+ sort_cols: Optional[str] = None, quiet: Optional[bool] = None) -> str:
304
+ """List all agents accessible to the user."""
305
+ flags: Dict[str, Any] = {}
306
+ if fields:
307
+ flags["fields"] = fields
308
+ if json_format:
309
+ flags["json"] = True
310
+ if sort_cols:
311
+ flags["sort-cols"] = sort_cols
312
+ cmd = self._build_command(["agent", "list"], flags=flags, quiet=quiet)
313
+ return self._run_command(cmd)
314
+
315
+ @handle_exceptions
316
+ def agent_info(self, agent_id: str, fields: Optional[str] = None, json_format: bool = False,
317
+ sort_cols: Optional[str] = None, quiet: Optional[bool] = None) -> str:
318
+ """Get information of a specific agent."""
319
+ args = [agent_id]
320
+ flags: Dict[str, Any] = {}
321
+ if fields:
322
+ flags["fields"] = fields
323
+ if json_format:
324
+ flags["json"] = True
325
+ if sort_cols:
326
+ flags["sort-cols"] = sort_cols
327
+ cmd = self._build_command(["agent", "info"], args, flags, quiet)
328
+ return self._run_command(cmd)
329
+
330
+ @handle_exceptions
331
+ def agent_run(self, pool_id: Optional[str] = None, gpu_ids: Optional[str] = None,
332
+ cache_size: Optional[int] = None, gateway_port: Optional[int] = None,
333
+ gateway_ips: Optional[str] = None, labels: Optional[str] = None,
334
+ workstation_alias: Optional[str] = None, listen_ip: Optional[str] = None,
335
+ metrics_address: Optional[str] = None, relay_server: Optional[str] = None,
336
+ stun_server: Optional[str] = None, taints: Optional[str] = None,
337
+ gpu_metrics_interval_ms: Optional[int] = None,
338
+ disable_gpu_metrics: bool = False, force_relay: bool = False,
339
+ exit_on_stdin: bool = False, os_managed_vram: bool = False,
340
+ quiet: Optional[bool] = None) -> str:
341
+ """run the agent in the foreground, sharing GPU to a specified pool."""
342
+ args = [pool_id] if pool_id else []
343
+ flags: Dict[str, Any] = {}
344
+ if gpu_ids:
345
+ flags["gpu-ids"] = gpu_ids
346
+ if cache_size:
347
+ flags["cache-size"] = cache_size
348
+ if gateway_port:
349
+ flags["gateway-port"] = gateway_port
350
+ if gateway_ips:
351
+ flags["gateway-ips"] = gateway_ips
352
+ if labels:
353
+ flags["labels"] = labels
354
+ if workstation_alias:
355
+ flags["workstation-alias"] = workstation_alias
356
+ if listen_ip:
357
+ flags["listen-ip"] = listen_ip
358
+ if metrics_address:
359
+ flags["metrics-address"] = metrics_address
360
+ if relay_server:
361
+ flags["relay-server"] = relay_server
362
+ if stun_server:
363
+ flags["stun-server"] = stun_server
364
+ if taints:
365
+ flags["taints"] = taints
366
+ if gpu_metrics_interval_ms:
367
+ flags["gpu-metrics-interval-ms"] = gpu_metrics_interval_ms
368
+ if disable_gpu_metrics:
369
+ flags["disable-gpu-metrics"] = True
370
+ if force_relay:
371
+ flags["force-relay"] = True
372
+ if exit_on_stdin:
373
+ flags["exit-on-stdin"] = True
374
+ if os_managed_vram:
375
+ flags["os-managed-vram"] = True
376
+ cmd = self._build_command(["agent", "run"], args, flags, quiet)
377
+ return self._run_command(cmd)
378
+
379
+ @handle_exceptions
380
+ def agent_service_status(self, quiet: Optional[bool] = None) -> str:
381
+ """Get the current status of the agent service."""
382
+ cmd = self._build_command(["agent", "service", "status"], quiet=quiet)
383
+ return self._run_command(cmd)
384
+
385
+ @handle_exceptions
386
+ def agent_service_start(self, quiet: Optional[bool] = None) -> str:
387
+ """Start the installed agent service."""
388
+ cmd = self._build_command(["agent", "service", "start"], quiet=quiet)
389
+ return self._run_command(cmd)
390
+
391
+ @handle_exceptions
392
+ def agent_service_stop(self, quiet: Optional[bool] = None) -> str:
393
+ """Stop the installed running agent service."""
394
+ cmd = self._build_command(["agent", "service", "stop"], quiet=quiet)
395
+ return self._run_command(cmd)
396
+
397
+ @handle_exceptions
398
+ def agent_service_restart(self, quiet: Optional[bool] = None) -> str:
399
+ """Restart the agent service."""
400
+ cmd = self._build_command(["agent", "service", "restart"], quiet=quiet)
401
+ return self._run_command(cmd)
402
+
403
+ @handle_exceptions
404
+ def agent_service_enable(self, quiet: Optional[bool] = None) -> str:
405
+ """Enable the agent service to start automatically on boot."""
406
+ cmd = self._build_command(["agent", "service", "enable"], quiet=quiet)
407
+ return self._run_command(cmd)
408
+
409
+ @handle_exceptions
410
+ def agent_service_disable(self, quiet: Optional[bool] = None) -> str:
411
+ """Disable the agent service from starting automatically on boot."""
412
+ cmd = self._build_command(["agent", "service", "disable"], quiet=quiet)
413
+ return self._run_command(cmd)
414
+
415
+ @handle_exceptions
416
+ def agent_service_install(self, pool_id: Optional[str] = None, gpu_ids: Optional[str] = None,
417
+ cache_size: Optional[int] = None, gateway_port: Optional[int] = None,
418
+ gateway_ips: Optional[str] = None, labels: Optional[str] = None,
419
+ workstation_alias: Optional[str] = None, listen_ip: Optional[str] = None,
420
+ metrics_address: Optional[str] = None, relay_server: Optional[str] = None,
421
+ stun_server: Optional[str] = None, taints: Optional[str] = None,
422
+ gpu_metrics_interval_ms: Optional[int] = None,
423
+ disable_gpu_metrics: bool = False, force_relay: bool = False,
424
+ os_managed_vram: bool = False, quiet: Optional[bool] = None) -> str:
425
+ """
426
+ Install the agent as a service. Uses the same parameters as the agent run command.
427
+ """
428
+ args = [pool_id] if pool_id else []
429
+ flags: Dict[str, Any] = {}
430
+ if gpu_ids:
431
+ flags["gpu-ids"] = gpu_ids
432
+ if cache_size:
433
+ flags["cache-size"] = cache_size
434
+ if gateway_port:
435
+ flags["gateway-port"] = gateway_port
436
+ if gateway_ips:
437
+ flags["gateway-ips"] = gateway_ips
438
+ if labels:
439
+ flags["labels"] = labels
440
+ if workstation_alias:
441
+ flags["workstation-alias"] = workstation_alias
442
+ if listen_ip:
443
+ flags["listen-ip"] = listen_ip
444
+ if metrics_address:
445
+ flags["metrics-address"] = metrics_address
446
+ if relay_server:
447
+ flags["relay-server"] = relay_server
448
+ if stun_server:
449
+ flags["stun-server"] = stun_server
450
+ if taints:
451
+ flags["taints"] = taints
452
+ if gpu_metrics_interval_ms:
453
+ flags["gpu-metrics-interval-ms"] = gpu_metrics_interval_ms
454
+ if disable_gpu_metrics:
455
+ flags["disable-gpu-metrics"] = True
456
+ if force_relay:
457
+ flags["force-relay"] = True
458
+ if os_managed_vram:
459
+ flags["os-managed-vram"] = True
460
+ cmd = self._build_command(["agent", "service", "install"], args, flags, quiet)
461
+ return self._run_command(cmd)
462
+
463
+ @handle_exceptions
464
+ def agent_service_uninstall(self, quiet: Optional[bool] = None) -> str:
465
+ """Uninstall the agent service."""
466
+ cmd = self._build_command(["agent", "service", "uninstall"], quiet=quiet)
467
+ return self._run_command(cmd)
468
+
469
+ @handle_exceptions
470
+ def release_list(self, fields: Optional[str] = None, json_format: bool = False,
471
+ sort_cols: Optional[str] = None, quiet: Optional[bool] = None) -> str:
472
+ """List client releases and their notes."""
473
+ flags: Dict[str, Any] = {}
474
+ if fields:
475
+ flags["fields"] = fields
476
+ if json_format:
477
+ flags["json"] = True
478
+ if sort_cols:
479
+ flags["sort-cols"] = sort_cols
480
+ cmd = self._build_command(["release", "list"], flags=flags, quiet=quiet)
481
+ return self._run_command(cmd)
482
+
483
+ @handle_exceptions
484
+ def release_download(self, version: str, quiet: Optional[bool] = None) -> str:
485
+ """Download a release."""
486
+ args = [version]
487
+ cmd = self._build_command(["release", "download"], args, quiet=quiet)
488
+ return self._run_command(cmd)
489
+
490
+ @handle_exceptions
491
+ def m2m_create(self, description: Optional[str] = None, expire_days: Optional[int] = None,
492
+ quiet: Optional[bool] = None) -> str:
493
+ """Create a Machine-2-Machine authentication token for use on servers."""
494
+ flags: Dict[str, Any] = {}
495
+ if description:
496
+ flags["description"] = description
497
+ if expire_days:
498
+ flags["expire-days"] = expire_days
499
+
500
+ cmd = self._build_command(["m2m", "create"], flags=flags, quiet=quiet)
501
+ return self._run_command(cmd)
502
+
503
+ @handle_exceptions
504
+ def m2m_list(self, fields: Optional[str] = None, json_format: bool = False,
505
+ sort_cols: Optional[str] = None, quiet: Optional[bool] = None) -> str:
506
+ """List all M2M tokens accessible to the CLI."""
507
+ flags: Dict[str, Any] = {}
508
+ if fields:
509
+ flags["fields"] = fields
510
+ if json_format:
511
+ flags["json"] = True
512
+ if sort_cols:
513
+ flags["sort-cols"] = sort_cols
514
+ cmd = self._build_command(["m2m", "list"], flags=flags, quiet=quiet)
515
+ return self._run_command(cmd)
516
+
517
+ @handle_exceptions
518
+ def m2m_remove(self, token_id: str, quiet: Optional[bool] = None) -> str:
519
+ """Remove a M2M token."""
520
+ args = [token_id]
521
+ cmd = self._build_command(["m2m", "remove"], args, quiet=quiet)
522
+ return self._run_command(cmd)
523
+
524
+ @handle_exceptions
525
+ def user_info(self, quiet: Optional[bool] = None) -> str:
526
+ """Retrieve user information."""
527
+ cmd = self._build_command(["user", "info"], quiet=quiet)
528
+ return self._run_command(cmd)
529
+
530
+ @handle_exceptions
531
+ def help(self, command: Optional[str] = None, quiet: Optional[bool] = None) -> str:
532
+ """Get help for any command in the application."""
533
+ args = [command] if command else []
534
+ cmd = self._build_command(["help"], args, quiet=quiet)
535
+ return self._run_command(cmd)
536
+
537
+ # -------------------------------------------------------------------------
538
+ # Session path management (Windows only)
539
+ # -------------------------------------------------------------------------
540
+
541
+ @handle_exceptions
542
+ def session_list_paths(self, quiet: Optional[bool] = None) -> Optional[str]:
543
+ """Lists all paths in the active session configuration (Windows only)."""
544
+ cmd = self._build_command(["session", "list-paths"], [], {}, quiet)
545
+ return self._run_command(cmd)
546
+
547
+ @handle_exceptions
548
+ def session_remove_path(self, path: str, quiet: Optional[bool] = None) -> Optional[str]:
549
+ """Removes a path from the active session configuration (Windows only)."""
550
+ cmd = self._build_command(["session", "remove-path"], [path], {}, quiet)
551
+ return self._run_command(cmd)
552
+
553
+ @handle_exceptions
554
+ def session_service(self, quiet: Optional[bool] = None) -> Optional[str]:
555
+ """Runs the session service (internal use)."""
556
+ cmd = self._build_command(["session", "service"], [], {}, quiet)
557
+ return self._run_command(cmd)
558
+
559
+ # -------------------------------------------------------------------------
560
+ # GPU query
561
+ # -------------------------------------------------------------------------
562
+
563
+ @handle_exceptions
564
+ def gpu_query(self, query: str, dump_ast: bool = False, quiet: Optional[bool] = None) -> Optional[str]:
565
+ """Queries the list of GPUs accessible to the user using a query expression."""
566
+ flags: Dict[str, Any] = {}
567
+ if dump_ast:
568
+ flags["dump-ast"] = True
569
+ cmd = self._build_command(["gpu", "query"], [query], flags, quiet)
570
+ return self._run_command(cmd)
571
+
572
+ # -------------------------------------------------------------------------
573
+ # Agent provision / query
574
+ # -------------------------------------------------------------------------
575
+
576
+ @handle_exceptions
577
+ def agent_provision(
578
+ self,
579
+ pool_id: Optional[str] = None,
580
+ version: Optional[str] = None,
581
+ num_gpus: Optional[int] = None,
582
+ quiet: Optional[bool] = None,
583
+ ) -> Optional[str]:
584
+ """Provisions an agent remotely."""
585
+ flags: Dict[str, Any] = {}
586
+ if version:
587
+ flags["version"] = version
588
+ if num_gpus is not None:
589
+ flags["num-gpus"] = num_gpus
590
+ args = [pool_id] if pool_id else []
591
+ cmd = self._build_command(["agent", "provision"], args, flags, quiet)
592
+ return self._run_command(cmd)
593
+
594
+ @handle_exceptions
595
+ def agent_query(self, query: str, dump_ast: bool = False, quiet: Optional[bool] = None) -> Optional[str]:
596
+ """Queries the list of agents accessible to the user using a query expression."""
597
+ flags: Dict[str, Any] = {}
598
+ if dump_ast:
599
+ flags["dump-ast"] = True
600
+ cmd = self._build_command(["agent", "query"], [query], flags, quiet)
601
+ return self._run_command(cmd)
602
+
603
+ # -------------------------------------------------------------------------
604
+ # Organization
605
+ # -------------------------------------------------------------------------
606
+
607
+ @handle_exceptions
608
+ def organization_list(self, json_format: bool = False, quiet: Optional[bool] = None) -> Optional[str]:
609
+ """Lists all organizations accessible to the user."""
610
+ flags: Dict[str, Any] = {}
611
+ if json_format:
612
+ flags["json"] = True
613
+ cmd = self._build_command(["organization", "list"], [], flags, quiet)
614
+ return self._run_command(cmd)
615
+
616
+ # -------------------------------------------------------------------------
617
+ # Debug
618
+ # -------------------------------------------------------------------------
619
+
620
+ @handle_exceptions
621
+ def debug_gather_logs(
622
+ self,
623
+ yes: bool = False,
624
+ dry_run: bool = False,
625
+ output: Optional[str] = None,
626
+ json_format: bool = False,
627
+ quiet: Optional[bool] = None,
628
+ ) -> Optional[str]:
629
+ """Collects logs and system info into an archive and uploads to support."""
630
+ flags: Dict[str, Any] = {}
631
+ if yes:
632
+ flags["yes"] = True
633
+ if dry_run:
634
+ flags["dry-run"] = True
635
+ if output:
636
+ flags["output"] = output
637
+ if json_format:
638
+ flags["json"] = True
639
+ cmd = self._build_command(["debug", "gather-logs"], [], flags, quiet)
640
+ return self._run_command(cmd)
641
+
642
+ @handle_exceptions
643
+ def debug_flags(self, json_format: bool = False, quiet: Optional[bool] = None) -> Optional[str]:
644
+ """Lists the current feature flags."""
645
+ flags: Dict[str, Any] = {}
646
+ if json_format:
647
+ flags["json"] = True
648
+ cmd = self._build_command(["debug", "flags"], [], flags, quiet)
649
+ return self._run_command(cmd)
650
+
651
+ # -------------------------------------------------------------------------
652
+ # Config
653
+ # -------------------------------------------------------------------------
654
+
655
+ @handle_exceptions
656
+ def config_get(self, key: str, quiet: Optional[bool] = None) -> Optional[str]:
657
+ """Gets a configuration value by key from the active context."""
658
+ cmd = self._build_command(["config", "get"], [key], {}, quiet)
659
+ return self._run_command(cmd)
660
+
661
+ @handle_exceptions
662
+ def config_list(self, quiet: Optional[bool] = None) -> Optional[str]:
663
+ """Lists all configuration values in the active context."""
664
+ cmd = self._build_command(["config", "list"], [], {}, quiet)
665
+ return self._run_command(cmd)
666
+
667
+ @handle_exceptions
668
+ def config_set(self, key: str, value: str, quiet: Optional[bool] = None) -> Optional[str]:
669
+ """Sets a configuration value by key and value in the active context."""
670
+ cmd = self._build_command(["config", "set"], [key, value], {}, quiet)
671
+ return self._run_command(cmd)
672
+
673
+ @handle_exceptions
674
+ def config_unset(self, key: str, quiet: Optional[bool] = None) -> Optional[str]:
675
+ """Removes (unsets) a configuration value by key from the active context."""
676
+ cmd = self._build_command(["config", "unset"], [key], {}, quiet)
677
+ return self._run_command(cmd)
678
+
679
+ # -------------------------------------------------------------------------
680
+ # Context
681
+ # -------------------------------------------------------------------------
682
+
683
+ @handle_exceptions
684
+ def context_activate(self, name: str, quiet: Optional[bool] = None) -> Optional[str]:
685
+ """Activates a named context."""
686
+ cmd = self._build_command(["context", "activate"], [name], {}, quiet)
687
+ return self._run_command(cmd)
688
+
689
+ @handle_exceptions
690
+ def context_list(self, quiet: Optional[bool] = None) -> Optional[str]:
691
+ """Lists all configured contexts."""
692
+ cmd = self._build_command(["context", "list"], [], {}, quiet)
693
+ return self._run_command(cmd)
694
+
695
+ @handle_exceptions
696
+ def context_remove(self, name: str, quiet: Optional[bool] = None) -> Optional[str]:
697
+ """Removes a named context."""
698
+ cmd = self._build_command(["context", "remove"], [name], {}, quiet)
699
+ return self._run_command(cmd)
700
+
701
+ # -------------------------------------------------------------------------
702
+ # Client service (Windows only)
703
+ # -------------------------------------------------------------------------
704
+
705
+ @handle_exceptions
706
+ def client_service_install(self, quiet: Optional[bool] = None) -> Optional[str]:
707
+ """Installs the machine-wide Boost client service (Windows only)."""
708
+ cmd = self._build_command(["client", "service", "install"], [], {}, quiet)
709
+ return self._run_command(cmd)
710
+
711
+ @handle_exceptions
712
+ def client_service_uninstall(self, quiet: Optional[bool] = None) -> Optional[str]:
713
+ """Uninstalls the Boost client service (Windows only)."""
714
+ cmd = self._build_command(["client", "service", "uninstall"], [], {}, quiet)
715
+ return self._run_command(cmd)
716
+
717
+ @handle_exceptions
718
+ def client_service_start(self, quiet: Optional[bool] = None) -> Optional[str]:
719
+ """Starts the installed Boost client service (Windows only)."""
720
+ cmd = self._build_command(["client", "service", "start"], [], {}, quiet)
721
+ return self._run_command(cmd)
722
+
723
+ @handle_exceptions
724
+ def client_service_stop(self, quiet: Optional[bool] = None) -> Optional[str]:
725
+ """Stops the installed Boost client service (Windows only)."""
726
+ cmd = self._build_command(["client", "service", "stop"], [], {}, quiet)
727
+ return self._run_command(cmd)
728
+
729
+ @handle_exceptions
730
+ def client_service_restart(self, quiet: Optional[bool] = None) -> Optional[str]:
731
+ """Restarts the Boost client service (Windows only)."""
732
+ cmd = self._build_command(["client", "service", "restart"], [], {}, quiet)
733
+ return self._run_command(cmd)
734
+
735
+ @handle_exceptions
736
+ def client_service_status(self, quiet: Optional[bool] = None) -> Optional[str]:
737
+ """Returns the current status of the Boost client service (Windows only)."""
738
+ cmd = self._build_command(["client", "service", "status"], [], {}, quiet)
739
+ return self._run_command(cmd)
740
+
741
+ @handle_exceptions
742
+ def client_service_enable(self, quiet: Optional[bool] = None) -> Optional[str]:
743
+ """Enables the Boost client service to start automatically on boot (Windows only)."""
744
+ cmd = self._build_command(["client", "service", "enable"], [], {}, quiet)
745
+ return self._run_command(cmd)
746
+
747
+ @handle_exceptions
748
+ def client_service_disable(self, quiet: Optional[bool] = None) -> Optional[str]:
749
+ """Disables the Boost client service from starting automatically on boot (Windows only)."""
750
+ cmd = self._build_command(["client", "service", "disable"], [], {}, quiet)
751
+ return self._run_command(cmd)
752
+
753
+ @handle_exceptions
754
+ def client_service_run(self, quiet: Optional[bool] = None) -> Optional[str]:
755
+ """Runs the Boost client service (internal — used by Windows Service Control Manager)."""
756
+ cmd = self._build_command(["client", "service", "run"], [], {}, quiet)
757
+ return self._run_command(cmd)
758
+
759
+ # -------------------------------------------------------------------------
760
+ # Release admin
761
+ # -------------------------------------------------------------------------
762
+
763
+ @handle_exceptions
764
+ def release_admin_list(
765
+ self,
766
+ channel: Optional[str] = None,
767
+ all_channels: bool = False,
768
+ json_format: bool = False,
769
+ quiet: Optional[bool] = None,
770
+ ) -> Optional[str]:
771
+ """Lists releases (admin view with channel filtering)."""
772
+ flags: Dict[str, Any] = {}
773
+ if channel:
774
+ flags["channel"] = channel
775
+ if all_channels:
776
+ flags["all"] = True
777
+ if json_format:
778
+ flags["json"] = True
779
+ cmd = self._build_command(["release", "admin", "list"], [], flags, quiet)
780
+ return self._run_command(cmd)
781
+
782
+ @handle_exceptions
783
+ def release_admin_create(
784
+ self,
785
+ version: str,
786
+ channels: Optional[str] = None,
787
+ notes: Optional[str] = None,
788
+ notes_from_file: Optional[str] = None,
789
+ quiet: Optional[bool] = None,
790
+ ) -> Optional[str]:
791
+ """Creates a new release."""
792
+ flags: Dict[str, Any] = {}
793
+ if channels:
794
+ flags["channels"] = channels
795
+ if notes:
796
+ flags["notes"] = notes
797
+ if notes_from_file:
798
+ flags["notes-from-file"] = notes_from_file
799
+ cmd = self._build_command(["release", "admin", "create"], [version], flags, quiet)
800
+ return self._run_command(cmd)
801
+
802
+ @handle_exceptions
803
+ def release_admin_update(
804
+ self,
805
+ version: str,
806
+ channels: Optional[str] = None,
807
+ add_channels: Optional[str] = None,
808
+ notes: Optional[str] = None,
809
+ notes_from_file: Optional[str] = None,
810
+ quiet: Optional[bool] = None,
811
+ ) -> Optional[str]:
812
+ """Updates an existing release."""
813
+ flags: Dict[str, Any] = {}
814
+ if channels:
815
+ flags["channels"] = channels
816
+ if add_channels:
817
+ flags["add-channels"] = add_channels
818
+ if notes:
819
+ flags["notes"] = notes
820
+ if notes_from_file:
821
+ flags["notes-from-file"] = notes_from_file
822
+ cmd = self._build_command(["release", "admin", "update"], [version], flags, quiet)
823
+ return self._run_command(cmd)