vantage6 5.0.0a22__py3-none-any.whl → 5.0.0a29__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 (55) hide show
  1. tests_cli/test_client_script.py +23 -0
  2. tests_cli/test_server_cli.py +7 -6
  3. tests_cli/test_wizard.py +7 -7
  4. vantage6/cli/__build__ +1 -1
  5. vantage6/cli/algorithm/generate_algorithm_json.py +531 -0
  6. vantage6/cli/algostore/list.py +2 -1
  7. vantage6/cli/algostore/start.py +6 -6
  8. vantage6/cli/algostore/stop.py +3 -2
  9. vantage6/cli/cli.py +25 -0
  10. vantage6/cli/common/decorator.py +3 -1
  11. vantage6/cli/common/start.py +221 -12
  12. vantage6/cli/common/stop.py +90 -0
  13. vantage6/cli/common/utils.py +15 -20
  14. vantage6/cli/config.py +260 -0
  15. vantage6/cli/configuration_manager.py +8 -14
  16. vantage6/cli/configuration_wizard.py +66 -111
  17. vantage6/cli/context/__init__.py +2 -1
  18. vantage6/cli/context/algorithm_store.py +10 -7
  19. vantage6/cli/context/node.py +38 -54
  20. vantage6/cli/context/server.py +36 -5
  21. vantage6/cli/dev/create.py +88 -29
  22. vantage6/cli/dev/data/km_dataset.csv +2401 -0
  23. vantage6/cli/dev/remove.py +99 -98
  24. vantage6/cli/globals.py +24 -4
  25. vantage6/cli/node/common/__init__.py +6 -5
  26. vantage6/cli/node/new.py +4 -3
  27. vantage6/cli/node/remove.py +4 -2
  28. vantage6/cli/node/start.py +33 -42
  29. vantage6/cli/prometheus/monitoring_manager.py +146 -0
  30. vantage6/cli/prometheus/prometheus.yml +5 -0
  31. vantage6/cli/server/files.py +4 -2
  32. vantage6/cli/server/import_.py +7 -7
  33. vantage6/cli/server/list.py +2 -1
  34. vantage6/cli/server/new.py +25 -6
  35. vantage6/cli/server/shell.py +5 -4
  36. vantage6/cli/server/start.py +44 -213
  37. vantage6/cli/server/stop.py +36 -105
  38. vantage6/cli/server/version.py +5 -4
  39. vantage6/cli/template/algo_store_config.j2 +0 -1
  40. vantage6/cli/template/node_config.j2 +3 -1
  41. vantage6/cli/template/server_import_config.j2 +0 -2
  42. vantage6/cli/test/algo_test_scripts/algo_test_arguments.py +29 -0
  43. vantage6/cli/test/algo_test_scripts/algo_test_script.py +92 -0
  44. vantage6/cli/test/client_script.py +151 -0
  45. vantage6/cli/test/common/diagnostic_runner.py +2 -2
  46. vantage6/cli/test/feature_tester.py +5 -2
  47. vantage6/cli/use/context.py +46 -0
  48. vantage6/cli/use/namespace.py +55 -0
  49. vantage6/cli/utils.py +70 -4
  50. {vantage6-5.0.0a22.dist-info → vantage6-5.0.0a29.dist-info}/METADATA +15 -11
  51. vantage6-5.0.0a29.dist-info/RECORD +84 -0
  52. {vantage6-5.0.0a22.dist-info → vantage6-5.0.0a29.dist-info}/WHEEL +1 -1
  53. vantage6-5.0.0a22.dist-info/RECORD +0 -72
  54. {vantage6-5.0.0a22.dist-info → vantage6-5.0.0a29.dist-info}/entry_points.txt +0 -0
  55. {vantage6-5.0.0a22.dist-info → vantage6-5.0.0a29.dist-info}/top_level.txt +0 -0
@@ -1,12 +1,14 @@
1
1
  import click
2
2
 
3
3
  from vantage6.common import info
4
- from vantage6.cli.context.server import ServerContext
4
+ from vantage6.common.globals import InstanceType
5
+
5
6
  from vantage6.cli.common.decorator import click_insert_context
