vantage6 5.0.0a33__tar.gz → 5.0.0a34__tar.gz
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-5.0.0a33 → vantage6-5.0.0a34}/PKG-INFO +4 -4
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/pyproject.toml +4 -4
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/tests_cli/test_server_cli.py +1 -1
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/tests_cli/test_wizard.py +1 -1
- vantage6-5.0.0a34/vantage6/cli/algostore/new.py +39 -0
- vantage6-5.0.0a34/vantage6/cli/algostore/start.py +73 -0
- vantage6-5.0.0a34/vantage6/cli/algostore/stop.py +96 -0
- {vantage6-5.0.0a33/vantage6/cli/server → vantage6-5.0.0a34/vantage6/cli/common}/new.py +14 -33
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/common/start.py +17 -223
- vantage6-5.0.0a34/vantage6/cli/common/utils.py +373 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/configuration_manager.py +65 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/configuration_wizard.py +95 -76
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/context/algorithm_store.py +7 -6
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/context/base_server.py +22 -30
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/context/node.py +4 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/context/server.py +16 -7
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/globals.py +12 -11
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/common/__init__.py +1 -1
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/create_private_key.py +9 -6
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/set_api_key.py +7 -4
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/start.py +1 -1
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/stop.py +7 -7
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/server/import_.py +1 -2
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/server/list.py +0 -3
- vantage6-5.0.0a34/vantage6/cli/server/new.py +41 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/server/shell.py +1 -1
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/server/start.py +17 -17
- vantage6-5.0.0a34/vantage6/cli/server/stop.py +99 -0
- vantage6-5.0.0a34/vantage6/cli/template/algo_store_config.j2 +195 -0
- vantage6-5.0.0a34/vantage6/cli/template/server_config.j2 +256 -0
- vantage6-5.0.0a33/vantage6/cli/algostore/new.py +0 -61
- vantage6-5.0.0a33/vantage6/cli/algostore/start.py +0 -107
- vantage6-5.0.0a33/vantage6/cli/algostore/stop.py +0 -61
- vantage6-5.0.0a33/vantage6/cli/common/utils.py +0 -177
- vantage6-5.0.0a33/vantage6/cli/server/stop.py +0 -50
- vantage6-5.0.0a33/vantage6/cli/template/algo_store_config.j2 +0 -22
- vantage6-5.0.0a33/vantage6/cli/template/server_config.j2 +0 -34
- vantage6-5.0.0a33/vantage6/cli/template/server_import_config.j2 +0 -31
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/.gitignore +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/Makefile +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/README.md +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/tests_cli/__init__.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/tests_cli/test_client_script.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/tests_cli/test_example.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/tests_cli/test_node_cli.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/__init__.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/algorithm/create.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/algorithm/generate_algorithm_json.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/algorithm/update.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/algostore/attach.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/algostore/files.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/algostore/list.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/algostore/remove.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/cli.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/common/decorator.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/common/stop.py +1 -1
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/config.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/context/__init__.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/dev/create.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/dev/data/km_dataset.csv +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/dev/remove.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/attach.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/clean.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/files.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/list.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/new.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/remove.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/restart.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/node/version.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/prometheus/monitoring_manager.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/prometheus/prometheus.yml +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/rabbitmq/__init__.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/rabbitmq/definitions.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/rabbitmq/queue_manager.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/rabbitmq/rabbitmq.config +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/server/attach.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/server/common/__init__.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/server/files.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/server/remove.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/server/version.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/template/node_config.j2 +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/test/algo_test_scripts/algo_test_arguments.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/test/algo_test_scripts/algo_test_script.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/test/client_script.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/test/common/diagnostic_runner.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/test/feature_tester.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/test/integration_test.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/use/context.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/use/namespace.py +0 -0
- {vantage6-5.0.0a33 → vantage6-5.0.0a34}/vantage6/cli/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: vantage6
|
|
3
|
-
Version: 5.0.
|
|
3
|
+
Version: 5.0.0a34
|
|
4
4
|
Summary: vantage6 command line interface
|
|
5
5
|
Author: Vantage6 Team
|
|
6
6
|
Maintainer-email: Frank Martin <f.martin@iknl.nl>, Bart van Beusekom <b.vanbeusekom@iknl.nl>
|
|
@@ -8,7 +8,7 @@ License: MIT
|
|
|
8
8
|
Requires-Python: >=3.13
|
|
9
9
|
Requires-Dist: click==8.1.3
|
|
10
10
|
Requires-Dist: colorama==0.4.6
|
|
11
|
-
Requires-Dist: copier==9.
|
|
11
|
+
Requires-Dist: copier==9.9.1
|
|
12
12
|
Requires-Dist: docker==7.1.0
|
|
13
13
|
Requires-Dist: ipython==8.10.0
|
|
14
14
|
Requires-Dist: jinja2==3.1.6
|
|
@@ -18,8 +18,8 @@ Requires-Dist: questionary==1.10.0
|
|
|
18
18
|
Requires-Dist: rich==13.5.2
|
|
19
19
|
Requires-Dist: schema==0.7.5
|
|
20
20
|
Requires-Dist: sqlalchemy==2.0.37
|
|
21
|
-
Requires-Dist: vantage6-client==5.0.
|
|
22
|
-
Requires-Dist: vantage6-common==5.0.
|
|
21
|
+
Requires-Dist: vantage6-client==5.0.0a34
|
|
22
|
+
Requires-Dist: vantage6-common==5.0.0a34
|
|
23
23
|
Provides-Extra: dev
|
|
24
24
|
Requires-Dist: black; extra == 'dev'
|
|
25
25
|
Requires-Dist: coverage==7.10.2; extra == 'dev'
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "vantage6"
|
|
7
|
-
version = "5.0.
|
|
7
|
+
version = "5.0.0a34"
|
|
8
8
|
description = "vantage6 command line interface"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
@@ -19,7 +19,7 @@ requires-python = ">=3.13"
|
|
|
19
19
|
dependencies = [
|
|
20
20
|
"click==8.1.3",
|
|
21
21
|
"colorama==0.4.6",
|
|
22
|
-
"copier==9.
|
|
22
|
+
"copier==9.9.1",
|
|
23
23
|
"docker==7.1.0",
|
|
24
24
|
"ipython==8.10.0",
|
|
25
25
|
"jinja2==3.1.6",
|
|
@@ -29,8 +29,8 @@ dependencies = [
|
|
|
29
29
|
"rich==13.5.2",
|
|
30
30
|
"schema==0.7.5",
|
|
31
31
|
"sqlalchemy==2.0.37",
|
|
32
|
-
"vantage6-common==5.0.
|
|
33
|
-
"vantage6-client==5.0.
|
|
32
|
+
"vantage6-common==5.0.0a34",
|
|
33
|
+
"vantage6-client==5.0.0a34",
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
[project.optional-dependencies]
|
|
@@ -134,7 +134,7 @@ class ServerCLITest(unittest.TestCase):
|
|
|
134
134
|
"""Stop server without errors."""
|
|
135
135
|
|
|
136
136
|
container1 = MagicMock()
|
|
137
|
-
container1.name = f"{APPNAME}-iknl-system-{InstanceType.SERVER}"
|
|
137
|
+
container1.name = f"{APPNAME}-iknl-system-{InstanceType.SERVER.value}"
|
|
138
138
|
containers.containers.list.return_value = [container1]
|
|
139
139
|
|
|
140
140
|
runner = CliRunner()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from vantage6.common.globals import InstanceType
|
|
4
|
+
|
|
5
|
+
from vantage6.cli.common.new import new
|
|
6
|
+
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@click.command()
|
|
10
|
+
@click.option(
|
|
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",
|
|
25
|
+
)
|
|
26
|
+
@click.option("--context", default=None, help="Kubernetes context to use")
|
|
27
|
+
@click.option(
|
|
28
|
+
"--namespace",
|
|
29
|
+
default=None,
|
|
30
|
+
help="Kubernetes namespace to use",
|
|
31
|
+
)
|
|
32
|
+
def cli_algo_store_new(
|
|
33
|
+
name: str, system_folders: bool, namespace: str, context: str
|
|
34
|
+
) -> None:
|
|
35
|
+
"""
|
|
36
|
+
Create a new server configuration.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
new(name, system_folders, namespace, context, InstanceType.ALGORITHM_STORE)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from vantage6.common import info
|
|
4
|
+
from vantage6.common.globals import (
|
|
5
|
+
InstanceType,
|
|
6
|
+
Ports,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
from vantage6.cli.common.decorator import click_insert_context
|
|
10
|
+
from vantage6.cli.common.start import (
|
|
11
|
+
helm_install,
|
|
12
|
+
start_port_forward,
|
|
13
|
+
)
|
|
14
|
+
from vantage6.cli.common.utils import (
|
|
15
|
+
attach_logs,
|
|
16
|
+
create_directory_if_not_exists,
|
|
17
|
+
select_context_and_namespace,
|
|
18
|
+
)
|
|
19
|
+
from vantage6.cli.context.algorithm_store import AlgorithmStoreContext
|
|
20
|
+
from vantage6.cli.globals import ChartName
|
|
21
|
+
|
|
22
|
+
|
|
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")
|
|
26
|
+
@click.option("--ip", default=None, help="IP address to listen on")
|
|
27
|
+
@click.option("-p", "--port", default=None, type=int, help="Port to listen on")
|
|
28
|
+
@click.option(
|
|
29
|
+
"--attach/--detach",
|
|
30
|
+
default=False,
|
|
31
|
+
help="Print server logs to the console after start",
|
|
32
|
+
)
|
|
33
|
+
@click_insert_context(InstanceType.ALGORITHM_STORE)
|
|
34
|
+
def cli_algo_store_start(
|
|
35
|
+
ctx: AlgorithmStoreContext,
|
|
36
|
+
context: str,
|
|
37
|
+
namespace: str,
|
|
38
|
+
ip: str,
|
|
39
|
+
port: int,
|
|
40
|
+
attach: bool,
|
|
41
|
+
) -> None:
|
|
42
|
+
"""
|
|
43
|
+
Start the algorithm store.
|
|
44
|
+
"""
|
|
45
|
+
info("Starting algorithm store...")
|
|
46
|
+
context, namespace = select_context_and_namespace(
|
|
47
|
+
context=context,
|
|
48
|
+
namespace=namespace,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
create_directory_if_not_exists(ctx.log_dir)
|
|
52
|
+
|
|
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,
|
|
59
|
+
)
|
|
60
|
+
|
|
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,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if attach:
|
|
73
|
+
attach_logs("app=store", "component=store-server")
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from colorama import Fore, Style
|
|
3
|
+
|
|
4
|
+
from vantage6.common import error, info
|
|
5
|
+
from vantage6.common.globals import InstanceType
|
|
6
|
+
|
|
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
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@click.command()
|
|
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
|
+
)
|
|
35
|
+
@click.option("--all", "all_stores", flag_value=True, help="Stop all algorithm stores")
|
|
36
|
+
def cli_algo_store_stop(
|
|
37
|
+
name: str,
|
|
38
|
+
context: str,
|
|
39
|
+
namespace: str,
|
|
40
|
+
system_folders: bool,
|
|
41
|
+
all_stores: bool,
|
|
42
|
+
):
|
|
43
|
+
"""
|
|
44
|
+
Stop one or all running algorithm store(s).
|
|
45
|
+
"""
|
|
46
|
+
context, namespace = select_context_and_namespace(
|
|
47
|
+
context=context,
|
|
48
|
+
namespace=namespace,
|
|
49
|
+
)
|
|
50
|
+
|
|
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,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
if not running_stores:
|
|
60
|
+
error("No running algorithm stores found.")
|
|
61
|
+
return
|
|
62
|
+
|
|
63
|
+
if all_stores:
|
|
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
|
|
74
|
+
|
|
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?!")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _stop_store(store_name: str, namespace: str, context: str) -> None:
|
|
83
|
+
info(f"Stopping store {store_name}...")
|
|
84
|
+
|
|
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.")
|
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
import click
|
|
2
1
|
from colorama import Fore, Style
|
|
3
2
|
|
|
4
3
|
from vantage6.common import ensure_config_dir_writable, error, info
|
|
5
4
|
from vantage6.common.globals import InstanceType
|
|
6
5
|
|
|
6
|
+
from vantage6.cli.common.utils import get_main_cli_command_name
|
|
7
7
|
from vantage6.cli.config import CliConfig
|
|
8
8
|
from vantage6.cli.configuration_wizard import configuration_wizard
|
|
9
|
-
from vantage6.cli.context
|
|
10
|
-
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
9
|
+
from vantage6.cli.context import select_context_class
|
|
11
10
|
from vantage6.cli.utils import check_config_name_allowed, prompt_config_name
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
18
|
-
@click.option("--system", "system_folders", flag_value=True)
|
|
19
|
-
@click.option(
|
|
20
|
-
"--user", "system_folders", flag_value=False, default=DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
21
|
-
)
|
|
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:
|
|
34
|
-
"""
|
|
35
|
-
Create a new server configuration.
|
|
36
|
-
"""
|
|
13
|
+
def new(
|
|
14
|
+
name: str, system_folders: bool, namespace: str, context: str, type_: InstanceType
|
|
15
|
+
):
|
|
37
16
|
cli_config = CliConfig()
|
|
38
17
|
context, namespace = cli_config.compare_changes_config(
|
|
39
18
|
context=context,
|
|
@@ -46,34 +25,36 @@ def cli_server_new(
|
|
|
46
25
|
check_config_name_allowed(name)
|
|
47
26
|
|
|
48
27
|
# check that this config does not exist
|
|
28
|
+
ctx_class = select_context_class(type_)
|
|
49
29
|
try:
|
|
50
|
-
if
|
|
51
|
-
error(f"Configuration {Fore.RED}{name}{Style.RESET_ALL} already
|
|
30
|
+
if ctx_class.config_exists(name, system_folders):
|
|
31
|
+
error(f"Configuration {Fore.RED}{name}{Style.RESET_ALL} already exists!")
|
|
52
32
|
exit(1)
|
|
53
33
|
except Exception as e:
|
|
54
34
|
error(e)
|
|
55
35
|
exit(1)
|
|
56
36
|
|
|
37
|
+
command_name = get_main_cli_command_name(type_)
|
|
38
|
+
|
|
57
39
|
# Check that we can write in this folder
|
|
58
40
|
if not ensure_config_dir_writable(system_folders):
|
|
59
41
|
error("Your user does not have write access to all folders. Exiting")
|
|
60
42
|
info(
|
|
61
|
-
f"Create a new
|
|
43
|
+
f"Create a new {command_name} using '{Fore.GREEN}v6 {command_name} new "
|
|
62
44
|
f"--user{Style.RESET_ALL}' instead!"
|
|
63
45
|
)
|
|
64
46
|
exit(1)
|
|
65
47
|
|
|
66
48
|
# create config in ctx location
|
|
67
49
|
try:
|
|
68
|
-
cfg_file = configuration_wizard(
|
|
50
|
+
cfg_file = configuration_wizard(type_, name, system_folders)
|
|
69
51
|
except KeyboardInterrupt:
|
|
70
52
|
error("Configuration creation aborted.")
|
|
71
53
|
exit(1)
|
|
72
54
|
info(f"New configuration created: {Fore.GREEN}{cfg_file}{Style.RESET_ALL}")
|
|
73
55
|
|
|
74
|
-
# info(f"root user created.")
|
|
75
56
|
flag = "" if system_folders else "--user"
|
|
76
57
|
info(
|
|
77
|
-
f"You can start the
|
|
78
|
-
f"{flag}{Style.RESET_ALL}"
|
|
58
|
+
f"You can start the {command_name} by running {Fore.GREEN}v6 {command_name} "
|
|
59
|
+
f"start {flag}{Style.RESET_ALL}"
|
|
79
60
|
)
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import enum
|
|
4
|
-
import os
|
|
5
3
|
import re
|
|
6
4
|
import subprocess
|
|
7
5
|
import time
|
|
8
6
|
from os import PathLike
|
|
9
7
|
from pathlib import Path
|
|
10
|
-
from threading import Thread
|
|
11
8
|
|
|
12
9
|
import docker
|
|
13
|
-
from colorama import Fore, Style
|
|
14
10
|
from docker.client import DockerClient
|
|
15
|
-
from docker.models.containers import Container
|
|
16
|
-
from sqlalchemy.engine.url import make_url
|
|
17
11
|
|
|
18
12
|
from vantage6.common import error, info, warning
|
|
19
|
-
from vantage6.common.
|
|
20
|
-
from vantage6.common.docker.addons import check_docker_running, pull_image
|
|
13
|
+
from vantage6.common.docker.addons import pull_image
|
|
21
14
|
from vantage6.common.globals import (
|
|
22
|
-
APPNAME,
|
|
23
15
|
DEFAULT_ALGO_STORE_IMAGE,
|
|
24
16
|
DEFAULT_CHART_REPO,
|
|
25
17
|
DEFAULT_DOCKER_REGISTRY,
|
|
@@ -29,83 +21,8 @@ from vantage6.common.globals import (
|
|
|
29
21
|
InstanceType,
|
|
30
22
|
)
|
|
31
23
|
|
|
32
|
-
from vantage6.cli.
|
|
33
|
-
from vantage6.cli.
|
|
34
|
-
from vantage6.cli.globals import AlgoStoreGlobals, ServerGlobals
|
|
35
|
-
from vantage6.cli.utils import (
|
|
36
|
-
check_config_name_allowed,
|
|
37
|
-
validate_input_cmd_args,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def check_for_start(ctx: AppContext, type_: InstanceType) -> DockerClient:
|
|
42
|
-
"""
|
|
43
|
-
Check if all requirements are met to start the instance.
|
|
44
|
-
|
|
45
|
-
Parameters
|
|
46
|
-
----------
|
|
47
|
-
ctx : AppContext
|
|
48
|
-
The context object
|
|
49
|
-
type_ : InstanceType
|
|
50
|
-
The type of instance to check for
|
|
51
|
-
|
|
52
|
-
Returns
|
|
53
|
-
-------
|
|
54
|
-
DockerClient
|
|
55
|
-
A Docker client instance
|
|
56
|
-
"""
|
|
57
|
-
# will print an error if not
|
|
58
|
-
check_docker_running()
|
|
59
|
-
|
|
60
|
-
info("Finding Docker daemon.")
|
|
61
|
-
docker_client = docker.from_env()
|
|
62
|
-
|
|
63
|
-
# check if name is allowed for docker volume, else exit
|
|
64
|
-
check_config_name_allowed(ctx.name)
|
|
65
|
-
|
|
66
|
-
# check that this server is not already running
|
|
67
|
-
running_servers = docker_client.containers.list(
|
|
68
|
-
filters={"label": f"{APPNAME}-type={type_}"}
|
|
69
|
-
)
|
|
70
|
-
for server in running_servers:
|
|
71
|
-
if server.name == f"{APPNAME}-{ctx.name}-{ctx.scope}-{type_}":
|
|
72
|
-
error(f"Server {Fore.RED}{ctx.name}{Style.RESET_ALL} is already running")
|
|
73
|
-
exit(1)
|
|
74
|
-
return docker_client
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def get_image(
|
|
78
|
-
image: str, ctx: AppContext, custom_image_key: str, default_image: str
|
|
79
|
-
) -> str:
|
|
80
|
-
"""
|
|
81
|
-
Get the image name for the given instance type.
|
|
82
|
-
|
|
83
|
-
Parameters
|
|
84
|
-
----------
|
|
85
|
-
image : str | None
|
|
86
|
-
The image name to use if specified
|
|
87
|
-
ctx : AppContext
|
|
88
|
-
The context object
|
|
89
|
-
custom_image_key : str
|
|
90
|
-
The key to look for in the config file
|
|
91
|
-
default_image : str
|
|
92
|
-
The default image name
|
|
93
|
-
|
|
94
|
-
Returns
|
|
95
|
-
-------
|
|
96
|
-
str
|
|
97
|
-
The image name to use
|
|
98
|
-
"""
|
|
99
|
-
# Determine image-name. First we check if the option --image has been used.
|
|
100
|
-
# Then we check if the image has been specified in the config file, and
|
|
101
|
-
# finally we use the default settings from the package.
|
|
102
|
-
if image is None:
|
|
103
|
-
custom_images: dict = ctx.config.get("images")
|
|
104
|
-
if custom_images:
|
|
105
|
-
image = custom_images.get(custom_image_key)
|
|
106
|
-
if not image:
|
|
107
|
-
image = f"{DEFAULT_DOCKER_REGISTRY}/{default_image}"
|
|
108
|
-
return image
|
|
24
|
+
from vantage6.cli.globals import ChartName
|
|
25
|
+
from vantage6.cli.utils import validate_input_cmd_args
|
|
109
26
|
|
|
110
27
|
|
|
111
28
|
def pull_infra_image(
|
|
@@ -129,8 +46,8 @@ def pull_infra_image(
|
|
|
129
46
|
try:
|
|
130
47
|
pull_image(client, image, suppress_error=True)
|
|
131
48
|
except docker.errors.APIError:
|
|
132
|
-
if not
|
|
133
|
-
if
|
|
49
|
+
if not _is_default_infra_image(image, instance_type):
|
|
50
|
+
if _image_exists_locally(client, image):
|
|
134
51
|
warning("Failed to pull infrastructure image! Will use local image...")
|
|
135
52
|
else:
|
|
136
53
|
error("Failed to pull infrastructure image!")
|
|
@@ -141,7 +58,7 @@ def pull_infra_image(
|
|
|
141
58
|
exit(1)
|
|
142
59
|
|
|
143
60
|
|
|
144
|
-
def
|
|
61
|
+
def _is_default_infra_image(image: str, instance_type: InstanceType) -> bool:
|
|
145
62
|
"""
|
|
146
63
|
Check if an infrastructure image is the default image.
|
|
147
64
|
|
|
@@ -167,7 +84,7 @@ def is_default_infra_image(image: str, instance_type: InstanceType) -> bool:
|
|
|
167
84
|
return image == f"{DEFAULT_DOCKER_REGISTRY}/{DEFAULT_NODE_IMAGE}"
|
|
168
85
|
|
|
169
86
|
|
|
170
|
-
def
|
|
87
|
+
def _image_exists_locally(client: DockerClient, image: str) -> bool:
|
|
171
88
|
"""
|
|
172
89
|
Check if the image exists locally.
|
|
173
90
|
|
|
@@ -190,137 +107,9 @@ def image_exists_locally(client: DockerClient, image: str) -> bool:
|
|
|
190
107
|
return True
|
|
191
108
|
|
|
192
109
|
|
|
193
|
-
def mount_config_file(ctx: AppContext, config_file: str) -> list[docker.types.Mount]:
|
|
194
|
-
"""
|
|
195
|
-
Mount the config file in the container.
|
|
196
|
-
|
|
197
|
-
Parameters
|
|
198
|
-
----------
|
|
199
|
-
ctx : AppContext
|
|
200
|
-
The context object
|
|
201
|
-
config_file : str
|
|
202
|
-
The path to the config file
|
|
203
|
-
|
|
204
|
-
Returns
|
|
205
|
-
-------
|
|
206
|
-
list[docker.types.Mount]
|
|
207
|
-
The mounts to use
|
|
208
|
-
"""
|
|
209
|
-
info("Creating mounts")
|
|
210
|
-
return [docker.types.Mount(config_file, str(ctx.config_file), type="bind")]
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
def mount_source(mount_src: str) -> docker.types.Mount:
|
|
214
|
-
"""
|
|
215
|
-
Mount the vantage6 source code in the container.
|
|
216
|
-
|
|
217
|
-
Parameters
|
|
218
|
-
----------
|
|
219
|
-
mount_src : str
|
|
220
|
-
The path to the source code
|
|
221
|
-
|
|
222
|
-
Returns
|
|
223
|
-
-------
|
|
224
|
-
docker.types.Mount | None
|
|
225
|
-
The mount to use
|
|
226
|
-
"""
|
|
227
|
-
if mount_src:
|
|
228
|
-
mount_src = os.path.abspath(mount_src)
|
|
229
|
-
return docker.types.Mount("/vantage6", mount_src, type="bind")
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
def mount_database(
|
|
233
|
-
ctx: ServerContext | AlgorithmStoreContext, type_: InstanceType
|
|
234
|
-
) -> tuple[docker.types.Mount, dict]:
|
|
235
|
-
"""
|
|
236
|
-
Mount database in the container if it is file-based (e.g. a SQLite DB).
|
|
237
|
-
|
|
238
|
-
Parameters
|
|
239
|
-
----------
|
|
240
|
-
ctx : AppContext
|
|
241
|
-
The context object
|
|
242
|
-
type_ : InstanceType
|
|
243
|
-
The type of instance to mount the database for
|
|
244
|
-
|
|
245
|
-
Returns
|
|
246
|
-
-------
|
|
247
|
-
docker.types.Mount | None
|
|
248
|
-
The mount to use
|
|
249
|
-
dict | None
|
|
250
|
-
The environment variables to use
|
|
251
|
-
"""
|
|
252
|
-
# FIXME: code duplication with cli_server_import()
|
|
253
|
-
# try to mount database
|
|
254
|
-
uri = ctx.config["uri"]
|
|
255
|
-
url = make_url(uri)
|
|
256
|
-
environment_vars = {}
|
|
257
|
-
mount = None
|
|
258
|
-
|
|
259
|
-
# If host is None, we're dealing with a file-based DB, like SQLite
|
|
260
|
-
if url.host is None:
|
|
261
|
-
db_path = url.database
|
|
262
|
-
|
|
263
|
-
if not os.path.isabs(db_path):
|
|
264
|
-
# We're dealing with a relative path here -> make it absolute
|
|
265
|
-
db_path = ctx.data_dir / url.database
|
|
266
|
-
|
|
267
|
-
basename = os.path.basename(db_path)
|
|
268
|
-
dirname = os.path.dirname(db_path)
|
|
269
|
-
os.makedirs(dirname, exist_ok=True)
|
|
270
|
-
|
|
271
|
-
# we're mounting the entire folder that contains the database
|
|
272
|
-
mount = docker.types.Mount("/mnt/database/", dirname, type="bind")
|
|
273
|
-
|
|
274
|
-
if type_ == InstanceType.SERVER:
|
|
275
|
-
environment_vars = {
|
|
276
|
-
ServerGlobals.DB_URI_ENV_VAR.value: f"sqlite:////mnt/database/{basename}",
|
|
277
|
-
ServerGlobals.CONFIG_NAME_ENV_VAR.value: ctx.config_file_name,
|
|
278
|
-
}
|
|
279
|
-
elif type_ == InstanceType.ALGORITHM_STORE:
|
|
280
|
-
environment_vars = {
|
|
281
|
-
AlgoStoreGlobals.DB_URI_ENV_VAR.value: f"sqlite:////mnt/database/{basename}",
|
|
282
|
-
AlgoStoreGlobals.CONFIG_NAME_ENV_VAR.value: ctx.config_file_name,
|
|
283
|
-
}
|
|
284
|
-
else:
|
|
285
|
-
warning(
|
|
286
|
-
f"Database could not be transferred, make sure {url.host} "
|
|
287
|
-
"is reachable from the Docker container"
|
|
288
|
-
)
|
|
289
|
-
info("Consider using the docker-compose method to start a server")
|
|
290
|
-
|
|
291
|
-
return mount, environment_vars
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
# TODO v5+ remove this function, it is replaced by the `attach_logs` function in
|
|
295
|
-
# `vantage6.cli.common.utils`
|
|
296
|
-
def attach_logs(container: Container, type_: InstanceType) -> None:
|
|
297
|
-
"""
|
|
298
|
-
Attach container logs to the console if specified.
|
|
299
|
-
|
|
300
|
-
Parameters
|
|
301
|
-
----------
|
|
302
|
-
container : Container
|
|
303
|
-
The container to attach the logs from
|
|
304
|
-
type_ : InstanceType
|
|
305
|
-
The type of instance to attach the logs for
|
|
306
|
-
"""
|
|
307
|
-
logs = container.attach(stream=True, logs=True, stdout=True)
|
|
308
|
-
Thread(target=print_log_worker, args=(logs,), daemon=True).start()
|
|
309
|
-
while True:
|
|
310
|
-
try:
|
|
311
|
-
time.sleep(1)
|
|
312
|
-
except KeyboardInterrupt:
|
|
313
|
-
info("Closing log file. Keyboard Interrupt.")
|
|
314
|
-
info(
|
|
315
|
-
"Note that your server is still running! Shut it down "
|
|
316
|
-
f"with {Fore.RED}v6 {type_} stop{Style.RESET_ALL}"
|
|
317
|
-
)
|
|
318
|
-
exit(0)
|
|
319
|
-
|
|
320
|
-
|
|
321
110
|
def helm_install(
|
|
322
111
|
release_name: str,
|
|
323
|
-
chart_name:
|
|
112
|
+
chart_name: ChartName,
|
|
324
113
|
values_file: str | PathLike | None = None,
|
|
325
114
|
context: str | None = None,
|
|
326
115
|
namespace: str | None = None,
|
|
@@ -361,6 +150,7 @@ def helm_install(
|
|
|
361
150
|
chart_name,
|
|
362
151
|
"--repo",
|
|
363
152
|
DEFAULT_CHART_REPO,
|
|
153
|
+
# TODO v5+ remove this flag when we have a stable release
|
|
364
154
|
"--devel", # ensure using latest version including pre-releases
|
|
365
155
|
]
|
|
366
156
|
|
|
@@ -380,14 +170,18 @@ def helm_install(
|
|
|
380
170
|
check=True,
|
|
381
171
|
)
|
|
382
172
|
info(
|
|
383
|
-
f"Successfully installed release '{release_name}' using chart
|
|
173
|
+
f"Successfully installed release '{release_name}' using chart "
|
|
174
|
+
f"'{chart_name}'."
|
|
384
175
|
)
|
|
385
|
-
except subprocess.CalledProcessError
|
|
386
|
-
error(f"Failed to install release '{release_name}'
|
|
176
|
+
except subprocess.CalledProcessError:
|
|
177
|
+
error(f"Failed to install release '{release_name}'.")
|
|
178
|
+
exit(1)
|
|
387
179
|
except FileNotFoundError:
|
|
388
180
|
error(
|
|
389
|
-
"Helm command not found. Please ensure Helm is installed and available in
|
|
181
|
+
"Helm command not found. Please ensure Helm is installed and available in "
|
|
182
|
+
"the PATH."
|
|
390
183
|
)
|
|
184
|
+
exit(1)
|
|
391
185
|
|
|
392
186
|
|
|
393
187
|
def start_port_forward(
|