vantage6 5.0.0a36__py3-none-any.whl → 5.0.0a38__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 vantage6 might be problematic. Click here for more details.

Files changed (80) hide show
  1. vantage6/cli/algorithm/generate_algorithm_json.py +0 -1
  2. vantage6/cli/algostore/attach.py +28 -3
  3. vantage6/cli/algostore/list.py +2 -2
  4. vantage6/cli/algostore/new.py +3 -2
  5. vantage6/cli/algostore/start.py +25 -6
  6. vantage6/cli/algostore/stop.py +3 -0
  7. vantage6/cli/algostore/version.py +62 -0
  8. vantage6/cli/auth/attach.py +1 -1
  9. vantage6/cli/auth/list.py +2 -2
  10. vantage6/cli/auth/new.py +3 -2
  11. vantage6/cli/auth/remove.py +58 -0
  12. vantage6/cli/auth/start.py +27 -9
  13. vantage6/cli/auth/stop.py +3 -0
  14. vantage6/cli/cli.py +21 -0
  15. vantage6/cli/common/attach.py +114 -0
  16. vantage6/cli/common/decorator.py +25 -4
  17. vantage6/cli/common/list.py +68 -0
  18. vantage6/cli/common/new.py +27 -7
  19. vantage6/cli/common/remove.py +18 -0
  20. vantage6/cli/common/start.py +48 -40
  21. vantage6/cli/common/stop.py +16 -4
  22. vantage6/cli/common/utils.py +65 -74
  23. vantage6/cli/common/version.py +82 -0
  24. vantage6/cli/config.py +10 -2
  25. vantage6/cli/{configuration_wizard.py → configuration_create.py} +22 -14
  26. vantage6/cli/configuration_manager.py +70 -21
  27. vantage6/cli/context/__init__.py +10 -5
  28. vantage6/cli/context/algorithm_store.py +13 -7
  29. vantage6/cli/context/auth.py +23 -5
  30. vantage6/cli/context/node.py +25 -8
  31. vantage6/cli/context/server.py +18 -6
  32. vantage6/cli/globals.py +1 -0
  33. vantage6/cli/node/attach.py +27 -3
  34. vantage6/cli/node/common/__init__.py +26 -10
  35. vantage6/cli/node/common/task_cleanup.py +153 -0
  36. vantage6/cli/node/list.py +3 -44
  37. vantage6/cli/node/new.py +13 -6
  38. vantage6/cli/node/set_api_key.py +1 -1
  39. vantage6/cli/node/start.py +30 -7
  40. vantage6/cli/node/stop.py +151 -7
  41. vantage6/cli/node/version.py +96 -33
  42. vantage6/cli/sandbox/config/base.py +109 -0
  43. vantage6/cli/sandbox/config/core.py +300 -0
  44. vantage6/cli/sandbox/config/node.py +311 -0
  45. vantage6/cli/sandbox/data/km_dataset.csv +2401 -0
  46. vantage6/cli/sandbox/data/olympic_athletes_2016.csv +2425 -0
  47. vantage6/cli/sandbox/new.py +207 -0
  48. vantage6/cli/sandbox/populate/__init__.py +173 -0
  49. vantage6/cli/sandbox/populate/helpers/connect_store.py +203 -0
  50. vantage6/cli/sandbox/populate/helpers/delete_fixtures.py +67 -0
  51. vantage6/cli/sandbox/populate/helpers/load_fixtures.py +476 -0
  52. vantage6/cli/sandbox/populate/helpers/utils.py +35 -0
  53. vantage6/cli/sandbox/remove.py +155 -0
  54. vantage6/cli/sandbox/start.py +349 -0
  55. vantage6/cli/sandbox/stop.py +106 -0
  56. vantage6/cli/server/attach.py +28 -3
  57. vantage6/cli/server/common/__init__.py +5 -6
  58. vantage6/cli/server/import_.py +137 -119
  59. vantage6/cli/server/list.py +2 -2
  60. vantage6/cli/server/new.py +5 -3
  61. vantage6/cli/server/start.py +21 -4
  62. vantage6/cli/server/stop.py +2 -0
  63. vantage6/cli/server/version.py +31 -18
  64. vantage6/cli/template/algo_store_config.j2 +3 -0
  65. vantage6/cli/template/auth_config.j2 +24 -1
  66. vantage6/cli/template/node_config.j2 +2 -0
  67. vantage6/cli/template/server_config.j2 +10 -7
  68. vantage6/cli/use/context.py +8 -1
  69. vantage6/cli/use/namespace.py +10 -7
  70. vantage6/cli/utils.py +33 -1
  71. vantage6/cli/utils_kubernetes.py +270 -0
  72. {vantage6-5.0.0a36.dist-info → vantage6-5.0.0a38.dist-info}/METADATA +4 -4
  73. vantage6-5.0.0a38.dist-info/RECORD +102 -0
  74. vantage6/cli/rabbitmq/__init__.py +0 -0
  75. vantage6/cli/rabbitmq/definitions.py +0 -26
  76. vantage6/cli/rabbitmq/queue_manager.py +0 -220
  77. vantage6/cli/rabbitmq/rabbitmq.config +0 -8
  78. vantage6-5.0.0a36.dist-info/RECORD +0 -86
  79. {vantage6-5.0.0a36.dist-info → vantage6-5.0.0a38.dist-info}/WHEEL +0 -0
  80. {vantage6-5.0.0a36.dist-info → vantage6-5.0.0a38.dist-info}/entry_points.txt +0 -0