7
+ from vantage6.cli.context.server import ServerContext
6
8
 
7
9
 
8
10
  @click.command()
9
- @click_insert_context(type_="server")
11
+ @click_insert_context(type_=InstanceType.SERVER)
10
12
  def cli_server_files(ctx: ServerContext) -> None:
11
13
  """
12
14
  List files that belong to a particular server instance.
@@ -4,7 +4,6 @@ from threading import Thread
4
4
  import click
5
5
  import docker
6
6
  from sqlalchemy.engine.url import make_url
7
- from vantage6.cli.globals import ServerGlobals
8
7
 
9
8
  from vantage6.common import info, warning
10
9
  from vantage6.common.docker.addons import check_docker_running, pull_image
@@ -14,10 +13,12 @@ from vantage6.common.globals import (
14
13
  DEFAULT_SERVER_IMAGE,
15
14
  InstanceType,
16
15
  )
17
- from vantage6.cli.context.server import ServerContext
18
- from vantage6.cli.utils import check_config_name_allowed
16
+
19
17
  from vantage6.cli.common.decorator import click_insert_context
20
18
  from vantage6.cli.common.utils import print_log_worker
19
+ from vantage6.cli.context.server import ServerContext
20
+ from vantage6.cli.globals import ServerGlobals
21
+ from vantage6.cli.utils import check_config_name_allowed
21
22
 
22
23
 
23
24
  # TODO this method has a lot of duplicated code from `start`
@@ -33,8 +34,7 @@ from vantage6.cli.common.utils import print_log_worker
33
34
  @click.option(
34
35
  "--mount-src",
35
36
  default="",
36
- help="Override vantage6 source code in container with the source"
37
- " code in this path",
37
+ help="Override vantage6 source code in container with the source code in this path",
38
38
  )
39
39
  @click.option(
40
40
  "--keep/--auto-remove",
@@ -42,7 +42,7 @@ from vantage6.cli.common.utils import print_log_worker
42
42
  help="Keep image after finishing. Useful for debugging",
43
43
  )
44
44
  @click.option("--wait", default=False, help="Wait for the import to finish")
45
- @click_insert_context(type_="server")
45
+ @click_insert_context(type_=InstanceType.SERVER)
46
46
  def cli_server_import(
47
47
  ctx: ServerContext,
48
48
  file: str,
@@ -111,7 +111,7 @@ def cli_server_import(
111
111
  mounts.append(docker.types.Mount("/mnt/database/", dirname, type="bind"))
112
112
 
113
113
  environment_vars = {
114
- ServerGlobals.DB_URI_ENV_VAR: f"sqlite:////mnt/database/{basename}"
114
+ ServerGlobals.DB_URI_ENV_VAR.value: f"sqlite:////mnt/database/{basename}"
115
115
  }
116
116
 
117
117
  else:
@@ -2,6 +2,7 @@ import click
2
2
 
3
3
  from vantage6.common.docker.addons import check_docker_running
4
4
  from vantage6.common.globals import InstanceType
5
+
5
6
  from vantage6.cli.common.utils import get_server_configuration_list
6
7
 
7
8
 
@@ -12,4 +13,4 @@ def cli_server_configuration_list() -> None:
12
13
  """
13
14
  check_docker_running()
14
15
 
15
- get_server_configuration_list(InstanceType.SERVER.value)
16
+ get_server_configuration_list(InstanceType.SERVER)
@@ -1,12 +1,14 @@
1
1
  import click
2
2
  from colorama import Fore, Style
3
3
 
4
- from vantage6.common import info, error, ensure_config_dir_writable
5
- from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
6
- from vantage6.cli.context.server import ServerContext
4
+ from vantage6.common import ensure_config_dir_writable, error, info
5
+ from vantage6.common.globals import InstanceType
6
+
7
+ from vantage6.cli.config import CliConfig
7
8
  from vantage6.cli.configuration_wizard import configuration_wizard
9
+ from vantage6.cli.context.server import ServerContext
10
+ from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
8
11
  from vantage6.cli.utils import check_config_name_allowed, prompt_config_name
