vantage6 5.0.0a34__py3-none-any.whl → 5.0.0a35__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/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/cli.py +31 -33
- vantage6/cli/common/new.py +28 -3
- vantage6/cli/common/remove.py +54 -0
- vantage6/cli/common/start.py +30 -1
- vantage6/cli/common/stop.py +79 -1
- vantage6/cli/common/utils.py +45 -4
- vantage6/cli/configuration_manager.py +26 -13
- vantage6/cli/configuration_wizard.py +13 -397
- vantage6/cli/context/node.py +10 -17
- vantage6/cli/globals.py +20 -0
- vantage6/cli/node/attach.py +1 -0
- vantage6/cli/node/files.py +12 -25
- 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/server/new.py +70 -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/node_config.j2 +336 -33
- vantage6/cli/utils.py +0 -2
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a35.dist-info}/METADATA +3 -3
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a35.dist-info}/RECORD +32 -32
- vantage6/cli/node/clean.py +0 -46
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a35.dist-info}/WHEEL +0 -0
- {vantage6-5.0.0a34.dist-info → vantage6-5.0.0a35.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/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,65 @@ def cli_server_new(
|
|
|
38
45
|
"""
|
|
39
46
|
Create a new server configuration.
|
|
40
47
|
"""
|
|
41
|
-
new(
|
|
48
|
+
new(
|
|
49
|
+
questionnaire_function=server_configuration_questionaire,
|
|
50
|
+
name=name,
|
|
51
|
+
system_folders=system_folders,
|
|
52
|
+
namespace=namespace,
|
|
53
|
+
context=context,
|
|
54
|
+
type_=InstanceType.SERVER,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def server_configuration_questionaire(instance_name: str) -> dict[str, Any]:
|
|
59
|
+
"""
|
|
60
|
+
Kubernetes-specific questionnaire to generate Helm values for server.
|
|
61
|
+
|
|
62
|
+
Parameters
|
|
63
|
+
----------
|
|
64
|
+
instance_name : str
|
|
65
|
+
Name of the server instance.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
dict[str, Any]
|
|
70
|
+
dictionary with Helm values for the server configuration
|
|
71
|
+
"""
|
|
72
|
+
# Get active kube namespace
|
|
73
|
+
cli_config = CliConfig()
|
|
74
|
+
kube_namespace = cli_config.get_last_namespace()
|
|
75
|
+
|
|
76
|
+
# Initialize config with basic structure
|
|
77
|
+
config = {"server": {}, "database": {}, "ui": {}, "rabbitmq": {}}
|
|
78
|
+
|
|
79
|
+
config, is_production = add_common_server_config(
|
|
80
|
+
config, InstanceType.SERVER, instance_name
|
|
81
|
+
)
|
|
82
|
+
if not is_production:
|
|
83
|
+
config["server"]["jwt"] = {
|
|
84
|
+
"secret": "constant_development_secret`",
|
|
85
|
+
}
|
|
86
|
+
config["server"]["dev"] = {
|
|
87
|
+
"host_uri": "host.docker.internal",
|
|
88
|
+
"store_in_local_cluster": True,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# TODO v5+ these should be removed, latest should usually be used so question is
|
|
92
|
+
# not needed. However, for now we want to specify alpha/beta images.
|
|
93
|
+
# === Server settings ===
|
|
94
|
+
config["server"]["image"] = q.text(
|
|
95
|
+
"Server Docker image:",
|
|
96
|
+
default="harbor2.vantage6.ai/infrastructure/server:latest",
|
|
97
|
+
).unsafe_ask()
|
|
98
|
+
|
|
99
|
+
# === UI settings ===
|
|
100
|
+
config["ui"]["image"] = q.text(
|
|
101
|
+
"UI Docker image:",
|
|
102
|
+
default="harbor2.vantage6.ai/infrastructure/ui:latest",
|
|
103
|
+
).unsafe_ask()
|
|
104
|
+
|
|
105
|
+
# === Keycloak settings ===
|
|
106
|
+
keycloak_url = f"http://vantage6-auth-keycloak.{kube_namespace}.svc.cluster.local"
|
|
107
|
+
config["server"]["keycloakUrl"] = keycloak_url
|
|
108
|
+
|
|
109
|
+
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
|
|