@@ -6,7 +6,8 @@ import click
6
6
  from vantage6.common import error
7
7
  from vantage6.common.globals import InstanceType
8
8
 
9
- from vantage6.cli.configuration_wizard import select_configuration_questionaire
9
+ from vantage6.cli.common.utils import extract_name_and_is_sandbox
10
+ from vantage6.cli.configuration_create import select_configuration_questionnaire
10
11
  from vantage6.cli.context import get_context, select_context_class
11
12
 
12
13
 
@@ -14,6 +15,8 @@ def click_insert_context(
14
15
  type_: InstanceType,
15
16
  include_name: bool = False,
16
17
  include_system_folders: bool = False,
18
+ is_sandbox: bool = False,
19
+ sandbox_param: str | None = None,
17
20
  ) -> callable:
18
21
  """
19
22
  Supply the Click function with an additional context parameter. The context
@@ -27,6 +30,12 @@ def click_insert_context(
27
30
  Include the name of the configuration as an argument
28
31
  include_system_folders : bool
29
32
  Include whether or not to use the system folders as an argument
33
+ is_sandbox : bool
34
+ Include whether or not to use the sandbox configurations as an argument
35
+ sandbox_param : str | None
36
+ Name of a Click option/parameter in the command function whose boolean
37
+ value should determine sandbox mode at runtime. If provided, this value
38
+ overrides the static is_sandbox parameter.
30
39
 
31
40
  Returns
32
41
  -------
@@ -58,7 +67,7 @@ def click_insert_context(
58
67
  "--user",
59
68
  "system_folders",
60
69
  flag_value=False,
61
- default=False if type_ == InstanceType.NODE else True,
70
+ default=False if type_ == InstanceType.NODE or is_sandbox else True,
62
71
  help="Use user folders instead of system folders",
63
72
  )
64
73
  @wraps(func)
@@ -74,6 +83,16 @@ def click_insert_context(
74
83
  Decorated function
75
84
  """
76
85
  ctx_class = select_context_class(type_)
86
+
87
+ # Determine sandbox mode, preferring runtime option when provided
88
+ runtime_is_sandbox = is_sandbox
89
+ if sandbox_param is not None:
90
+ # Pop to avoid passing unknown kwarg to the wrapped function
91
+ runtime_is_sandbox = bool(kwargs.pop(sandbox_param, False))
92
+ name, runtime_is_sandbox = extract_name_and_is_sandbox(
93
+ name, runtime_is_sandbox
94
+ )
95
+
77
96
  # path to configuration file always overrides name
78
97
  if config:
79
98
  ctx = ctx_class.from_external_config_file(config, system_folders)