9
- from vantage6.common.globals import InstanceType
10
12
 
11
13
 
12
14
  @click.command()
@@ -17,13 +19,30 @@ from vantage6.common.globals import InstanceType
17
19
  @click.option(
18
20
  "--user", "system_folders", flag_value=False, default=DEFAULT_SERVER_SYSTEM_FOLDERS
19
21
  )
20
- def cli_server_new(name: str, system_folders: bool) -> None:
22
+ @click.option("--context", default=None, help="Kubernetes context to use")
23
+ @click.option(
24
+ "--namespace",
25
+ default=None,
26
+ help="Kubernetes namespace to use",
27
+ )
28
+ def cli_server_new(
29
+ name: str,
30
+ system_folders: bool,
31
+ namespace: str,
32
+ context: str,
33
+ ) -> None:
21
34
  """
22
35
  Create a new server configuration.
23
36
  """
37
+ cli_config = CliConfig()
38
+ context, namespace = cli_config.compare_changes_config(
39
+ context=context,
40
+ namespace=namespace,
41
+ )
42
+
24
43
  name = prompt_config_name(name)
25
44
 
26
- # check if name is allowed for docker volume, else exit
45
+ # check if name is valid
27
46
  check_config_name_allowed(name)
28
47
 
29
48
  # check that this config does not exist
@@ -4,15 +4,16 @@ import click
4
4
  import docker
5
5
  from colorama import Fore, Style
6
6
 
7
- from vantage6.common import info, error, debug as debug_msg
7
+ from vantage6.common import debug as debug_msg, error, info
8
8
  from vantage6.common.docker.addons import check_docker_running
9
9
  from vantage6.common.globals import APPNAME, InstanceType
10
- from vantage6.cli.context.server import ServerContext
10
+
11
11
  from vantage6.cli.common.decorator import click_insert_context
12
+ from vantage6.cli.context.server import ServerContext
12
13
 
13
14
 
14
15
  @click.command()
15
- @click_insert_context(type_="server")
16
+ @click_insert_context(type_=InstanceType.SERVER)
16
17
  def cli_server_shell(ctx: ServerContext) -> None:
17
18
  """
18
19
  Run an iPython shell within a running server. This can be used to modify
@@ -28,7 +29,7 @@ def cli_server_shell(ctx: ServerContext) -> None:
28
29
  docker_client = docker.from_env()
29
30
 
30
31
  running_servers = docker_client.containers.list(
31
- filters={"label": f"{APPNAME}-type={InstanceType.SERVER.value}"}
32
+ filters={"label": f"{APPNAME}-type={InstanceType.SERVER}"}
32
33
  )
33
34
 
34
35
  if ctx.docker_container_name not in [s.name for s in running_servers]:
@@ -1,256 +1,87 @@
1
1
  import click
2
- import docker
3
- from docker.client import DockerClient
4
2
 
5
- from vantage6.common import info, warning, error
6
- from vantage6.common.docker.network_manager import NetworkManager
7
- from vantage6.common.globals import (
8
- APPNAME,
9
- DEFAULT_SERVER_IMAGE,
10
- DEFAULT_UI_IMAGE,
11
- InstanceType,
12
- )
3
+ from vantage6.common import info
4
+ from vantage6.common.globals import InstanceType
13
5
 
14
- from vantage6.common.globals import Ports
15
- from vantage6.cli.context.server import ServerContext
16
- from vantage6.cli.rabbitmq.queue_manager import RabbitMQManager
17
- from vantage6.cli.server.common import stop_ui
18
6
  from vantage6.cli.common.decorator import click_insert_context
19
7
  from vantage6.cli.common.start import (
20
- attach_logs,
21
- check_for_start,
22
- get_image,
23
- mount_database,
24
- mount_source,
25
- pull_infra_image,
8
+ helm_install,
9
+ start_port_forward,
26
10
  )
11
+ from vantage6.cli.common.utils import attach_logs
12
+ from vantage6.cli.config import CliConfig
13
+ from vantage6.cli.context.server import ServerContext
27
14
 
28
15
 
29
16
  @click.command()
17
+ @click.option("--context", default=None, help="Kubernetes context to use")
18
+ @click.option("--namespace", default=None, help="Kubernetes namespace to use")
30
19
  @click.option("--ip", default=None, help="IP address to listen on")
31
- @click.option("-p", "--port", default=None, type=int, help="Port to listen on")
32
- @click.option("-i", "--image", default=None, help="Server Docker image to use")
33
20
  @click.option(
34
- "--with-ui",
35
- "start_ui",
36
- flag_value=True,
37
- default=False,
38
- help="Start the graphical User Interface as well",
21
+ "-p", "--port", default=None, type=int, help="Port to listen on for the server"
39
22
  )
40
23
  @click.option(
41
24
  "--ui-port", default=None, type=int, help="Port to listen on for the User Interface"
42
25
  )
43
- @click.option(
44
- "--with-rabbitmq",
45
- "start_rabbitmq",
46
- flag_value=True,
47
- default=False,
48
- help="Start RabbitMQ message broker as local "
49
- "container - use in development only",
50
- )
51
- @click.option("--rabbitmq-image", default=None, help="RabbitMQ docker image to use")
52
- @click.option(
53
- "--keep/--auto-remove",
54
- default=False,
55
- help="Keep image after server has stopped. Useful for debugging",
56
- )
57
- @click.option(
58
- "--mount-src",
59
- default="",
60
- help="Override vantage6 source code in container with the source"
61
- " code in this path",
62
- )
63
26
  @click.option(
64
27
  "--attach/--detach",
65
28
  default=False,
66
29
  help="Print server logs to the console after start",
67
30
  )
68
- @click_insert_context(type_="server")
31
+ @click_insert_context(type_=InstanceType.SERVER)
69
32
  def cli_server_start(
70
33
  ctx: ServerContext,
34
+ context: str,
35
+ namespace: str,
71
36
  ip: str,
72
37
  port: int,
73
- image: str,
74
- start_ui: bool,
75
38
  ui_port: int,
76
- start_rabbitmq: bool,
77
- rabbitmq_image: str,
78
- keep: bool,
79
- mount_src: str,
80
39
  attach: bool,
81
40
  ) -> None:
82
41
  """
83
42
  Start the server.
