vantage6 5.0.0a34__py3-none-any.whl → 5.0.0a36__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.
- vantage6/cli/algorithm/generate_algorithm_json.py +9 -9
- vantage6/cli/algorithm/update.py +1 -1
- vantage6/cli/algostore/attach.py +1 -0
- vantage6/cli/algostore/files.py +3 -2
- vantage6/cli/algostore/list.py +0 -3
- vantage6/cli/algostore/new.py +83 -2
- vantage6/cli/algostore/remove.py +18 -34
- vantage6/cli/algostore/start.py +10 -7
- vantage6/cli/algostore/stop.py +12 -50
- vantage6/cli/auth/attach.py +60 -0
- vantage6/cli/auth/files.py +16 -0
- vantage6/cli/auth/list.py +13 -0
- vantage6/cli/auth/new.py +80 -0
- vantage6/cli/auth/remove.py +31 -0
- vantage6/cli/auth/start.py +80 -0
- vantage6/cli/auth/stop.py +64 -0
- vantage6/cli/cli.py +67 -37
- vantage6/cli/common/new.py +28 -3
- vantage6/cli/common/remove.py +54 -0
- vantage6/cli/common/start.py +31 -2
- vantage6/cli/common/stop.py +79 -1
- vantage6/cli/common/utils.py +47 -4
- vantage6/cli/configuration_manager.py +57 -13
- vantage6/cli/configuration_wizard.py +18 -397
- vantage6/cli/context/__init__.py +3 -0
- vantage6/cli/context/auth.py +107 -0
- vantage6/cli/context/base_server.py +0 -4
- vantage6/cli/context/node.py +10 -17
- vantage6/cli/dev/clean.py +28 -0
- vantage6/cli/dev/common.py +34 -0
- vantage6/cli/dev/rebuild.py +39 -0
- vantage6/cli/dev/start.py +36 -0
- vantage6/cli/dev/stop.py +23 -0
- vantage6/cli/globals.py +24 -1
- vantage6/cli/node/attach.py +1 -0
- vantage6/cli/node/files.py +12 -25
- vantage6/cli/node/list.py +5 -4
- vantage6/cli/node/new.py +348 -28
- vantage6/cli/node/remove.py +14 -90
- vantage6/cli/node/restart.py +30 -51
- vantage6/cli/node/start.py +81 -304
- vantage6/cli/node/stop.py +36 -96
- vantage6/cli/node/version.py +5 -4
- vantage6/cli/prometheus/monitoring_manager.py +5 -3
- vantage6/cli/rabbitmq/queue_manager.py +13 -11
- vantage6/cli/server/attach.py +1 -0
- vantage6/cli/server/common/__init__.py +1 -27
- vantage6/cli/server/import_.py +1 -1
- vantage6/cli/server/new.py +83 -2
- vantage6/cli/server/remove.py +12 -33
- vantage6/cli/server/start.py +8 -6
- vantage6/cli/server/stop.py +10 -39
- vantage6/cli/template/algo_store_config.j2 +1 -1
- vantage6/cli/template/auth_config.j2 +230 -0
- vantage6/cli/template/node_config.j2 +336 -33
- vantage6/cli/template/node_config_nonk8s.j2 +33 -0
- vantage6/cli/test/common/diagnostic_runner.py +5 -3
- vantage6/cli/use/namespace.py +2 -1
- vantage6/cli/utils.py +0 -2
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a36.dist-info}/METADATA +3 -3
- vantage6-5.0.0a36.dist-info/RECORD +86 -0
- vantage6/cli/dev/create.py +0 -693
- vantage6/cli/dev/data/km_dataset.csv +0 -2401
- vantage6/cli/dev/remove.py +0 -112
- vantage6/cli/node/clean.py +0 -46
- vantage6/cli/server/shell.py +0 -54
- vantage6-5.0.0a34.dist-info/RECORD +0 -75
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a36.dist-info}/WHEEL +0 -0
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a36.dist-info}/entry_points.txt +0 -0
vantage6/cli/node/stop.py
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import time
|
|
2
|
-
|
|
3
1
|
import click
|
|
4
|
-
import docker
|
|
5
|
-
import questionary as q
|
|
6
|
-
from colorama import Fore, Style
|
|
7
2
|
|
|
8
|
-
from vantage6.common import
|
|
9
|
-
from vantage6.common.
|
|
10
|
-
check_docker_running,
|
|
11
|
-
delete_volume_if_exists,
|
|
12
|
-
get_server_config_name,
|
|
13
|
-
stop_container,
|
|
14
|
-
)
|
|
15
|
-
from vantage6.common.globals import APPNAME
|
|
3
|
+
from vantage6.common import info
|
|
4
|
+
from vantage6.common.globals import InstanceType
|
|
16
5
|
|
|
17
|
-
from vantage6.cli.
|
|
18
|
-
from vantage6.cli.globals import
|
|
19
|
-
|
|
6
|
+
from vantage6.cli.common.stop import execute_stop, helm_uninstall, stop_port_forward
|
|
7
|
+
from vantage6.cli.globals import (
|
|
8
|
+
DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL,
|
|
9
|
+
InfraComponentName,
|
|
10
|
+
)
|
|
20
11
|
|
|
21
12
|
|
|
22
13
|
@click.command()
|
|
23
14
|
@click.option("-n", "--name", default=None, help="Configuration name")
|
|
15
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
16
|
+
@click.option("--namespace", default=None, help="Kubernetes namespace to use")
|
|
24
17
|
@click.option(
|
|
25
18
|
"--system",
|
|
26
19
|
"system_folders",
|
|
@@ -36,96 +29,43 @@ from vantage6.cli.node.common import find_running_node_names
|
|
|
36
29
|
"system folders. This is the default.",
|
|
37
30
|
)
|
|
38
31
|
@click.option("--all", "all_nodes", flag_value=True, help="Stop all running nodes")
|
|
39
|
-
@click.option(
|
|
40
|
-
"--force",
|
|
41
|
-
"force",
|
|
42
|
-
flag_value=True,
|
|
43
|
-
help="Kill nodes instantly; don't wait for them to shut down",
|
|
44
|
-
)
|
|
45
32
|
def cli_node_stop(
|
|
46
|
-
name: str,
|
|
33
|
+
name: str,
|
|
34
|
+
context: str,
|
|
35
|
+
namespace: str,
|
|
36
|
+
system_folders: bool,
|
|
37
|
+
all_nodes: bool,
|
|
47
38
|
) -> None:
|
|
48
39
|
"""
|
|
49
40
|
Stop one or all running nodes.
|
|
50
41
|
"""
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"host!"
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
if all_nodes:
|
|
68
|
-
for container_name in running_node_names:
|
|
69
|
-
_stop_node(client, container_name, force, system_folders)
|
|
70
|
-
else:
|
|
71
|
-
if not name:
|
|
72
|
-
try:
|
|
73
|
-
container_name = q.select(
|
|
74
|
-
"Select the node you wish to stop:", choices=running_node_names
|
|
75
|
-
).unsafe_ask()
|
|
76
|
-
except KeyboardInterrupt:
|
|
77
|
-
error("Aborted by user!")
|
|
78
|
-
return
|
|
79
|
-
else:
|
|
80
|
-
post_fix = "system" if system_folders else "user"
|
|
81
|
-
container_name = f"{APPNAME}-{name}-{post_fix}"
|
|
82
|
-
|
|
83
|
-
if container_name in running_node_names:
|
|
84
|
-
_stop_node(client, container_name, force, system_folders)
|
|
85
|
-
info(f"Stopped the {Fore.GREEN}{container_name}{Style.RESET_ALL} Node.")
|
|
86
|
-
else:
|
|
87
|
-
error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running?!")
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def _stop_node(
|
|
91
|
-
client: docker.DockerClient, container_name: str, force: bool, system_folders: bool
|
|
92
|
-
) -> None:
|
|
42
|
+
execute_stop(
|
|
43
|
+
stop_function=_stop_node,
|
|
44
|
+
instance_type=InstanceType.NODE,
|
|
45
|
+
infra_component=InfraComponentName.NODE,
|
|
46
|
+
stop_all=all_nodes,
|
|
47
|
+
to_stop=name,
|
|
48
|
+
namespace=namespace,
|
|
49
|
+
context=context,
|
|
50
|
+
system_folders=system_folders,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _stop_node(node_name: str, namespace: str, context: str) -> None:
|
|
93
55
|
"""
|
|
94
56
|
Stop a node
|
|
95
57
|
|
|
96
58
|
Parameters
|
|
97
59
|
----------
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
system_folders : bool
|
|
105
|
-
Whether to use system folders or not
|
|
60
|
+
node_name : str
|
|
61
|
+
Name of the node to stop
|
|
62
|
+
namespace : str
|
|
63
|
+
Kubernetes namespace to use
|
|
64
|
+
context : str
|
|
65
|
+
Kubernetes context to use
|
|
106
66
|
"""
|
|
107
|
-
|
|
108
|
-
# Stop the container. Using stop() gives the container 10s to exit
|
|
109
|
-
# itself, if not then it will be killed
|
|
110
|
-
stop_container(container, force)
|
|
111
|
-
|
|
112
|
-
# Sleep for 1 second. Not doing so often causes errors that docker volumes deleted
|
|
113
|
-
# below are 'still in use' when you try to remove them a few ms after the container
|
|
114
|
-
# has been removed
|
|
115
|
-
time.sleep(1)
|
|
67
|
+
helm_uninstall(release_name=node_name, context=context, namespace=namespace)
|
|
116
68
|
|
|
117
|
-
|
|
118
|
-
# it is stopped, because at that point the volumes are still in use. Here, the node
|
|
119
|
-
# has already been stopped
|
|
120
|
-
scope = "system" if system_folders else "user"
|
|
121
|
-
config_name = get_server_config_name(container_name, scope)
|
|
122
|
-
ctx = NodeContext(config_name, system_folders, print_log_header=False)
|
|
69
|
+
stop_port_forward(service_name=f"{node_name}-vantage6-node-service")
|
|
123
70
|
|
|
124
|
-
|
|
125
|
-
for volume in [
|
|
126
|
-
# ctx.docker_volume_name,
|
|
127
|
-
ctx.docker_squid_volume_name,
|
|
128
|
-
ctx.docker_ssh_volume_name,
|
|
129
|
-
ctx.docker_vpn_volume_name,
|
|
130
|
-
]:
|
|
131
|
-
delete_volume_if_exists(client, volume)
|
|
71
|
+
info(f"Node {node_name} stopped successfully.")
|
vantage6/cli/node/version.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import click
|
|
2
|
-
import questionary as q
|
|
3
2
|
import docker
|
|
3
|
+
import questionary as q
|
|
4
4
|
|
|
5
5
|
from vantage6.common import error
|
|
6
|
-
from vantage6.common.globals import APPNAME
|
|
7
6
|
from vantage6.common.docker.addons import check_docker_running
|
|
8
|
-
from vantage6.
|
|
7
|
+
from vantage6.common.globals import APPNAME
|
|
8
|
+
|
|
9
9
|
from vantage6.cli import __version__
|
|
10
|
+
from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
|
|
10
11
|
from vantage6.cli.node.common import find_running_node_names
|
|
11
12
|
|
|
12
13
|
|
|
@@ -16,7 +17,7 @@ from vantage6.cli.node.common import find_running_node_names
|
|
|
16
17
|
"--system",
|
|
17
18
|
"system_folders",
|
|
18
19
|
flag_value=True,
|
|
19
|
-
help="Search for configuration in system folders rather than
|
|
20
|
+
help="Search for configuration in system folders rather than user folders",
|
|
20
21
|
)
|
|
21
22
|
@click.option(
|
|
22
23
|
"--user",
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import yaml
|
|
2
|
-
import docker
|
|
3
1
|
from pathlib import Path
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
import docker
|
|
4
|
+
import yaml
|
|
5
|
+
|
|
6
|
+
from vantage6.common import error, info
|
|
6
7
|
from vantage6.common.docker.network_manager import NetworkManager
|
|
7
8
|
from vantage6.common.globals import DEFAULT_PROMETHEUS_EXPORTER_PORT
|
|
9
|
+
|
|
8
10
|
from vantage6.cli.context.server import ServerContext
|
|
9
11
|
from vantage6.cli.globals import (
|
|
10
12
|
DEFAULT_PROMETHEUS_IMAGE,
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import base64
|
|
2
|
+
import hashlib
|
|
2
3
|
import json
|
|
3
4
|
import os
|
|
4
5
|
import shutil
|
|
5
|
-
import base64
|
|
6
|
-
import hashlib
|
|
7
6
|
import time
|
|
8
|
-
|
|
9
7
|
from pathlib import Path
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
import docker
|
|
10
|
+
|
|
11
|
+
from vantage6.common import debug, error, info, split_rabbitmq_uri
|
|
13
12
|
from vantage6.common.docker.addons import get_container
|
|
14
13
|
from vantage6.common.docker.network_manager import NetworkManager
|
|
15
|
-
from vantage6.common import
|
|
14
|
+
from vantage6.common.globals import APPNAME
|
|
15
|
+
|
|
16
16
|
from vantage6.cli.context.server import ServerContext
|
|
17
|
-
from vantage6.cli.rabbitmq.definitions import RABBITMQ_DEFINITIONS
|
|
18
17
|
from vantage6.cli.globals import RABBIT_TIMEOUT
|
|
18
|
+
from vantage6.cli.rabbitmq.definitions import RABBITMQ_DEFINITIONS
|
|
19
19
|
|
|
20
20
|
DEFAULT_RABBIT_IMAGE = "harbor2.vantage6.ai/infrastructure/rabbitmq"
|
|
21
21
|
RABBIT_CONFIG = "rabbitmq.config"
|
|
@@ -75,7 +75,7 @@ class RabbitMQManager:
|
|
|
75
75
|
# check if a RabbitMQ container is already running
|
|
76
76
|
self.rabbit_container = get_container(docker_client=self.docker, name=self.host)
|
|
77
77
|
if self.rabbit_container:
|
|
78
|
-
info("RabbitMQ is already running! Linking the server to that
|
|
78
|
+
info("RabbitMQ is already running! Linking the server to that queue")
|
|
79
79
|
if not self.network_mgr.contains(self.rabbit_container):
|
|
80
80
|
self.network_mgr.connect(self.rabbit_container)
|
|
81
81
|
return
|
|
@@ -161,8 +161,10 @@ class RabbitMQManager:
|
|
|
161
161
|
"bind": "/etc/rabbitmq/definitions.json",
|
|
162
162
|
"mode": "ro",
|
|
163
163
|
},
|
|
164
|
-
self.ctx.data_dir
|
|
165
|
-
|
|
164
|
+
self.ctx.data_dir / RABBIT_CONFIG: {
|
|
165
|
+
"bind": "/etc/rabbitmq/rabbitmq.config",
|
|
166
|
+
"mode": "ro",
|
|
167
|
+
},
|
|
166
168
|
rabbit_data_dir: {"bind": "/var/lib/rabbitmq", "mode": "rw"},
|
|
167
169
|
}
|
|
168
170
|
|
vantage6/cli/server/attach.py
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
from docker.client import DockerClient
|
|
2
1
|
from colorama import Fore, Style
|
|
3
2
|
|
|
4
|
-
from vantage6.common import error
|
|
5
|
-
from vantage6.common.globals import APPNAME
|
|
6
|
-
from vantage6.common.docker.addons import remove_container, get_container
|
|
3
|
+
from vantage6.common import error
|
|
7
4
|
from vantage6.common.context import AppContext
|
|
8
5
|
|
|
9
|
-
from vantage6.cli.context.server import ServerContext
|
|
10
|
-
|
|
11
6
|
|
|
12
7
|
def get_server_context(
|
|
13
8
|
name: str, system_folders: bool, ctx_class: AppContext
|
|
@@ -45,24 +40,3 @@ def get_server_context(
|
|
|
45
40
|
ctx = ctx_class(name, system_folders=system_folders)
|
|
46
41
|
|
|
47
42
|
return ctx
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def stop_ui(client: DockerClient, ctx: ServerContext) -> None:
|
|
51
|
-
"""
|
|
52
|
-
Check if the UI container is running, and if so, stop and remove it.
|
|
53
|
-
|
|
54
|
-
Parameters
|
|
55
|
-
----------
|
|
56
|
-
client : DockerClient
|
|
57
|
-
Docker client
|
|
58
|
-
ctx : ServerContext
|
|
59
|
-
Server context object
|
|
60
|
-
"""
|
|
61
|
-
ui_container_name = f"{APPNAME}-{ctx.name}-{ctx.scope}-ui"
|
|
62
|
-
ui_container = get_container(client, name=ui_container_name)
|
|
63
|
-
if ui_container:
|
|
64
|
-
remove_container(ui_container, kill=True)
|
|
65
|
-
info(
|
|
66
|
-
f"Stopped the {Fore.GREEN}{ui_container_name}"
|
|
67
|
-
f"{Style.RESET_ALL} User Interface container."
|
|
68
|
-
)
|
vantage6/cli/server/import_.py
CHANGED
|
@@ -102,7 +102,7 @@ def cli_server_import(
|
|
|
102
102
|
# We're dealing with a relative path here -> make it absolute
|
|
103
103
|
db_path = ctx.data_dir / url.database
|
|
104
104
|
|
|
105
|
-
basename = os.path.basename(db_path)
|
|
105
|
+
# basename = os.path.basename(db_path)
|
|
106
106
|
dirname = os.path.dirname(db_path)
|
|
107
107
|
os.makedirs(dirname, exist_ok=True)
|
|
108
108
|
|
vantage6/cli/server/new.py
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
1
3
|
import click
|
|
4
|
+
import questionary as q
|
|
2
5
|
|
|
3
|
-
from vantage6.common.globals import
|
|
6
|
+
from vantage6.common.globals import (
|
|
7
|
+
InstanceType,
|
|
8
|
+
)
|
|
4
9
|
|
|
5
10
|
from vantage6.cli.common.new import new
|
|
11
|
+
from vantage6.cli.config import CliConfig
|
|
12
|
+
from vantage6.cli.configuration_wizard import add_common_server_config
|
|
6
13
|
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
7
14
|
|
|
8
15
|
|
|
@@ -38,4 +45,78 @@ def cli_server_new(
|
|
|
38
45
|
"""
|
|
39
46
|
Create a new server configuration.
|
|
40
47
|
"""
|
|
41
|
-
|
|
48
|
+
# info(
|
|
49
|
+
# "Vantage6 uses keycloak for authentication. Please configure a keycloak "
|
|
50
|
+
# "server here unless you have one running externally."
|
|
51
|
+
# )
|
|
52
|
+
# configure_keycloak = q.confirm(
|
|
53
|
+
# "Do you want to configure a keycloak server?",
|
|
54
|
+
# default=True,
|
|
55
|
+
# ).unsafe_ask()
|
|
56
|
+
# if configure_keycloak:
|
|
57
|
+
# print("awefawef")
|
|
58
|
+
|
|
59
|
+
new(
|
|
60
|
+
questionnaire_function=server_configuration_questionaire,
|
|
61
|
+
name=name,
|
|
62
|
+
system_folders=system_folders,
|
|
63
|
+
namespace=namespace,
|
|
64
|
+
context=context,
|
|
65
|
+
type_=InstanceType.SERVER,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def server_configuration_questionaire(instance_name: str) -> dict[str, Any]:
|
|
70
|
+
"""
|
|
71
|
+
Kubernetes-specific questionnaire to generate Helm values for server.
|
|
72
|
+
|
|
73
|
+
Parameters
|
|
74
|
+
----------
|
|
75
|
+
instance_name : str
|
|
76
|
+
Name of the server instance.
|
|
77
|
+
|
|
78
|
+
Returns
|
|
79
|
+
-------
|
|
80
|
+
dict[str, Any]
|
|
81
|
+
dictionary with Helm values for the server configuration
|
|
82
|
+
"""
|
|
83
|
+
# Initialize config with basic structure
|
|
84
|
+
config = {"server": {}, "database": {}, "ui": {}, "rabbitmq": {}}
|
|
85
|
+
|
|
86
|
+
config, is_production = add_common_server_config(
|
|
87
|
+
config, InstanceType.SERVER, instance_name
|
|
88
|
+
)
|
|
89
|
+
if not is_production:
|
|
90
|
+
config["server"]["jwt"] = {
|
|
91
|
+
"secret": "constant_development_secret`",
|
|
92
|
+
}
|
|
93
|
+
config["server"]["dev"] = {
|
|
94
|
+
"host_uri": "host.docker.internal",
|
|
95
|
+
"store_in_local_cluster": True,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
# TODO v5+ these should be removed, latest should usually be used so question is
|
|
99
|
+
# not needed. However, for now we want to specify alpha/beta images.
|
|
100
|
+
# === Server settings ===
|
|
101
|
+
config["server"]["image"] = q.text(
|
|
102
|
+
"Server Docker image:",
|
|
103
|
+
default="harbor2.vantage6.ai/infrastructure/server:latest",
|
|
104
|
+
).unsafe_ask()
|
|
105
|
+
|
|
106
|
+
# === UI settings ===
|
|
107
|
+
config["ui"]["image"] = q.text(
|
|
108
|
+
"UI Docker image:",
|
|
109
|
+
default="harbor2.vantage6.ai/infrastructure/ui:latest",
|
|
110
|
+
).unsafe_ask()
|
|
111
|
+
|
|
112
|
+
# TODO v5+ we need to add a question to ask which algorithm stores are allowed, to
|
|
113
|
+
# set the CSP headers in the UI. This is not done now because it becomes easier when
|
|
114
|
+
# store and keycloak service can also be setup in the `v6 server new` command.
|
|
115
|
+
|
|
116
|
+
# === Keycloak settings ===
|
|
117
|
+
cli_config = CliConfig()
|
|
118
|
+
kube_namespace = cli_config.get_last_namespace()
|
|
119
|
+
keycloak_url = f"http://vantage6-auth-keycloak.{kube_namespace}.svc.cluster.local"
|
|
120
|
+
config["server"]["keycloakUrl"] = keycloak_url
|
|
121
|
+
|
|
122
|
+
return config
|
vantage6/cli/server/remove.py
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import itertools
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from shutil import rmtree
|
|
4
|
-
|
|
5
1
|
import click
|
|
6
|
-
import questionary as q
|
|
7
2
|
|
|
8
|
-
from vantage6.common import info
|
|
9
|
-
from vantage6.common.docker.addons import check_docker_running
|
|
10
3
|
from vantage6.common.globals import InstanceType
|
|
4
|
+
|
|
11
5
|
from vantage6.cli.common.decorator import click_insert_context
|
|
6
|
+
from vantage6.cli.common.remove import execute_remove
|
|
12
7
|
from vantage6.cli.context import ServerContext
|
|
13
|
-
from vantage6.cli.
|
|
8
|
+
from vantage6.cli.globals import InfraComponentName
|
|
14
9
|
|
|
15
10
|
|
|
16
11
|
@click.command()
|
|
17
|
-
@click_insert_context(
|
|
12
|
+
@click_insert_context(
|
|
13
|
+
type_=InstanceType.SERVER, include_name=True, include_system_folders=True
|
|
14
|
+
)
|
|
18
15
|
@click.option("-f", "--force", "force", flag_value=True)
|
|
19
|
-
def cli_server_remove(
|
|
16
|
+
def cli_server_remove(
|
|
17
|
+
ctx: ServerContext, name: str, system_folders: bool, force: bool
|
|
18
|
+
) -> None:
|
|
20
19
|
"""
|
|
21
20
|
Function to remove a server.
|
|
22
21
|
|
|
@@ -27,26 +26,6 @@ def cli_server_remove(ctx: ServerContext, force: bool) -> None:
|
|
|
27
26
|
force : bool
|
|
28
27
|
Whether to ask for confirmation before removing or not
|
|
29
28
|
"""
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if not q.confirm(
|
|
34
|
-
"This server will be deleted permanently including its "
|
|
35
|
-
"configuration. Are you sure?",
|
|
36
|
-
default=False,
|
|
37
|
-
).ask():
|
|
38
|
-
info("Server will not be deleted")
|
|
39
|
-
exit(0)
|
|
40
|
-
|
|
41
|
-
# now remove the folders...
|
|
42
|
-
remove_file(ctx.config_file, "configuration")
|
|
43
|
-
|
|
44
|
-
# ensure log files are closed before removing
|
|
45
|
-
log_dir = Path(ctx.log_file.parent)
|
|
46
|
-
if log_dir.exists():
|
|
47
|
-
info(f"Removing log directory: {log_dir}")
|
|
48
|
-
for handler in itertools.chain(ctx.log.handlers, ctx.log.root.handlers):
|
|
49
|
-
handler.close()
|
|
50
|
-
# remove the whole folder with all the log files. This may also still contain other
|
|
51
|
-
# files like RabbitMQ configuration etc
|
|
52
|
-
rmtree(log_dir)
|
|
29
|
+
execute_remove(
|
|
30
|
+
ctx, InstanceType.SERVER, InfraComponentName.SERVER, name, system_folders, force
|
|
31
|
+
)
|
vantage6/cli/server/start.py
CHANGED
|
@@ -6,12 +6,12 @@ from vantage6.common.globals import InstanceType, Ports
|
|
|
6
6
|
from vantage6.cli.common.decorator import click_insert_context
|
|
7
7
|
from vantage6.cli.common.start import (
|
|
8
8
|
helm_install,
|
|
9
|
+
prestart_checks,
|
|
9
10
|
start_port_forward,
|
|
10
11
|
)
|
|
11
12
|
from vantage6.cli.common.utils import (
|
|
12
13
|
attach_logs,
|
|
13
14
|
create_directory_if_not_exists,
|
|
14
|
-
select_context_and_namespace,
|
|
15
15
|
)
|
|
16
16
|
from vantage6.cli.context.server import ServerContext
|
|
17
17
|
from vantage6.cli.globals import ChartName
|
|
@@ -32,9 +32,13 @@ from vantage6.cli.globals import ChartName
|
|
|
32
32
|
default=False,
|
|
33
33
|
help="Print server logs to the console after start",
|
|
34
34
|
)
|
|
35
|
-
@click_insert_context(
|
|
35
|
+
@click_insert_context(
|
|
36
|
+
type_=InstanceType.SERVER, include_name=True, include_system_folders=True
|
|
37
|
+
)
|
|
36
38
|
def cli_server_start(
|
|
37
39
|
ctx: ServerContext,
|
|
40
|
+
name: str,
|
|
41
|
+
system_folders: bool,
|
|
38
42
|
context: str,
|
|
39
43
|
namespace: str,
|
|
40
44
|
ip: str,
|
|
@@ -46,10 +50,8 @@ def cli_server_start(
|
|
|
46
50
|
Start the server.
|
|
47
51
|
"""
|
|
48
52
|
info("Starting server...")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
namespace=namespace,
|
|
52
|
-
)
|
|
53
|
+
|
|
54
|
+
prestart_checks(ctx, InstanceType.SERVER, name, system_folders, context, namespace)
|
|
53
55
|
|
|
54
56
|
create_directory_if_not_exists(ctx.log_dir)
|
|
55
57
|
|
vantage6/cli/server/stop.py
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import click
|
|
2
|
-
from colorama import Fore, Style
|
|
3
2
|
|
|
4
|
-
from vantage6.common import
|
|
3
|
+
from vantage6.common import info
|
|
5
4
|
from vantage6.common.globals import InstanceType
|
|
6
5
|
|
|
7
|
-
from vantage6.cli.common.stop import helm_uninstall, stop_port_forward
|
|
8
|
-
from vantage6.cli.
|
|
9
|
-
find_running_service_names,
|
|
10
|
-
select_context_and_namespace,
|
|
11
|
-
select_running_service,
|
|
12
|
-
)
|
|
13
|
-
from vantage6.cli.context import get_context
|
|
14
|
-
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
6
|
+
from vantage6.cli.common.stop import execute_stop, helm_uninstall, stop_port_forward
|
|
7
|
+
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS, InfraComponentName
|
|
15
8
|
|
|
16
9
|
|
|
17
10
|
@click.command()
|
|
@@ -43,39 +36,17 @@ def cli_server_stop(
|
|
|
43
36
|
"""
|
|
44
37
|
Stop an running server.
|
|
45
38
|
"""
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
namespace=namespace,
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
running_servers = find_running_service_names(
|
|
39
|
+
execute_stop(
|
|
40
|
+
stop_function=_stop_server,
|
|
52
41
|
instance_type=InstanceType.SERVER,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
infra_component=InfraComponentName.SERVER,
|
|
43
|
+
stop_all=all_servers,
|
|
44
|
+
to_stop=name,
|
|
56
45
|
namespace=namespace,
|
|
46
|
+
context=context,
|
|
47
|
+
system_folders=system_folders,
|
|
57
48
|
)
|
|
58
49
|
|
|
59
|
-
if not running_servers:
|
|
60
|
-
error("No running servers found.")
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
if all_servers:
|
|
64
|
-
for server in running_servers:
|
|
65
|
-
_stop_server(server["name"], namespace, context)
|
|
66
|
-
else:
|
|
67
|
-
if not name:
|
|
68
|
-
server_name = select_running_service(running_servers, InstanceType.SERVER)
|
|
69
|
-
else:
|
|
70
|
-
ctx = get_context(InstanceType.SERVER, name, system_folders)
|
|
71
|
-
server_name = ctx.helm_release_name
|
|
72
|
-
|
|
73
|
-
if server_name in running_servers:
|
|
74
|
-
_stop_server(server_name, namespace, context)
|
|
75
|
-
info(f"Stopped the {Fore.GREEN}{server_name}{Style.RESET_ALL} server.")
|
|
76
|
-
else:
|
|
77
|
-
error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running?!")
|
|
78
|
-
|
|
79
50
|
|
|
80
51
|
def _stop_server(server_name: str, namespace: str, context: str) -> None:
|
|
81
52
|
info(f"Stopping server {server_name}...")
|
|
@@ -19,7 +19,7 @@ store:
|
|
|
19
19
|
|
|
20
20
|
vantage6ServerUri: {{ store.vantage6ServerUri | default('http://localhost:7601/server') }}
|
|
21
21
|
|
|
22
|
-
image: {{ store.image | default('harbor2.vantage6.ai/infrastructure/store:latest') }}
|
|
22
|
+
image: {{ store.image | default('harbor2.vantage6.ai/infrastructure/algorithm-store:latest') }}
|
|
23
23
|
|
|
24
24
|
replications: {{ store.replications | default(1) }}
|
|
25
25
|
|