@@ -87,12 +106,14 @@ def click_insert_context(
87
106
  if not name:
88
107
  try:
89
108
  # select configuration if none supplied
90
- name = select_configuration_questionaire(type_, system_folders)
109
+ name = select_configuration_questionnaire(
110
+ type_, system_folders, runtime_is_sandbox
111
+ )
91
112
  except Exception:
92
113
  error("No configurations could be found!")
93
114
  exit(1)
94
115
 
95
- ctx = get_context(type_, name, system_folders)
116
+ ctx = get_context(type_, name, system_folders, runtime_is_sandbox)
96
117
  extra_args = []
97
118
  if include_name:
98
119
  if not name:
@@ -0,0 +1,68 @@
1
+ import click
2
+ from colorama import Fore, Style
3
+
4
+ from vantage6.common import warning
5
+ from vantage6.common.globals import (
6
+ APPNAME,
7
+ SANDBOX_SUFFIX,
8
+ InstanceType,
9
+ )
10
+
11
+ from vantage6.cli.common.utils import find_running_service_names
12
+ from vantage6.cli.context import select_context_class
13
+
14
+
15
+ def get_configuration_list(instance_type: InstanceType) -> None:
16
+ """
17
+ Print list of available server configurations.
18
+
19
+ Parameters
20
+ ----------
21
+ instance_type : InstanceType
22
+ The type of instance to get the configurations for
23
+ """
24
+ ctx_class = select_context_class(instance_type)
25
+
26
+ running_server_names = find_running_service_names(instance_type)
27
+ header = "\nName" + (21 * " ") + "Status" + (10 * " ") + "System/User"
28
+
29
+ click.echo(header)
30
+ click.echo("-" * len(header))
31
+
32
+ running = Fore.GREEN + "Running" + Style.RESET_ALL
33
+ stopped = Fore.RED + "Not running" + Style.RESET_ALL
34
+
35
+ # system folders
36
+ configs, failed_imports_system = ctx_class.available_configurations(
37
+ system_folders=True
38
+ )
39
+ for config in configs:
40
+ config.name = config.name.replace(SANDBOX_SUFFIX, "")
41
+ status = (
42
+ running
43
+ if f"{APPNAME}-{config.name}-system-{instance_type.value}"
44
+ in running_server_names
45
+ else stopped
46
+ )
47
+ click.echo(f"{config.name:25}{status:25} System ")
48
+
49
+ # user folders
50
+ configs, failed_imports_user = ctx_class.available_configurations(
51
+ system_folders=False
52
+ )
53
+ for config in configs:
54
+ config.name = config.name.replace(SANDBOX_SUFFIX, "")
55
+ status = (
56
+ running
57
+ if f"{APPNAME}-{config.name}-user-{instance_type.value}"
58
+ in running_server_names
59
+ else stopped
60
+ )
61
+ click.echo(f"{config.name:25}{status:25} User ")
62
+
63
+ click.echo("-" * 85)
64
+ if len(failed_imports_system) + len(failed_imports_user):
65
+ warning(
66
+ f"{Fore.RED}Failed imports: "
67
+ f"{len(failed_imports_system) + len(failed_imports_user)}{Style.RESET_ALL}"
68
+ )
@@ -1,3 +1,5 @@
1
+ from pathlib import Path
2
+
1
3
  from colorama import Fore, Style
2
4
 
3
5
  from vantage6.common import ensure_config_dir_writable, error, info
@@ -5,26 +7,30 @@ from vantage6.common.globals import InstanceType
5
7
 
6
8
  from vantage6.cli.common.utils import get_main_cli_command_name
7
9
  from vantage6.cli.config import CliConfig
8
- from vantage6.cli.configuration_wizard import configuration_wizard
10
+ from vantage6.cli.configuration_create import make_configuration
9
11
  from vantage6.cli.context import select_context_class
10
12
  from vantage6.cli.utils import check_config_name_allowed, prompt_config_name
11
13
 
12
14
 
13
15
  def new(
14
- questionnaire_function: callable,
16
+ config_producing_func: callable,
17
+ config_producing_func_args: tuple,
15
18
  name: str,
16
19
  system_folders: bool,
17
20
  namespace: str,
18
21
  context: str,
19
22
  type_: InstanceType,
20
- ) -> None:
23
+ is_sandbox: bool = False,
24
+ ) -> Path | None:
21
25
  """
22
26
  Create a new configuration.
23
27
 
24
28
  Parameters
25
29
  ----------
26
- questionnaire_function : callable
30
+ config_producing_func : callable
27
31
  Function to generate the configuration
32
+ config_producing_func_args : tuple
33
+ Arguments to pass to the config producing function
28
34
  name : str
29
35
  Name of the configuration
30
36
  system_folders : bool
@@ -35,6 +41,13 @@ def new(
35
41
  Context to use
36
42
  type_ : InstanceType
37
43
  Type of the configuration (node, server, algorithm store, etc)
44
+ is_sandbox : bool
45
+ Whether to create a sandbox configuration or not
46
+
47
+ Returns
48
+ -------
49
+ Path | None
50
+ Path to the configuration file. None if the process is aborted for any reason.
38
51
  """