84
43
  """
85
44
  info("Starting server...")
86
- docker_client = check_for_start(ctx, InstanceType.SERVER.value)
45
+ cli_config = CliConfig()
87
46
 
88
- image = get_image(image, ctx, "server", DEFAULT_SERVER_IMAGE)
47
+ context, namespace = cli_config.compare_changes_config(
48
+ context=context,
49
+ namespace=namespace,
50
+ )
89
51
 
90
52
  # check that log directory exists - or create it
91
53
  ctx.log_dir.mkdir(parents=True, exist_ok=True)
92
54
 
93
- info("Pulling server image...")
94
- pull_infra_image(docker_client, image, InstanceType.SERVER)
95
-
96
- info("Creating mounts")
97
- config_file = "/mnt/config.yaml"
98
- mounts = [
99
- docker.types.Mount(config_file, str(ctx.config_file), type="bind"),
100
- docker.types.Mount("/mnt/log/", str(ctx.log_dir), type="bind"),
101
- ]
102
-
103
- src_mount = mount_source(mount_src)
104
- if src_mount:
105
- mounts.append(src_mount)
106
-
107
- mount, environment_vars = mount_database(ctx, InstanceType.SERVER)
108
- if mount:
109
- mounts.append(mount)
110
-
111
- # Create a docker network for the server and other services like RabbitMQ
112
- # to reside in
113
- server_network_mgr = NetworkManager(
114
- network_name=f"{APPNAME}-{ctx.name}-{ctx.scope}-network"
55
+ release_name = f"{ctx.name}-{ctx.instance_type}"
56
+ helm_install(
57
+ release_name=release_name,
58
+ chart_name="server",
59
+ values_file=ctx.config_file,
60
+ context=context,
61
+ namespace=namespace,
115
62
  )
116
- server_network_mgr.create_network(is_internal=False)
117
-
118
- if (
119
- start_rabbitmq
120
- or ctx.config.get("rabbitmq")
121
- and ctx.config["rabbitmq"].get("start_with_server", False)
122
- ):
123
- # Note that ctx.data_dir has been created at this point, which is
124
- # required for putting some RabbitMQ configuration files inside
125
- info("Starting RabbitMQ container")
126
- _start_rabbitmq(ctx, rabbitmq_image, server_network_mgr)
127
- elif ctx.config.get("rabbitmq"):
128
- info(
129
- "RabbitMQ is provided in the config file as external service. "
130
- "Assuming this service is up and running."
131
- )
132
- else:
133
- warning(
134
- "Message queue is not set up! This means that the vantage6 server "
135
- "cannot be scaled horizontally!"
136
- )
137
-
138
- # start the UI if requested
139
- if start_ui or ctx.config.get("ui") and ctx.config["ui"].get("enabled"):
140
- _start_ui(docker_client, ctx, ui_port)
141
63
 
142
- # The `ip` and `port` refer here to the ip and port within the container.
143
- # So we do not really care that is it listening on all interfaces.
144
- internal_port = 5000
145
- cmd = (
146
- f"uwsgi --http :{internal_port} --gevent 1000 --http-websockets "
147
- "--master --callable app --disable-logging "
148
- "--wsgi-file /vantage6/vantage6-server/vantage6/server/wsgi.py "
149
- f"--pyargv {config_file}"
64
+ # port forward for server
65
+ info("Port forwarding for server")
66
+ start_port_forward(
67
+ service_name=f"{release_name}-vantage6-server-service",
68
+ service_port=ctx.config["server"].get("port", 7601),
69
+ port=port or ctx.config["server"].get("port", 7601),
70
+ ip=ip,
71
+ context=context,
72
+ namespace=namespace,
150
73
  )
151
- info(cmd)
152
74
 
153
- info("Run Docker container")
154
- port_ = str(port or ctx.config["port"] or Ports.DEV_SERVER.value)
155
- container = docker_client.containers.run(
156
- image,
157
- command=cmd,
158
- mounts=mounts,
159
- detach=True,
160
- labels={
161
- f"{APPNAME}-type": InstanceType.SERVER.value,
162
- "name": ctx.config_file_name,
163
- },
164
- environment=environment_vars,
165
- ports={f"{internal_port}/tcp": (ip, port_)},
166
- name=ctx.docker_container_name,
167
- auto_remove=not keep,
168
- tty=True,
169
- network=server_network_mgr.network_name,
75
+ # port forward for UI
76
+ info("Port forwarding for UI")
77
+ start_port_forward(
78
+ service_name=f"{release_name}-vantage6-frontend-service",
79
+ service_port=ctx.config["ui"].get("port", 7600),
80
+ port=ui_port or ctx.config["ui"].get("port", 7600),
81
+ ip=ip,
82
+ context=context,
83
+ namespace=namespace,
170
84
  )
171
85
 
172
- info(f"Success! container id = {container.id}")
173
-
174
86
  if attach:
175
- attach_logs(container, InstanceType.SERVER)
176
-
177
-
178
- def _start_rabbitmq(
179
- ctx: ServerContext, rabbitmq_image: str, network_mgr: NetworkManager
180
- ) -> None:
181
- """
182
- Start the RabbitMQ container if it is not already running.
183
-
184
- Parameters
185
- ----------
186
- ctx : ServerContext
187
- Server context object
188
- rabbitmq_image : str
189
- RabbitMQ image to use
190
- network_mgr : NetworkManager
191
- Network manager object
192
- """
193
- rabbit_uri = ctx.config["rabbitmq"].get("uri")
194
- if not rabbit_uri:
195
- error(
196
- "No RabbitMQ URI found in the configuration file! Please add"
197
- "a 'uri' key to the 'rabbitmq' section of the configuration."
198
- )
199
- exit(1)
200
- # kick off RabbitMQ container
201
- rabbit_mgr = RabbitMQManager(ctx=ctx, network_mgr=network_mgr, image=rabbitmq_image)
202
- rabbit_mgr.start()
203
-
204
-
205
- def _start_ui(client: DockerClient, ctx: ServerContext, ui_port: int) -> None:
206
- """
207
- Start the UI container.
208
-
209
- Parameters
210
- ----------
211
- client : DockerClient
212
- Docker client
213
- ctx : ServerContext
214
- Server context object
215
- ui_port : int
216
- Port to expose the UI on
217
- """
218
- # if no port is specified, check if config contains a port
219
- ui_config = ctx.config.get("ui")
220
- if ui_config and not ui_port:
221
- ui_port = ui_config.get("port")
222
-
223
- # check if the port is valid
224
- # TODO make function to check if port is valid, and use in more places
225
- if not isinstance(ui_port, int) or not 0 < ui_port < 65536:
226
- warning(
227
- f"UI port '{ui_port}' is not valid! Using default port "
228
- f"{Ports.DEV_UI.value}"
229
- )
230
- ui_port = str(Ports.DEV_UI.value)
231
-
232
- # find image to use
233
- image = get_image(None, ctx, "ui", DEFAULT_UI_IMAGE)
234
-
235
- pull_infra_image(client, image, InstanceType.UI)
236
-
237
- # set environment variables
238
- env_vars = {
239
- "SERVER_URL": f"http://localhost:{ctx.config.get('port')}",
240
- "API_PATH": ctx.config.get("api_path"),
241
- }
242
-
243
- # stop the UI container if it is already running
244
- stop_ui(client, ctx)
245
-
246
- info(f"Starting User Interface at port {ui_port}")
247
- ui_container_name = f"{APPNAME}-{ctx.name}-{ctx.scope}-ui"
248
- client.containers.run(
249
- image,
250
- detach=True,
251
- labels={f"{APPNAME}-type": "ui", "name": ctx.config_file_name},
252
- ports={"80/tcp": (ctx.config.get("ip"), ui_port)},
253
- name=ui_container_name,
254
- environment=env_vars,
255
- tty=True,
256
- )
87
+ attach_logs("app=vantage6-server", "component=vantage6-server")
@@ -1,119 +1,50 @@
1
1
  import click
2
- import questionary as q
3
- import docker
4
- from colorama import Fore, Style
5
- from docker.client import DockerClient
6
2
 
7
- from vantage6.common import info, warning, error
8
- from vantage6.common.docker.addons import (
9
- check_docker_running,
10
- remove_container,
11
- get_server_config_name,
12
- get_container,
13
- get_num_nonempty_networks,
14
- get_network,
15
- delete_network,
16
- remove_container_if_exists,
17
- )
18
- from vantage6.common.globals import APPNAME, InstanceType
19
- from vantage6.common import split_rabbitmq_uri
3
+ from vantage6.common import info
4
+ from vantage6.common.globals import InstanceType
5
+
6
+ from vantage6.cli.common.decorator import click_insert_context
7
+ from vantage6.cli.common.stop import helm_uninstall, stop_port_forward
8
+ from vantage6.cli.config import CliConfig
20
9
  from vantage6.cli.context.server import ServerContext
21
- from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
22
- from vantage6.cli.server.common import get_server_context, stop_ui
23
10
 
24
11
 
25
12
  @click.command()
26
- @click.option("-n", "--name", default=None, help="Configuration name")
27
- @click.option("--system", "system_folders", flag_value=True)
28
- @click.option(
29
- "--user", "system_folders", flag_value=False, default=DEFAULT_SERVER_SYSTEM_FOLDERS
30
- )
31
- @click.option("--all", "all_servers", flag_value=True, help="Stop all servers")
32
- def cli_server_stop(name: str, system_folders: bool, all_servers: bool):
13
+ # add context and namespace options
14
+ @click.option("--context", default=None, help="Kubernetes context to use")
15
+ @click.option("--namespace", default=None, help="Kubernetes namespace to use")
16
+ @click_insert_context(type_=InstanceType.SERVER)
17
+ def cli_server_stop(
18
+ ctx: ServerContext,
19
+ context: str,
20
+ namespace: str,
21
+ ):
33
22
  """
