vantage6 5.0.0a33__py3-none-any.whl → 5.0.0a34__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 +24 -46
- vantage6/cli/algostore/start.py +33 -67
- vantage6/cli/algostore/stop.py +75 -40
- vantage6/cli/common/new.py +60 -0
- vantage6/cli/common/start.py +17 -223
- vantage6/cli/common/stop.py +1 -1
- vantage6/cli/common/utils.py +212 -16
- vantage6/cli/configuration_manager.py +65 -0
- vantage6/cli/configuration_wizard.py +95 -76
- vantage6/cli/context/algorithm_store.py +7 -6
- vantage6/cli/context/base_server.py +22 -30
- vantage6/cli/context/node.py +4 -0
- vantage6/cli/context/server.py +16 -7
- vantage6/cli/globals.py +12 -11
- vantage6/cli/node/common/__init__.py +1 -1
- vantage6/cli/node/create_private_key.py +9 -6
- vantage6/cli/node/set_api_key.py +7 -4
- vantage6/cli/node/start.py +1 -1
- vantage6/cli/node/stop.py +7 -7
- vantage6/cli/server/import_.py +1 -2
- vantage6/cli/server/list.py +0 -3
- vantage6/cli/server/new.py +13 -51
- vantage6/cli/server/shell.py +1 -1
- vantage6/cli/server/start.py +17 -17
- vantage6/cli/server/stop.py +64 -15
- vantage6/cli/template/algo_store_config.j2 +195 -22
- vantage6/cli/template/server_config.j2 +255 -33
- {vantage6-5.0.0a33.dist-info → vantage6-5.0.0a34.dist-info}/METADATA +4 -4
- {vantage6-5.0.0a33.dist-info → vantage6-5.0.0a34.dist-info}/RECORD +31 -31
- vantage6/cli/template/server_import_config.j2 +0 -31
- {vantage6-5.0.0a33.dist-info → vantage6-5.0.0a34.dist-info}/WHEEL +0 -0
- {vantage6-5.0.0a33.dist-info → vantage6-5.0.0a34.dist-info}/entry_points.txt +0 -0
vantage6/cli/algostore/new.py
CHANGED
|
@@ -1,61 +1,39 @@
|
|
|
1
1
|
import click
|
|
2
|
-
from colorama import Fore, Style
|
|
3
2
|
|
|
4
|
-
from vantage6.common import info, error, ensure_config_dir_writable
|
|
5
3
|
from vantage6.common.globals import InstanceType
|
|
4
|
+
|
|
5
|
+
from vantage6.cli.common.new import new
|
|
6
6
|
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
7
|
-
from vantage6.cli.context.algorithm_store import AlgorithmStoreContext
|
|
8
|
-
from vantage6.cli.configuration_wizard import configuration_wizard
|
|
9
|
-
from vantage6.cli.utils import check_config_name_allowed, prompt_config_name
|
|
10
7
|
|
|
11
8
|
|
|
12
9
|
@click.command()
|
|
13
10
|
@click.option(
|
|
14
|
-
"-n", "--name", default=None, help="
|
|
11
|
+
"-n", "--name", default=None, help="Name of the configuration you want to use."
|
|
12
|
+
)
|
|
13
|
+
@click.option(
|
|
14
|
+
"--system",
|
|
15
|
+
"system_folders",
|
|
16
|
+
flag_value=True,
|
|
17
|
+
help="Use system folders instead of user folders. This is the default",
|
|
18
|
+
)
|
|
19
|
+
@click.option(
|
|
20
|
+
"--user",
|
|
21
|
+
"system_folders",
|
|
22
|
+
flag_value=False,
|
|
23
|
+
default=DEFAULT_SERVER_SYSTEM_FOLDERS,
|
|
24
|
+
help="Use user folders instead of system folders",
|
|
15
25
|
)
|
|
16
|
-
@click.option("--
|
|
26
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
17
27
|
@click.option(
|
|
18
|
-
"--
|
|
28
|
+
"--namespace",
|
|
29
|
+
default=None,
|
|
30
|
+
help="Kubernetes namespace to use",
|
|
19
31
|
)
|
|
20
|
-
def cli_algo_store_new(
|
|
32
|
+
def cli_algo_store_new(
|
|
33
|
+
name: str, system_folders: bool, namespace: str, context: str
|
|
34
|
+
) -> None:
|
|
21
35
|
"""
|
|
22
36
|
Create a new server configuration.
|
|
23
37
|
"""
|
|
24
|
-
name = prompt_config_name(name)
|
|
25
|
-
|
|
26
|
-
# check if name is allowed for docker volume, else exit
|
|
27
|
-
check_config_name_allowed(name)
|
|
28
|
-
|
|
29
|
-
# check that this config does not exist
|
|
30
|
-
try:
|
|
31
|
-
if AlgorithmStoreContext.config_exists(name, system_folders):
|
|
32
|
-
error(f"Configuration {Fore.RED}{name}{Style.RESET_ALL} already " "exists!")
|
|
33
|
-
exit(1)
|
|
34
|
-
except Exception as e:
|
|
35
|
-
error(e)
|
|
36
|
-
exit(1)
|
|
37
|
-
|
|
38
|
-
# Check that we can write in this folder
|
|
39
|
-
if not ensure_config_dir_writable(system_folders):
|
|
40
|
-
error("Your user does not have write access to all folders. Exiting")
|
|
41
|
-
info(
|
|
42
|
-
f"Create a new server using '{Fore.GREEN}v6 algorithm-store new "
|
|
43
|
-
f"--user{Style.RESET_ALL}' instead!"
|
|
44
|
-
)
|
|
45
|
-
exit(1)
|
|
46
|
-
|
|
47
|
-
# create config in ctx location
|
|
48
|
-
try:
|
|
49
|
-
cfg_file = configuration_wizard(
|
|
50
|
-
InstanceType.ALGORITHM_STORE, name, system_folders
|
|
51
|
-
)
|
|
52
|
-
except KeyboardInterrupt:
|
|
53
|
-
error("Configuration creation aborted.")
|
|
54
|
-
exit(1)
|
|
55
|
-
info(f"New configuration created: {Fore.GREEN}{cfg_file}{Style.RESET_ALL}")
|
|
56
38
|
|
|
57
|
-
|
|
58
|
-
info(
|
|
59
|
-
f"You can start the algorithm store by running {Fore.GREEN}v6 "
|
|
60
|
-
f"algorithm-store start {flag}{Style.RESET_ALL}"
|
|
61
|
-
)
|
|
39
|
+
new(name, system_folders, namespace, context, InstanceType.ALGORITHM_STORE)
|
vantage6/cli/algostore/start.py
CHANGED
|
@@ -2,39 +2,29 @@ import click
|
|
|
2
2
|
|
|
3
3
|
from vantage6.common import info
|
|
4
4
|
from vantage6.common.globals import (
|
|
5
|
-
APPNAME,
|
|
6
|
-
DEFAULT_ALGO_STORE_IMAGE,
|
|
7
5
|
InstanceType,
|
|
8
6
|
Ports,
|
|
9
7
|
)
|
|
10
8
|
|
|
11
9
|
from vantage6.cli.common.decorator import click_insert_context
|
|
12
10
|
from vantage6.cli.common.start import (
|
|
11
|
+
helm_install,
|
|
12
|
+
start_port_forward,
|
|
13
|
+
)
|
|
14
|
+
from vantage6.cli.common.utils import (
|
|
13
15
|
attach_logs,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
mount_config_file,
|
|
17
|
-
mount_database,
|
|
18
|
-
mount_source,
|
|
19
|
-
pull_infra_image,
|
|
16
|
+
create_directory_if_not_exists,
|
|
17
|
+
select_context_and_namespace,
|
|
20
18
|
)
|
|
21
19
|
from vantage6.cli.context.algorithm_store import AlgorithmStoreContext
|
|
20
|
+
from vantage6.cli.globals import ChartName
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
@click.command()
|
|
24
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
25
|
+
@click.option("--namespace", default=None, help="Kubernetes namespace to use")
|
|
25
26
|
@click.option("--ip", default=None, help="IP address to listen on")
|
|
26
27
|
@click.option("-p", "--port", default=None, type=int, help="Port to listen on")
|
|
27
|
-
@click.option("-i", "--image", default=None, help="Algorithm store Docker image to use")
|
|
28
|
-
@click.option(
|
|
29
|
-
"--keep/--auto-remove",
|
|
30
|
-
default=False,
|
|
31
|
-
help="Keep image after algorithm store has been stopped. Useful for debugging",
|
|
32
|
-
)
|
|
33
|
-
@click.option(
|
|
34
|
-
"--mount-src",
|
|
35
|
-
default="",
|
|
36
|
-
help="Override vantage6 source code in container with the source code in this path",
|
|
37
|
-
)
|
|
38
28
|
@click.option(
|
|
39
29
|
"--attach/--detach",
|
|
40
30
|
default=False,
|
|
@@ -43,65 +33,41 @@ from vantage6.cli.context.algorithm_store import AlgorithmStoreContext
|
|
|
43
33
|
@click_insert_context(InstanceType.ALGORITHM_STORE)
|
|
44
34
|
def cli_algo_store_start(
|
|
45
35
|
ctx: AlgorithmStoreContext,
|
|
36
|
+
context: str,
|
|
37
|
+
namespace: str,
|
|
46
38
|
ip: str,
|
|
47
39
|
port: int,
|
|
48
|
-
image: str,
|
|
49
|
-
keep: bool,
|
|
50
|
-
mount_src: str,
|
|
51
40
|
attach: bool,
|
|
52
41
|
) -> None:
|
|
53
42
|
"""
|
|
54
|
-
Start the algorithm store
|
|
43
|
+
Start the algorithm store.
|
|
55
44
|
"""
|
|
56
45
|
info("Starting algorithm store...")
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
info("Pulling algorithm store image...")
|
|
62
|
-
pull_infra_image(docker_client, image, InstanceType.ALGORITHM_STORE)
|
|
63
|
-
|
|
64
|
-
config_file = "/mnt/config.yaml"
|
|
65
|
-
mounts = mount_config_file(ctx, config_file)
|
|
66
|
-
|
|
67
|
-
src_mount = mount_source(mount_src)
|
|
68
|
-
if src_mount:
|
|
69
|
-
mounts.append(src_mount)
|
|
46
|
+
context, namespace = select_context_and_namespace(
|
|
47
|
+
context=context,
|
|
48
|
+
namespace=namespace,
|
|
49
|
+
)
|
|
70
50
|
|
|
71
|
-
|
|
72
|
-
if mount:
|
|
73
|
-
mounts.append(mount)
|
|
51
|
+
create_directory_if_not_exists(ctx.log_dir)
|
|
74
52
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"--wsgi-file /vantage6/vantage6-algorithm-store/vantage6/algorithm"
|
|
82
|
-
f"/store/wsgi.py --pyargv {config_file}"
|
|
53
|
+
helm_install(
|
|
54
|
+
release_name=ctx.helm_release_name,
|
|
55
|
+
chart_name=ChartName.ALGORITHM_STORE,
|
|
56
|
+
values_file=ctx.config_file,
|
|
57
|
+
context=context,
|
|
58
|
+
namespace=namespace,
|
|
83
59
|
)
|
|
84
|
-
info(cmd)
|
|
85
60
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
"name": ctx.config_file_name,
|
|
96
|
-
},
|
|
97
|
-
environment=environment_vars,
|
|
98
|
-
ports={f"{internal_port}/tcp": (ip, port_)},
|
|
99
|
-
name=ctx.docker_container_name,
|
|
100
|
-
auto_remove=not keep,
|
|
101
|
-
tty=True,
|
|
61
|
+
# port forward for server
|
|
62
|
+
info("Port forwarding for algorithm store")
|
|
63
|
+
start_port_forward(
|
|
64
|
+
service_name=f"{ctx.helm_release_name}-vantage6-algorithm-store-service",
|
|
65
|
+
service_port=ctx.config["store"].get("port", Ports.DEV_ALGO_STORE.value),
|
|
66
|
+
port=port or ctx.config["store"].get("port", Ports.DEV_ALGO_STORE.value),
|
|
67
|
+
ip=ip,
|
|
68
|
+
context=context,
|
|
69
|
+
namespace=namespace,
|
|
102
70
|
)
|
|
103
71
|
|
|
104
|
-
info(f"Success! container id = {container.id}")
|
|
105
|
-
|
|
106
72
|
if attach:
|
|
107
|
-
attach_logs(
|
|
73
|
+
attach_logs("app=store", "component=store-server")
|
vantage6/cli/algostore/stop.py
CHANGED
|
@@ -1,61 +1,96 @@
|
|
|
1
1
|
import click
|
|
2
|
-
import docker
|
|
3
2
|
from colorama import Fore, Style
|
|
4
3
|
|
|
5
|
-
from vantage6.common import error, info
|
|
6
|
-
from vantage6.common.
|
|
7
|
-
check_docker_running,
|
|
8
|
-
remove_container_if_exists,
|
|
9
|
-
)
|
|
10
|
-
from vantage6.common.globals import APPNAME, InstanceType
|
|
4
|
+
from vantage6.common import error, info
|
|
5
|
+
from vantage6.common.globals import InstanceType
|
|
11
6
|
|
|
12
|
-
from vantage6.cli.common.
|
|
13
|
-
from vantage6.cli.
|
|
7
|
+
from vantage6.cli.common.stop import helm_uninstall, stop_port_forward
|
|
8
|
+
from vantage6.cli.common.utils import (
|
|
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
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
@click.command()
|
|
17
|
-
@
|
|
18
|
+
@click.option("-n", "--name", default=None, help="Configuration name")
|
|
19
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
20
|
+
@click.option("--namespace", default=None, help="Kubernetes namespace to use")
|
|
21
|
+
@click.option(
|
|
22
|
+
"--system",
|
|
23
|
+
"system_folders",
|
|
24
|
+
flag_value=True,
|
|
25
|
+
default=DEFAULT_SERVER_SYSTEM_FOLDERS,
|
|
26
|
+
help="Search for configuration in system folders instead of user folders. "
|
|
27
|
+
"This is the default.",
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--user",
|
|
31
|
+
"system_folders",
|
|
32
|
+
flag_value=False,
|
|
33
|
+
help="Search for configuration in the user folders instead of system folders.",
|
|
34
|
+
)
|
|
18
35
|
@click.option("--all", "all_stores", flag_value=True, help="Stop all algorithm stores")
|
|
19
|
-
def cli_algo_store_stop(
|
|
36
|
+
def cli_algo_store_stop(
|
|
37
|
+
name: str,
|
|
38
|
+
context: str,
|
|
39
|
+
namespace: str,
|
|
40
|
+
system_folders: bool,
|
|
41
|
+
all_stores: bool,
|
|
42
|
+
):
|
|
20
43
|
"""
|
|
21
|
-
Stop one or all running
|
|
44
|
+
Stop one or all running algorithm store(s).
|
|
22
45
|
"""
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
context, namespace = select_context_and_namespace(
|
|
47
|
+
context=context,
|
|
48
|
+
namespace=namespace,
|
|
49
|
+
)
|
|
25
50
|
|
|
26
|
-
running_stores =
|
|
27
|
-
|
|
51
|
+
running_stores = find_running_service_names(
|
|
52
|
+
instance_type=InstanceType.ALGORITHM_STORE,
|
|
53
|
+
only_system_folders=system_folders,
|
|
54
|
+
only_user_folders=not system_folders,
|
|
55
|
+
context=context,
|
|
56
|
+
namespace=namespace,
|
|
28
57
|
)
|
|
29
58
|
|
|
30
59
|
if not running_stores:
|
|
31
|
-
|
|
60
|
+
error("No running algorithm stores found.")
|
|
32
61
|
return
|
|
33
62
|
|
|
34
|
-
running_store_names = [server.name for server in running_stores]
|
|
35
|
-
|
|
36
63
|
if all_stores:
|
|
37
|
-
for
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
for store in running_stores:
|
|
65
|
+
_stop_store(store["name"], namespace, context)
|
|
66
|
+
else:
|
|
67
|
+
if not name:
|
|
68
|
+
store_name = select_running_service(
|
|
69
|
+
running_stores, InstanceType.ALGORITHM_STORE
|
|
70
|
+
)
|
|
71
|
+
else:
|
|
72
|
+
ctx = get_context(InstanceType.ALGORITHM_STORE, name, system_folders)
|
|
73
|
+
store_name = ctx.helm_release_name
|
|
40
74
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
75
|
+
if store_name in running_stores:
|
|
76
|
+
_stop_store(store_name, namespace, context)
|
|
77
|
+
info(f"Stopped the {Fore.GREEN}{store_name}{Style.RESET_ALL} store.")
|
|
78
|
+
else:
|
|
79
|
+
error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running?!")
|
|
45
80
|
|
|
46
|
-
_stop_algorithm_store(client, container_name)
|
|
47
81
|
|
|
82
|
+
def _stop_store(store_name: str, namespace: str, context: str) -> None:
|
|
83
|
+
info(f"Stopping store {store_name}...")
|
|
48
84
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
info(f"Stopped the {Fore.GREEN}{container_name}{Style.RESET_ALL} server.")
|
|
85
|
+
# uninstall the helm release
|
|
86
|
+
helm_uninstall(
|
|
87
|
+
release_name=store_name,
|
|
88
|
+
context=context,
|
|
89
|
+
namespace=namespace,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
stop_port_forward(
|
|
93
|
+
service_name=f"{store_name}-vantage6-algorithm-store-service",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
info(f"Store {store_name} stopped successfully.")
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from colorama import Fore, Style
|
|
2
|
+
|
|
3
|
+
from vantage6.common import ensure_config_dir_writable, error, info
|
|
4
|
+
from vantage6.common.globals import InstanceType
|
|
5
|
+
|
|
6
|
+
from vantage6.cli.common.utils import get_main_cli_command_name
|
|
7
|
+
from vantage6.cli.config import CliConfig
|
|
8
|
+
from vantage6.cli.configuration_wizard import configuration_wizard
|
|
9
|
+
from vantage6.cli.context import select_context_class
|
|
10
|
+
from vantage6.cli.utils import check_config_name_allowed, prompt_config_name
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def new(
|
|
14
|
+
name: str, system_folders: bool, namespace: str, context: str, type_: InstanceType
|
|
15
|
+
):
|
|
16
|
+
cli_config = CliConfig()
|
|
17
|
+
context, namespace = cli_config.compare_changes_config(
|
|
18
|
+
context=context,
|
|
19
|
+
namespace=namespace,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
name = prompt_config_name(name)
|
|
23
|
+
|
|
24
|
+
# check if name is valid
|
|
25
|
+
check_config_name_allowed(name)
|
|
26
|
+
|
|
27
|
+
# check that this config does not exist
|
|
28
|
+
ctx_class = select_context_class(type_)
|
|
29
|
+
try:
|
|
30
|
+
if ctx_class.config_exists(name, system_folders):
|
|
31
|
+
error(f"Configuration {Fore.RED}{name}{Style.RESET_ALL} already exists!")
|
|
32
|
+
exit(1)
|
|
33
|
+
except Exception as e:
|
|
34
|
+
error(e)
|
|
35
|
+
exit(1)
|
|
36
|
+
|
|
37
|
+
command_name = get_main_cli_command_name(type_)
|
|
38
|
+
|
|
39
|
+
# Check that we can write in this folder
|
|
40
|
+
if not ensure_config_dir_writable(system_folders):
|
|
41
|
+
error("Your user does not have write access to all folders. Exiting")
|
|
42
|
+
info(
|
|
43
|
+
f"Create a new {command_name} using '{Fore.GREEN}v6 {command_name} new "
|
|
44
|
+
f"--user{Style.RESET_ALL}' instead!"
|
|
45
|
+
)
|
|
46
|
+
exit(1)
|
|
47
|
+
|
|
48
|
+
# create config in ctx location
|
|
49
|
+
try:
|
|
50
|
+
cfg_file = configuration_wizard(type_, name, system_folders)
|
|
51
|
+
except KeyboardInterrupt:
|
|
52
|
+
error("Configuration creation aborted.")
|
|
53
|
+
exit(1)
|
|
54
|
+
info(f"New configuration created: {Fore.GREEN}{cfg_file}{Style.RESET_ALL}")
|
|
55
|
+
|
|
56
|
+
flag = "" if system_folders else "--user"
|
|
57
|
+
info(
|
|
58
|
+
f"You can start the {command_name} by running {Fore.GREEN}v6 {command_name} "
|
|
59
|
+
f"start {flag}{Style.RESET_ALL}"
|
|
60
|
+
)
|