39
52
  cli_config = CliConfig()
40
53
  context, namespace = cli_config.compare_changes_config(
@@ -50,11 +63,12 @@ def new(
50
63
  # check that this config does not exist
51
64
  ctx_class = select_context_class(type_)
52
65
  try:
53
- if ctx_class.config_exists(name, system_folders):
66
+ if ctx_class.config_exists(name, system_folders, is_sandbox):
54
67
  error(f"Configuration {Fore.RED}{name}{Style.RESET_ALL} already exists!")
55
68
  exit(1)
56
69
  except Exception as e:
57
70
  error(e)
71
+
58
72
  exit(1)
59
73
 
60
74
  command_name = get_main_cli_command_name(type_)
@@ -70,8 +84,13 @@ def new(
70
84
 
71
85
  # create config in ctx location
72
86
  try:
73
- cfg_file = configuration_wizard(
74
- questionnaire_function, type_, name, system_folders
87
+ cfg_file = make_configuration(
88
+ config_producing_func=config_producing_func,
89
+ config_producing_func_args=config_producing_func_args,
90
+ type_=type_,
91
+ instance_name=name,
92
+ system_folders=system_folders,
93
+ is_sandbox=is_sandbox,
75
94
  )
76
95
  except KeyboardInterrupt:
77
96
  error("Configuration creation aborted.")
@@ -83,3 +102,4 @@ def new(
83
102
  f"You can start the {command_name} by running {Fore.GREEN}v6 {command_name} "
84
103
  f"start {flag}{Style.RESET_ALL}"
85
104
  )
105
+ return cfg_file
@@ -24,6 +24,24 @@ def execute_remove(
24
24
  system_folders: bool,
25
25
  force: bool,
26
26
  ) -> None:
27
+ """
28
+ Function to remove a vantage6 service instance.
29
+
30
+ Parameters
31
+ ----------
32
+ ctx : AppContext
33
+ App context object
34
+ instance_type : InstanceType
35
+ Type of instance that is checked
36
+ infra_component : InfraComponentName
37
+ The infra component of the service
38
+ name : str
39
+ Name of the instance
40
+ system_folders : bool
41
+ Whether to use system folders or user folders
42
+ force : bool
43
+ Whether to ask for confirmation before removing or not
44
+ """
27
45
  if check_running(ctx.helm_release_name, instance_type, name, system_folders):
28
46
  error(
29
47
  f"The {infra_component.value} {name} is still running! Please stop the "
@@ -19,13 +19,11 @@ from vantage6.common.globals import (
19
19
  DEFAULT_NODE_IMAGE,
20
20
  DEFAULT_SERVER_IMAGE,
21
21
  DEFAULT_UI_IMAGE,
22
+ LOCALHOST,
22
23
  InstanceType,
23
24
  )
24
25
 
25
- from vantage6.cli.common.utils import (
26
- check_running,
27
- select_context_and_namespace,
28
- )
26
+ from vantage6.cli.common.utils import check_running
29
27
  from vantage6.cli.globals import ChartName
30
28
  from vantage6.cli.utils import check_config_name_allowed, validate_input_cmd_args
31
29
 
@@ -35,8 +33,6 @@ def prestart_checks(
35
33
  instance_type: InstanceType,
36
34
  name: str,
37
35
  system_folders: bool,
38
- context: str,
39
- namespace: str,
40
36
  ) -> None:
41
37
  """
42
38
  Run pre-start checks for an instance.
@@ -48,11 +44,6 @@ def prestart_checks(
48
44
  error(f"Instance '{name}' is already running.")
49
45
  exit(1)
50
46
 
51
- context, namespace = select_context_and_namespace(
52
- context=context,
53
- namespace=namespace,
54
- )
55
-
56
47
 
57
48
  def pull_infra_image(
58
49
  client: DockerClient, image: str, instance_type: InstanceType
@@ -142,6 +133,7 @@ def helm_install(
142
133
  values_file: str | PathLike | None = None,
143
134
  context: str | None = None,
144
135
  namespace: str | None = None,
136
+ local_chart_dir: str | None = None,
145
137
  ) -> None:
146
138
  """
147
139
  Manage the `helm install` command.
@@ -158,6 +150,8 @@ def helm_install(
158
150
  The Kubernetes context to use.
159
151
  namespace : str, optional
160
152
  The Kubernetes namespace to use.
153
+ local_chart_dir : str, optional
154
+ The local directory containing the Helm charts.
161
155
  """
162
156
  # Input validation
163
157
  validate_input_cmd_args(release_name, "release name")
@@ -171,17 +165,28 @@ def helm_install(
171
165
  validate_input_cmd_args(context, "context name", allow_none=True)
172
166
  validate_input_cmd_args(namespace, "namespace name", allow_none=True)
173
167
 
168
+ if local_chart_dir and local_chart_dir.rstrip("/").endswith(chart_name.value):
169
+ local_chart_dir = str(Path(local_chart_dir).parent)
170
+
174
171
  # Create the command
175
- command = [
176
- "helm",
177
- "install",
178
- release_name,
179
- chart_name,
180
- "--repo",
181
- DEFAULT_CHART_REPO,
182
- # TODO v5+ remove this flag when we have a stable release
183
- "--devel", # ensure using latest version including pre-releases
184
- ]
172
+ if local_chart_dir:
173
+ command = [
174
+ "helm",
175
+ "install",
176
+ release_name,
177
+ f"{local_chart_dir}/{chart_name.value}",
178
+ ]
179
+ else:
180
+ command = [
181
+ "helm",
182
+ "install",
183
+ release_name,
184
+ chart_name,
185
+ "--repo",
186
+ DEFAULT_CHART_REPO,
187
+ # TODO v5+ remove this flag when we have a stable release
188
+ "--devel",
189
+ ]
185
190
 
186
191
  if values_file:
187
192
  command.extend(["-f", str(values_file)])
@@ -217,7 +222,7 @@ def start_port_forward(
217
222
  service_name: str,
218
223
  service_port: int,
219
224
  port: int,
220
- ip: str | None,
225
+ ip: str = LOCALHOST,
221
226
  context: str | None = None,
222
227
  namespace: str | None = None,
223
228
  ) -> None:
@@ -232,8 +237,8 @@ def start_port_forward(
232
237
  The port on the service to forward.
233
238
  port : int
234
239
  The port to listen on.
235
- ip : str | None
236
- The IP address to listen on. If None, defaults to localhost.
240
+ ip : str
241
+ The IP address to listen on. Defaults to localhost.
237
242
  context : str | None
238
243
  The Kubernetes context to use.
239
244
  namespace : str | None
@@ -264,20 +269,22 @@ def start_port_forward(
264
269
  timeout = 300 # seconds
265
270
  while time.time() - start_time < timeout:
266
271
  try:
267
- result = (
268
- subprocess.check_output(
269
- [
270
- "kubectl",
271
- "get",
272
- "endpoints",
273
- service_name,
274
- "-o",
275
- "jsonpath={.subsets[*].addresses[*].ip}",
276
- ]
277
- )
278
- .decode()
279
- .strip()
280
- )
272
+ command = [
273
+ "kubectl",
274
+ "get",
275
+ "endpoints",
276
+ service_name,
277
+ "-o",
278
+ "jsonpath={.subsets[*].addresses[*].ip}",
279
+ ]
280
+
281
+ if context:
282
+ command.extend(["--context", context])
283
+
284
+ if namespace:
285
+ command.extend(["--namespace", namespace])
286
+
287
+ result = subprocess.check_output(command).decode().strip()
281
288
 
282
289
  if result:
283
290
  info(f"Service '{service_name}' is ready.")
@@ -288,13 +295,14 @@ def start_port_forward(
288
295
  time.sleep(2)
289
296
  else:
290
297
  error(
291
- f"Timeout: Service '{service_name}' has no ready endpoints after {timeout} seconds."
298
+ f"Timeout: Service '{service_name}' has no ready endpoints after {timeout} "
299
+ "seconds."
292
300
  )
293
301
  return
294
302
 
295
303
  # Create the port forwarding command
296
304
  if not ip:
297
- ip = "localhost"
305
+ ip = LOCALHOST
298
306
 
299
307
  command = [
300
308
  "kubectl",
@@ -8,6 +8,7 @@ from vantage6.common import error, info, warning
8
8
  from vantage6.common.globals import InstanceType
9
9
 
10
10
  from vantage6.cli.common.utils import (
11
+ extract_name_and_is_sandbox,
11
12
  find_running_service_names,
12
13
  select_context_and_namespace,
13
14
  select_running_service,
@@ -26,6 +27,8 @@ def execute_stop(
26
27
  namespace: str,
27
28
  context: str,
28
29
  system_folders: bool,
30
+ is_sandbox: bool = False,
31
+ stop_function_args: dict | None = None,
29
32
  ):
30
33
  """
31
34
  Execute the stop function for a given instance type and infra component.
@@ -41,19 +44,25 @@ def execute_stop(
41
44
  stop_all : bool
42
45
  Whether to stop all services.
43
46
  to_stop : str | None
44
- The name of the service to stop.
47
+ The name of the service to stop. If None, the user will be asked to select a
48
+ service.
45
49
  namespace : str
46
50
  The namespace of the service.
47
51
  context : str
48
52
  The context of the service.
49
53
  system_folders : bool
50
54
  Whether to use system folders.
55
+ is_sandbox : bool
56
+ Whether the configuration is a sandbox configuration, by default False
57
+ stop_function_args : dict | None
58
+ Additional arguments to pass to the stop function
51
59
  """
60
+ if stop_function_args is None:
61
+ stop_function_args = {}
52
62
  context, namespace = select_context_and_namespace(
53
63
  context=context,
54
64
  namespace=namespace,
55
65
  )
56
-
57
66
  running_services = find_running_service_names(
58
67
  instance_type=instance_type,
59
68
  only_system_folders=system_folders,
@@ -73,11 +82,14 @@ def execute_stop(
73
82
  if not to_stop:
74
83
  helm_name = select_running_service(running_services, instance_type)
75
84
  else:
76
- ctx = get_context(instance_type, to_stop, system_folders)
85
+ to_stop, is_sandbox = extract_name_and_is_sandbox(to_stop, is_sandbox)
86
+ ctx = get_context(
87
+ instance_type, to_stop, system_folders, is_sandbox=is_sandbox
88
+ )
77
89
  helm_name = ctx.helm_release_name
78
90
 
79
91
  if helm_name in running_services:
80
- stop_function(helm_name, namespace, context)
92
+ stop_function(helm_name, namespace, context, **stop_function_args)
81
93
  info(
82
94
  f"Stopped the {Fore.GREEN}{helm_name}{Style.RESET_ALL} {infra_component.value}."
83
95
  )
@@ -1,19 +1,20 @@
1
1
  import json
2
2
  import subprocess
3
3
  from pathlib import Path
4
- from subprocess import Popen
5
4
  from typing import Iterable
6
5
 
7
- import click
8
6
  import docker
9
7
  import questionary as q
10
- from colorama import Fore, Style
11
8
 
12
- from vantage6.common import error, warning
13
- from vantage6.common.globals import APPNAME, STRING_ENCODING, InstanceType
9
+ from vantage6.common import error
10
+ from vantage6.common.globals import (
11
+ APPNAME,
12
+ SANDBOX_SUFFIX,
13
+ STRING_ENCODING,
14
+ InstanceType,
15
+ )
14
16
 
15
17
  from vantage6.cli.config import CliConfig
16
- from vantage6.cli.context import select_context_class
17
18
  from vantage6.cli.globals import CLICommandName
18
19
  from vantage6.cli.utils import validate_input_cmd_args
19
20
 
@@ -66,6 +67,7 @@ def find_running_service_names(
66
67
  only_user_folders: bool = False,
67
68
  context: str | None = None,
68
69
  namespace: str | None = None,
70
+ sandbox: bool = False,
69
71
  ) -> list[str]:
70
72
  """
71
73
  List running Vantage6 servers.
@@ -82,6 +84,8 @@ def find_running_service_names(
82
84
  The Kubernetes context to use.
83
85
  namespace : str, optional
84
86
  The Kubernetes namespace to use.
87
+ sandbox : bool, optional
88
+ Whether to look for sandbox services or not. By default False.
85
89
 
86
90
  Returns
87
91
  -------
@@ -248,60 +252,6 @@ def get_running_servers(
248
252
  return [server.name for server in running_servers]
249
253
 
250
254
 
251
- def get_server_configuration_list(instance_type: InstanceType) -> None:
252
- """
253
- Print list of available server configurations.
254
-
255
- Parameters
256
- ----------
257
- instance_type : InstanceType
258
- The type of instance to get the configurations for
259
- """
260
- ctx_class = select_context_class(instance_type)
261
-
262
- running_server_names = find_running_service_names(instance_type)
263
- header = "\nName" + (21 * " ") + "Status" + (10 * " ") + "System/User"
264
-
265
- click.echo(header)
266
- click.echo("-" * len(header))
267
-
268
- running = Fore.GREEN + "Running" + Style.RESET_ALL
269
- stopped = Fore.RED + "Not running" + Style.RESET_ALL
270
-
271
- # system folders
272
- configs, failed_imports_system = ctx_class.available_configurations(
273
- system_folders=True
274
- )
275
- for config in configs:
276
- status = (
277
- running
278
- if f"{APPNAME}-{config.name}-system-{instance_type.value}"
279
- in running_server_names
280
- else stopped
281
- )
282
- click.echo(f"{config.name:25}{status:25} System ")
283
-
284
- # user folders
285
- configs, failed_imports_user = ctx_class.available_configurations(
286
- system_folders=False
287
- )
288
- for config in configs:
289
- status = (
290
- running
291
- if f"{APPNAME}-{config.name}-user-{instance_type.value}"
292
- in running_server_names
293
- else stopped
294
- )
295
- click.echo(f"{config.name:25}{status:25} User ")
296
-
297
- click.echo("-" * 85)
298
- if len(failed_imports_system) + len(failed_imports_user):
299
- warning(
300
- f"{Fore.RED}Failed imports: "
301
- f"{len(failed_imports_system) + len(failed_imports_user)}{Style.RESET_ALL}"
302
- )
303
-
304
-
305
255
  def print_log_worker(logs_stream: Iterable[bytes]) -> None:
306
256
  """
307
257
  Print the logs from the logs stream.
@@ -351,20 +301,6 @@ def get_config_name_from_service_name(service_name: str) -> str:
351
301
  return "-".join(service_name.split("-")[1:-2])
352
302
 
353
303
 
354
- def attach_logs(*labels: list[str]) -> None:
355
- """
356
- Attach to the logs of the given labels.
357
-
358
- Parameters
359
- ----------
360
- labels : list[str]
361
- The labels to attach to
362
- """
363
- command = ["kubectl", "logs", "--follow", "--selector", ",".join(labels)]
364
- process = Popen(command, stdout=None, stderr=None)
365
- process.wait()
366
-
367
-
368
304
  def get_main_cli_command_name(instance_type: InstanceType) -> str:
369
305
  """
370
306
  Get the main CLI command name for a given instance type.
@@ -414,3 +350,58 @@ def check_running(
414
350
  only_user_folders=not system_folders,
415
351
  )
416
352
  return helm_release_name in running_services
353
+
354
+
355
+ def get_config_name_from_helm_release_name(
356
+ helm_release_name: str, is_store: bool = False
357
+ ) -> str:
358
+ """
359
+ Get the config name from a helm release name.
360
+
361
+ Parameters
362
+ ----------
363
+ helm_release_name : str
364
+ The name of the Helm release
365
+ is_store : bool, optional
366
+ Whether the instance is a store or not. By default False.
367
+
368
+ Returns
369
+ -------
370
+ str
371
+ The config name
372
+ """
373
+ # helm release name is structured as:
374
+ # f"{APPNAME}-{name}-{scope}-{instance_type}"
375
+ # we want to get the name from the service name
376
+ if is_store:
377
+ # for store, the instance type is `algorithm-store` which contains an additional
378
+ # hyphen
379
+ return "-".join(helm_release_name.split("-")[1:-3])
380
+ else:
381
+ return "-".join(helm_release_name.split("-")[1:-2])
382
+
383
+
384
+ def extract_name_and_is_sandbox(name: str | None, is_sandbox: bool) -> tuple[str, bool]:
385
+ """
386
+ Extract the name and is_sandbox from the name.
387
+
388
+ Note that the name may be None: this occurs before when this function is called
389
+ before the user has selected a name. This scenario is fine because when the user
390
+ selects a name interactively, the name never ends with the .sandbox suffix.
391
+
392
+ Parameters
393
+ ----------
394
+ name : str | None
395
+ The name of the instance
396
+ is_sandbox : bool
397
+ Whether the instance is a sandbox instance
398
+
399
+ Returns
400
+ -------
401
+ tuple[str, bool]
402
+ The name and is_sandbox
403
+ """
404
+ if name and name.endswith(SANDBOX_SUFFIX):
405
+ return name[: -len(SANDBOX_SUFFIX)], True
406
+ else:
407
+ return name, is_sandbox