34
- Stop one or all running server(s).
23
+ Stop an running server.
35
24
  """
36
- check_docker_running()
37
- client = docker.from_env()
25
+ cli_config = CliConfig()
38
26
 
39
- running_servers = client.containers.list(
40
- filters={"label": f"{APPNAME}-type={InstanceType.SERVER.value}"}
27
+ context, namespace = cli_config.compare_changes_config(
28
+ context=context,
29
+ namespace=namespace,
41
30
  )
42
31
 
43
- if not running_servers:
44
- warning("No servers are currently running.")
45
- return
46
-
47
- running_server_names = [server.name for server in running_servers]
48
-
49
- if all_servers:
50
- for container_name in running_server_names:
51
- _stop_server_containers(client, container_name, system_folders)
52
- return
53
-
54
- # make sure we have a configuration name to work with
55
- if not name:
56
- try:
57
- container_name = q.select(
58
- "Select the server you wish to stop:", choices=running_server_names
59
- ).unsafe_ask()
60
- except KeyboardInterrupt:
61
- error("Aborted by user!")
62
- return
63
- else:
64
- post_fix = "system" if system_folders else "user"
65
- container_name = f"{APPNAME}-{name}-{post_fix}-{InstanceType.SERVER.value}"
66
-
67
- if container_name not in running_server_names:
68
- error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running!")
69
- return
70
-
71
- _stop_server_containers(client, container_name, system_folders)
72
-
73
-
74
- def _stop_server_containers(
75
- client: DockerClient, container_name: str, system_folders: bool
76
- ) -> None:
77
- """
78
- Given a server's name, kill its docker container and related (RabbitMQ)
79
- containers.
80
-
81
- Parameters
82
- ----------
83
- client : DockerClient
84
- Docker client
85
- container_name : str
86
- Name of the server to stop
87
- system_folders : bool
88
- Wether to use system folders or not
89
- """
90
- # kill the server
91
- remove_container_if_exists(client, name=container_name)
92
- info(f"Stopped the {Fore.GREEN}{container_name}{Style.RESET_ALL} server.")
93
-
94
- # find the configuration name from the docker container name
95
- scope = "system" if system_folders else "user"
96
- config_name = get_server_config_name(container_name, scope)
97
-
98
- ctx = get_server_context(config_name, system_folders, ServerContext)
32
+ # uninstall the helm release
33
+ info("Stopping server...")
34
+ release_name = f"{ctx.name}-{ctx.instance_type}"
35
+ helm_uninstall(
36
+ release_name=release_name,
37
+ context=context,
38
+ namespace=namespace,
39
+ )
99
40
 
100
- # kill the UI container (if it exists)
101
- stop_ui(client, ctx)
41
+ # stop the port forwarding for server and UI
42
+ stop_port_forward(
43
+ service_name=f"{release_name}-vantage6-server-service",
44
+ )
102
45
 
103
- # delete the server network
104
- network_name = f"{APPNAME}-{ctx.name}-{ctx.scope}-network"
105
- network = get_network(client, name=network_name)
106
- delete_network(network, kill_containers=False)
46
+ stop_port_forward(
47
+ service_name=f"{release_name}-vantage6-frontend-service",
48
+ )
107
49
 
108
- # kill RabbitMQ if it exists and no other servers are using to it (i.e. it
109
- # is not in other docker networks with other containers)
110
- rabbit_uri = ctx.config.get("rabbitmq", {}).get("uri")
111
- if rabbit_uri:
112
- rabbit_container_name = split_rabbitmq_uri(rabbit_uri=rabbit_uri)["host"]
113
- rabbit_container = get_container(client, name=rabbit_container_name)
114
- if rabbit_container and get_num_nonempty_networks(rabbit_container) == 0:
115
- remove_container(rabbit_container, kill=True)
116
- info(
117
- f"Stopped the {Fore.GREEN}{rabbit_container_name}"
118
- f"{Style.RESET_ALL} container."
119
- )
50
+ info("Server stopped successfully.")
@@ -4,9 +4,10 @@ import docker
4
4
  from vantage6.common import error
5
5
  from vantage6.common.docker.addons import check_docker_running
6
6
  from vantage6.common.globals import InstanceType
7
- from vantage6.cli.common.utils import get_server_name, get_running_servers
8
- from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
7
+
9
8
  from vantage6.cli import __version__
9
+ from vantage6.cli.common.utils import get_running_servers, get_server_name
10
+ from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
10
11
 
11
12
 
12
13
  @click.command()
@@ -22,10 +23,10 @@ def cli_server_version(name: str, system_folders: bool) -> None:
22
23
  check_docker_running()
23
24
  client = docker.from_env()
24
25
 
25
- running_server_names = get_running_servers(client, InstanceType.SERVER.value)
26
+ running_server_names = get_running_servers(client, InstanceType.SERVER)
26
27
 
27
28
  name = get_server_name(
28
- name, system_folders, running_server_names, InstanceType.SERVER.value
29
+ name, system_folders, running_server_names, InstanceType.SERVER
29
30
  )
30
31
 
31
32
  if name in running_server_names:
@@ -19,5 +19,4 @@ dev:
19
19
  disable_review: true
20
20
  policies:
21
21
  algorithm_view: public
22
- allow_localhost: true
23
22
  {{ user_provided_config }}
@@ -27,5 +27,7 @@ node_proxy_port: {{ node_proxy_port }}
27
27
  port: {{ port }}
28
28
  server_url: {{ server_url }}
29
29
  task_dir: {{ task_dir}}
30
+ dev:
31
+ task_dir_extension: {{ task_dir_extension }}
30
32
  task_namespace: {{ task_namespace }}
31
- {{ user_provided_config }}
33
+ {{- user_provided_config -}}
@@ -9,8 +9,6 @@ organizations:
9
9
  {% if org['make_admin'] %}
10
10
  users:
11
11
  - username: dev_admin
12
- firstname: admin
13
- lastname: robot
14
12
  password: password
15
13
  {% endif %}
16
14
  public_key: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUF2eU4wWVZhWWVZcHVWRVlpaDJjeQphTjdxQndCUnB5bVVibnRQNmw2Vk9OOGE1eGwxMmJPTlQyQ1hwSEVGUFhZQTFFZThQRFZwYnNQcVVKbUlseWpRCkgyN0NhZTlIL2lJbUNVNnViUXlnTzFsbG1KRTJQWDlTNXVxendVV3BXMmRxRGZFSHJLZTErUUlDRGtGSldmSEIKWkJkczRXMTBsMWlxK252dkZ4OWY3dk8xRWlLcVcvTGhQUS83Mm52YlZLMG9nRFNaUy9Jc1NnUlk5ZnJVU1FZUApFbGVZWUgwYmI5VUdlNUlYSHRMQjBkdVBjZUV4dXkzRFF5bXh2WTg3bTlkelJsN1NqaFBqWEszdUplSDAwSndjCk80TzJ0WDVod0lLL1hEQ3h4eCt4b3cxSDdqUWdXQ0FybHpodmdzUkdYUC9wQzEvL1hXaVZSbTJWZ3ZqaXNNaisKS2VTNWNaWWpkUkMvWkRNRW1QU29rS2Y4UnBZUk1lZk0xMWtETTVmaWZIQTlPcmY2UXEyTS9SMy90Mk92VDRlRgorUzVJeTd1QWk1N0ROUkFhejVWRHNZbFFxTU5QcUpKYlRtcGlYRWFpUHVLQitZVEdDSC90TXlrRG1JK1dpejNRCjh6SVo1bk1IUnhySFNqSWdWSFdwYnZlTnVaL1Q1aE95aE1uZHU0c3NpRkJyUXN5ZGc1RlVxR3lkdE1JMFJEVHcKSDVBc1ovaFlLeHdiUm1xTXhNcjFMaDFBaDB5SUlsZDZKREY5MkF1UlNTeDl0djNaVWRndEp5VVlYN29VZS9GKwpoUHVwVU4rdWVTUndGQjBiVTYwRXZQWTdVU2RIR1diVVIrRDRzTVQ4Wjk0UVl2S2ZCanU3ZXVKWSs0Mmd2Wm9jCitEWU9ZS05qNXFER2V5azErOE9aTXZNQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=