vantage6 5.0.0a0__py3-none-any.whl → 5.0.0a9__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.
- tests_cli/test_node_cli.py +36 -25
- tests_cli/test_server_cli.py +33 -12
- tests_cli/test_wizard.py +5 -5
- vantage6/cli/__build__ +1 -1
- vantage6/cli/__init__.py +1 -1
- vantage6/cli/algorithm/create.py +26 -8
- vantage6/cli/algorithm/update.py +5 -1
- vantage6/cli/algostore/attach.py +6 -25
- vantage6/cli/algostore/new.py +9 -3
- vantage6/cli/cli.py +6 -11
- vantage6/cli/common/start.py +1 -1
- vantage6/cli/common/utils.py +42 -4
- vantage6/cli/configuration_wizard.py +63 -51
- vantage6/cli/context/node.py +18 -1
- vantage6/cli/node/attach.py +5 -62
- vantage6/cli/node/clean.py +6 -2
- vantage6/cli/node/common/__init__.py +26 -4
- vantage6/cli/node/create_private_key.py +10 -2
- vantage6/cli/node/new.py +7 -3
- vantage6/cli/node/restart.py +128 -0
- vantage6/cli/node/set_api_key.py +7 -3
- vantage6/cli/node/start.py +12 -4
- vantage6/cli/node/stop.py +7 -3
- vantage6/cli/node/version.py +7 -3
- vantage6/cli/server/attach.py +5 -51
- vantage6/cli/server/new.py +7 -3
- vantage6/cli/server/start.py +1 -1
- vantage6/cli/server/stop.py +7 -3
- vantage6/cli/template/node_config.j2 +3 -1
- vantage6/cli/test/common/diagnostic_runner.py +2 -4
- vantage6/cli/test/feature_tester.py +10 -3
- vantage6/cli/test/integration_test.py +113 -113
- vantage6/cli/utils.py +5 -1
- {vantage6-5.0.0a0.dist-info → vantage6-5.0.0a9.dist-info}/METADATA +5 -5
- vantage6-5.0.0a9.dist-info/RECORD +70 -0
- vantage6/cli/dev/create.py +0 -632
- vantage6/cli/dev/data/olympic_athletes_2016.csv +0 -2425
- vantage6/cli/dev/remove.py +0 -94
- vantage6/cli/dev/start.py +0 -123
- vantage6/cli/dev/stop.py +0 -47
- vantage6/cli/dev/utils.py +0 -24
- vantage6-5.0.0a0.dist-info/RECORD +0 -75
- {vantage6-5.0.0a0.dist-info → vantage6-5.0.0a9.dist-info}/WHEEL +0 -0
- {vantage6-5.0.0a0.dist-info → vantage6-5.0.0a9.dist-info}/entry_points.txt +0 -0
- {vantage6-5.0.0a0.dist-info → vantage6-5.0.0a9.dist-info}/top_level.txt +0 -0
tests_cli/test_node_cli.py
CHANGED
|
@@ -17,6 +17,7 @@ from vantage6.cli.node.list import cli_node_list
|
|
|
17
17
|
from vantage6.cli.node.new import cli_node_new_configuration
|
|
18
18
|
from vantage6.cli.node.files import cli_node_files
|
|
19
19
|
from vantage6.cli.node.start import cli_node_start
|
|
20
|
+
from vantage6.cli.node.restart import cli_node_restart
|
|
20
21
|
from vantage6.cli.node.stop import cli_node_stop
|
|
21
22
|
from vantage6.cli.node.attach import cli_node_attach
|
|
22
23
|
from vantage6.cli.node.create_private_key import cli_node_create_private_key
|
|
@@ -85,7 +86,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
85
86
|
)
|
|
86
87
|
|
|
87
88
|
@patch("vantage6.cli.node.new.configuration_wizard")
|
|
88
|
-
@patch("vantage6.cli.node.new.
|
|
89
|
+
@patch("vantage6.cli.node.new.ensure_config_dir_writable")
|
|
89
90
|
@patch("vantage6.cli.node.common.NodeContext")
|
|
90
91
|
def test_new_config(self, context, permissions, wizard):
|
|
91
92
|
"""No error produced when creating new configuration."""
|
|
@@ -147,7 +148,7 @@ class NodeCLITest(unittest.TestCase):
|
|
|
147
148
|
# check non-zero exit code
|
|
148
149
|
self.assertEqual(result.exit_code, 1)
|
|
149
150
|
|
|
150
|
-
@patch("vantage6.cli.node.new.
|
|
151
|
+
@patch("vantage6.cli.node.new.ensure_config_dir_writable")
|
|
151
152
|
@patch("vantage6.cli.node.common.NodeContext")
|
|
152
153
|
def test_new_write_permissions(self, context, permissions):
|
|
153
154
|
"""User needs write permissions."""
|
|
@@ -243,19 +244,28 @@ class NodeCLITest(unittest.TestCase):
|
|
|
243
244
|
|
|
244
245
|
runner = CliRunner()
|
|
245
246
|
|
|
247
|
+
# Should fail when starting node with non-existing database CSV file
|
|
246
248
|
with runner.isolated_filesystem():
|
|
247
249
|
result = runner.invoke(cli_node_start, ["--name", "some-name"])
|
|
250
|
+
self.assertEqual(result.exit_code, 1)
|
|
248
251
|
|
|
252
|
+
# now do it with a SQL database which doesn't have to be an existing file
|
|
253
|
+
ctx.databases = [{"label": "some_label", "uri": "data.db", "type": "sql"}]
|
|
254
|
+
with runner.isolated_filesystem():
|
|
255
|
+
result = runner.invoke(cli_node_start, ["--name", "some-name"])
|
|
249
256
|
self.assertEqual(result.exit_code, 0)
|
|
250
257
|
|
|
258
|
+
def _setup_stop_test(self, containers):
|
|
259
|
+
container1 = MagicMock()
|
|
260
|
+
container1.name = f"{APPNAME}-iknl-user"
|
|
261
|
+
containers.list.return_value = [container1]
|
|
262
|
+
|
|
251
263
|
@patch("docker.DockerClient.containers")
|
|
252
264
|
@patch("vantage6.cli.node.stop.check_docker_running", return_value=True)
|
|
253
265
|
@patch("vantage6.cli.node.stop.NodeContext")
|
|
254
266
|
@patch("vantage6.cli.node.stop.delete_volume_if_exists")
|
|
255
267
|
def test_stop(self, delete_volume, node_context, check_docker, containers):
|
|
256
|
-
|
|
257
|
-
container1.name = f"{APPNAME}-iknl-user"
|
|
258
|
-
containers.list.return_value = [container1]
|
|
268
|
+
self._setup_stop_test(containers)
|
|
259
269
|
|
|
260
270
|
runner = CliRunner()
|
|
261
271
|
|
|
@@ -267,30 +277,31 @@ class NodeCLITest(unittest.TestCase):
|
|
|
267
277
|
|
|
268
278
|
self.assertEqual(result.exit_code, 0)
|
|
269
279
|
|
|
270
|
-
@patch("vantage6.cli.node.attach.time")
|
|
271
|
-
@patch("vantage6.cli.node.attach.print_log_worker")
|
|
272
280
|
@patch("docker.DockerClient.containers")
|
|
273
|
-
@patch("vantage6.cli.node.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
@patch("vantage6.cli.node.stop.check_docker_running", return_value=True)
|
|
282
|
+
@patch("vantage6.cli.node.stop.NodeContext")
|
|
283
|
+
@patch("vantage6.cli.node.stop.delete_volume_if_exists")
|
|
284
|
+
@patch("vantage6.cli.node.restart.subprocess.run")
|
|
285
|
+
def test_restart(
|
|
286
|
+
self, subprocess_run, delete_volume, node_context, check_docker, containers
|
|
287
|
+
):
|
|
288
|
+
"""Restart a node without errors."""
|
|
289
|
+
self._setup_stop_test(containers)
|
|
290
|
+
# The subprocess.run() function is called with the command to start the node.
|
|
291
|
+
# Unfortunately it is hard to test this, so we just return a successful run
|
|
292
|
+
subprocess_run.return_value = MagicMock(returncode=0)
|
|
283
293
|
runner = CliRunner()
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
self.assertEqual(
|
|
287
|
-
result.output,
|
|
288
|
-
"[info ] - Closing log file. Keyboard Interrupt.\n"
|
|
289
|
-
"[info ] - Note that your node is still running! Shut it down "
|
|
290
|
-
"with 'v6 node stop'\n",
|
|
291
|
-
)
|
|
294
|
+
with runner.isolated_filesystem():
|
|
295
|
+
result = runner.invoke(cli_node_restart, ["--name", "iknl"])
|
|
292
296
|
self.assertEqual(result.exit_code, 0)
|
|
293
297
|
|
|
298
|
+
@patch("vantage6.cli.node.attach.attach_logs")
|
|
299
|
+
def test_attach(self, attach_logs):
|
|
300
|
+
"""Attach docker logs without errors."""
|
|
301
|
+
runner = CliRunner()
|
|
302
|
+
runner.invoke(cli_node_attach)
|
|
303
|
+
attach_logs.assert_called_once_with("app=node")
|
|
304
|
+
|
|
294
305
|
@patch("vantage6.cli.node.clean.q")
|
|
295
306
|
@patch("docker.DockerClient.volumes")
|
|
296
307
|
@patch("vantage6.cli.node.clean.check_docker_running", return_value=True)
|
tests_cli/test_server_cli.py
CHANGED
|
@@ -5,6 +5,7 @@ from pathlib import Path
|
|
|
5
5
|
from click.testing import CliRunner
|
|
6
6
|
|
|
7
7
|
from vantage6.common.globals import APPNAME, InstanceType
|
|
8
|
+
from vantage6.cli.common.utils import attach_logs
|
|
8
9
|
from vantage6.cli.server.start import cli_server_start
|
|
9
10
|
from vantage6.cli.server.list import cli_server_configuration_list
|
|
10
11
|
from vantage6.cli.server.files import cli_server_files
|
|
@@ -112,7 +113,7 @@ class ServerCLITest(unittest.TestCase):
|
|
|
112
113
|
self.assertEqual(result.exit_code, 0)
|
|
113
114
|
|
|
114
115
|
@patch("vantage6.cli.server.new.configuration_wizard")
|
|
115
|
-
@patch("vantage6.cli.server.new.
|
|
116
|
+
@patch("vantage6.cli.server.new.ensure_config_dir_writable")
|
|
116
117
|
@patch("vantage6.cli.server.new.ServerContext")
|
|
117
118
|
def test_new(self, context, permissions, wizard):
|
|
118
119
|
"""New configuration without errors."""
|
|
@@ -141,18 +142,38 @@ class ServerCLITest(unittest.TestCase):
|
|
|
141
142
|
self.assertIsNone(result.exception)
|
|
142
143
|
self.assertEqual(result.exit_code, 0)
|
|
143
144
|
|
|
144
|
-
@patch("vantage6.cli.server.attach.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"""Attach log to the console without errors."""
|
|
148
|
-
container1 = MagicMock()
|
|
149
|
-
container1.name = f"{APPNAME}-iknl-system-{InstanceType.SERVER}"
|
|
150
|
-
containers.list.return_value = [container1]
|
|
151
|
-
|
|
152
|
-
sleep.side_effect = KeyboardInterrupt("Boom!")
|
|
153
|
-
|
|
145
|
+
@patch("vantage6.cli.server.attach.attach_logs")
|
|
146
|
+
def test_attach(self, attach_logs):
|
|
147
|
+
"""Attach logs to the console without errors."""
|
|
154
148
|
runner = CliRunner()
|
|
155
|
-
result = runner.invoke(cli_server_attach
|
|
149
|
+
result = runner.invoke(cli_server_attach)
|
|
156
150
|
|
|
157
151
|
self.assertIsNone(result.exception)
|
|
158
152
|
self.assertEqual(result.exit_code, 0)
|
|
153
|
+
attach_logs.assert_called_once_with(
|
|
154
|
+
"app=vantage6-server", "component=vantage6-server"
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
@patch("vantage6.cli.common.utils.Popen")
|
|
158
|
+
def test_attach_logs(self, mock_popen):
|
|
159
|
+
# Mock the Popen instance and its methods
|
|
160
|
+
mock_process = mock_popen.return_value
|
|
161
|
+
mock_process.wait.return_value = None
|
|
162
|
+
|
|
163
|
+
# Call the function with a sample label
|
|
164
|
+
attach_logs("app=node", "env=dev")
|
|
165
|
+
|
|
166
|
+
# Construct the expected command
|
|
167
|
+
expected_command = [
|
|
168
|
+
"devspace",
|
|
169
|
+
"logs",
|
|
170
|
+
"--follow",
|
|
171
|
+
"--label-selector",
|
|
172
|
+
"app=node,env=dev",
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
# Verify that Popen was called with the expected command
|
|
176
|
+
mock_popen.assert_called_once_with(expected_command, stdout=None, stderr=None)
|
|
177
|
+
|
|
178
|
+
# Verify that wait was called on the process
|
|
179
|
+
mock_process.wait.assert_called_once()
|
tests_cli/test_wizard.py
CHANGED
|
@@ -33,8 +33,8 @@ class WizardTest(unittest.TestCase):
|
|
|
33
33
|
"""An error is printed when docker is not running"""
|
|
34
34
|
|
|
35
35
|
with patch(f"{module_path}.q") as q:
|
|
36
|
-
q.
|
|
37
|
-
q.confirm.return_value.
|
|
36
|
+
q.unsafe_prompt.side_effect = self.prompts
|
|
37
|
+
q.confirm.return_value.unsafe_ask.side_effect = [
|
|
38
38
|
True, # add a database
|
|
39
39
|
False, # don't enable two-factor authentication
|
|
40
40
|
True, # add VPN server
|
|
@@ -79,8 +79,8 @@ class WizardTest(unittest.TestCase):
|
|
|
79
79
|
|
|
80
80
|
def test_server_wizard(self):
|
|
81
81
|
with patch(f"{module_path}.q") as q:
|
|
82
|
-
q.
|
|
83
|
-
q.confirm.return_value.
|
|
82
|
+
q.unsafe_prompt.side_effect = self.prompts
|
|
83
|
+
q.confirm.return_value.unsafe_ask.side_effect = [
|
|
84
84
|
True,
|
|
85
85
|
True,
|
|
86
86
|
True,
|
|
@@ -134,7 +134,7 @@ class WizardTest(unittest.TestCase):
|
|
|
134
134
|
available_configurations.return_value = [[config], []]
|
|
135
135
|
|
|
136
136
|
with patch(f"{module_path}.q") as q:
|
|
137
|
-
q.select.return_value.
|
|
137
|
+
q.select.return_value.unsafe_ask.return_value = "vtg6"
|
|
138
138
|
name = select_configuration_questionaire(InstanceType.NODE, True)
|
|
139
139
|
|
|
140
140
|
self.assertEqual(name, "vtg6")
|
vantage6/cli/__build__
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
9
|
vantage6/cli/__init__.py
CHANGED
vantage6/cli/algorithm/create.py
CHANGED
|
@@ -33,14 +33,11 @@ def cli_algorithm_create(name: str, directory: str) -> dict:
|
|
|
33
33
|
can be used to build an appropriate Docker image that can be used as a
|
|
34
34
|
vantage6 algorithm.
|
|
35
35
|
"""
|
|
36
|
-
|
|
37
|
-
name =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
directory = q.text(
|
|
42
|
-
"Directory to put the algorithm in:", default=default_dir
|
|
43
|
-
).ask()
|
|
36
|
+
try:
|
|
37
|
+
name, directory = _get_user_input(name, directory)
|
|
38
|
+
except KeyboardInterrupt:
|
|
39
|
+
info("Aborted by user!")
|
|
40
|
+
return
|
|
44
41
|
|
|
45
42
|
# Create the template. The `unsafe` flag is used to allow running a Python script
|
|
46
43
|
# after creating the template that cleans up some things.
|
|
@@ -49,3 +46,24 @@ def cli_algorithm_create(name: str, directory: str) -> dict:
|
|
|
49
46
|
)
|
|
50
47
|
info("Template created!")
|
|
51
48
|
info(f"You can find your new algorithm in: {directory}")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _get_user_input(name: str, directory: str) -> None:
|
|
52
|
+
"""Get user input for the algorithm creation
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
name : str
|
|
57
|
+
Name for the new algorithm
|
|
58
|
+
directory : str
|
|
59
|
+
Directory to put the algorithm into
|
|
60
|
+
"""
|
|
61
|
+
if not name:
|
|
62
|
+
name = q.text("Name of your new algorithm:").unsafe_ask()
|
|
63
|
+
|
|
64
|
+
if not directory:
|
|
65
|
+
default_dir = str(Path(os.getcwd()) / name)
|
|
66
|
+
directory = q.text(
|
|
67
|
+
"Directory to put the algorithm in:", default=default_dir
|
|
68
|
+
).unsafe_ask()
|
|
69
|
+
return name, directory
|
vantage6/cli/algorithm/update.py
CHANGED
|
@@ -34,7 +34,11 @@ def cli_algorithm_update(directory: str, change_answers: bool) -> dict:
|
|
|
34
34
|
"""
|
|
35
35
|
if not directory:
|
|
36
36
|
default_dir = str(Path(os.getcwd()))
|
|
37
|
-
|
|
37
|
+
try:
|
|
38
|
+
directory = q.text("Algorithm directory:", default=default_dir).unsafe_ask()
|
|
39
|
+
except KeyboardInterrupt:
|
|
40
|
+
info("Aborted by user!")
|
|
41
|
+
return
|
|
38
42
|
|
|
39
43
|
info("Updating template...")
|
|
40
44
|
try:
|
vantage6/cli/algostore/attach.py
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
import click
|
|
2
|
-
import docker
|
|
3
2
|
|
|
4
|
-
from
|
|
5
|
-
|
|
6
|
-
from vantage6.common import error
|
|
7
|
-
from vantage6.common.docker.addons import check_docker_running
|
|
8
|
-
from vantage6.common.globals import APPNAME, InstanceType
|
|
9
|
-
from vantage6.cli.common.decorator import click_insert_context
|
|
10
|
-
from vantage6.cli.common.start import attach_logs
|
|
11
|
-
from vantage6.cli.context.algorithm_store import AlgorithmStoreContext
|
|
3
|
+
from vantage6.common import info
|
|
4
|
+
from vantage6.cli.common.utils import attach_logs
|
|
12
5
|
|
|
13
6
|
|
|
14
7
|
@click.command()
|
|
15
|
-
|
|
16
|
-
def cli_algo_store_attach(ctx: AlgorithmStoreContext) -> None:
|
|
8
|
+
def cli_algo_store_attach() -> None:
|
|
17
9
|
"""
|
|
18
|
-
Show the
|
|
10
|
+
Show the store logs in the current console.
|
|
19
11
|
"""
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
running_servers = client.containers.list(
|
|
24
|
-
filters={"label": f"{APPNAME}-type={InstanceType.ALGORITHM_STORE}"}
|
|
25
|
-
)
|
|
26
|
-
running_server_names = [container.name for container in running_servers]
|
|
27
|
-
|
|
28
|
-
if ctx.docker_container_name in running_server_names:
|
|
29
|
-
container = client.containers.get(ctx.docker_container_name)
|
|
30
|
-
attach_logs(container, InstanceType.ALGORITHM_STORE)
|
|
31
|
-
else:
|
|
32
|
-
error(f"{Fore.RED}{ctx.name}{Style.RESET_ALL} is not running!")
|
|
12
|
+
info("Attaching to store logs...")
|
|
13
|
+
attach_logs("app=store", "component=store-server")
|
vantage6/cli/algostore/new.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import click
|
|
2
2
|
from colorama import Fore, Style
|
|
3
3
|
|
|
4
|
-
from vantage6.common import info, error,
|
|
4
|
+
from vantage6.common import info, error, ensure_config_dir_writable
|
|
5
5
|
from vantage6.common.globals import InstanceType
|
|
6
6
|
from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
|
|
7
7
|
from vantage6.cli.context.algorithm_store import AlgorithmStoreContext
|
|
@@ -36,7 +36,7 @@ def cli_algo_store_new(name: str, system_folders: bool) -> None:
|
|
|
36
36
|
exit(1)
|
|
37
37
|
|
|
38
38
|
# Check that we can write in this folder
|
|
39
|
-
if not
|
|
39
|
+
if not ensure_config_dir_writable(system_folders):
|
|
40
40
|
error("Your user does not have write access to all folders. Exiting")
|
|
41
41
|
info(
|
|
42
42
|
f"Create a new server using '{Fore.GREEN}v6 algorithm-store new "
|
|
@@ -45,7 +45,13 @@ def cli_algo_store_new(name: str, system_folders: bool) -> None:
|
|
|
45
45
|
exit(1)
|
|
46
46
|
|
|
47
47
|
# create config in ctx location
|
|
48
|
-
|
|
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)
|
|
49
55
|
info(f"New configuration created: {Fore.GREEN}{cfg_file}{Style.RESET_ALL}")
|
|
50
56
|
|
|
51
57
|
flag = "" if system_folders else "--user"
|
vantage6/cli/cli.py
CHANGED
|
@@ -17,18 +17,16 @@ from vantage6.cli.node.files import cli_node_files
|
|
|
17
17
|
from vantage6.cli.node.list import cli_node_list
|
|
18
18
|
from vantage6.cli.node.new import cli_node_new_configuration
|
|
19
19
|
from vantage6.cli.node.remove import cli_node_remove
|
|
20
|
+
from vantage6.cli.node.restart import cli_node_restart
|
|
20
21
|
from vantage6.cli.node.set_api_key import cli_node_set_api_key
|
|
21
22
|
from vantage6.cli.node.start import cli_node_start
|
|
22
23
|
from vantage6.cli.node.stop import cli_node_stop
|
|
23
24
|
from vantage6.cli.node.version import cli_node_version
|
|
24
|
-
from vantage6.cli.dev.create import create_demo_network
|
|
25
|
-
from vantage6.cli.dev.remove import remove_demo_network
|
|
26
|
-
from vantage6.cli.dev.start import start_demo_network
|
|
27
|
-
from vantage6.cli.dev.stop import stop_demo_network
|
|
28
25
|
from vantage6.cli.algorithm.create import cli_algorithm_create
|
|
29
26
|
from vantage6.cli.algorithm.update import cli_algorithm_update
|
|
30
27
|
from vantage6.cli.test.feature_tester import cli_test_features
|
|
31
|
-
|
|
28
|
+
|
|
29
|
+
# from vantage6.cli.test.integration_test import cli_test_integration
|
|
32
30
|
from vantage6.cli.algostore.attach import cli_algo_store_attach
|
|
33
31
|
from vantage6.cli.algostore.new import cli_algo_store_new
|
|
34
32
|
from vantage6.cli.algostore.start import cli_algo_store_start
|
|
@@ -75,6 +73,7 @@ cli_node.add_command(cli_node_files, name="files")
|
|
|
75
73
|
cli_node.add_command(cli_node_list, name="list")
|
|
76
74
|
cli_node.add_command(cli_node_new_configuration, name="new")
|
|
77
75
|
cli_node.add_command(cli_node_remove, name="remove")
|
|
76
|
+
cli_node.add_command(cli_node_restart, name="restart")
|
|
78
77
|
cli_node.add_command(cli_node_set_api_key, name="set-api-key")
|
|
79
78
|
cli_node.add_command(cli_node_start, name="start")
|
|
80
79
|
cli_node.add_command(cli_node_stop, name="stop")
|
|
@@ -91,11 +90,7 @@ def cli_dev() -> None:
|
|
|
91
90
|
"""
|
|
92
91
|
|
|
93
92
|
|
|
94
|
-
#
|
|
95
|
-
cli_dev.add_command(create_demo_network, name="create-demo-network")
|
|
96
|
-
cli_dev.add_command(remove_demo_network, name="remove-demo-network")
|
|
97
|
-
cli_dev.add_command(start_demo_network, name="start-demo-network")
|
|
98
|
-
cli_dev.add_command(stop_demo_network, name="stop-demo-network")
|
|
93
|
+
# TODO add commands for the dev group
|
|
99
94
|
|
|
100
95
|
|
|
101
96
|
# Define the algorithm group
|
|
@@ -121,7 +116,7 @@ def cli_test() -> None:
|
|
|
121
116
|
|
|
122
117
|
# Define the commands for the test group
|
|
123
118
|
cli_test.add_command(cli_test_features, name="feature-test")
|
|
124
|
-
cli_test.add_command(cli_test_integration, name="integration-test")
|
|
119
|
+
# cli_test.add_command(cli_test_integration, name="integration-test")
|
|
125
120
|
|
|
126
121
|
|
|
127
122
|
# Define the algorithm-store group
|
vantage6/cli/common/start.py
CHANGED
vantage6/cli/common/utils.py
CHANGED
|
@@ -3,6 +3,7 @@ from colorama import Fore, Style
|
|
|
3
3
|
import click
|
|
4
4
|
from typing import Iterable
|
|
5
5
|
import docker
|
|
6
|
+
from subprocess import Popen
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
from vantage6.common import warning, error
|
|
@@ -38,10 +39,14 @@ def get_server_name(
|
|
|
38
39
|
f"{instance_type}s that are running"
|
|
39
40
|
)
|
|
40
41
|
exit(1)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
try:
|
|
43
|
+
name = q.select(
|
|
44
|
+
f"Select the {instance_type} you wish to inspect:",
|
|
45
|
+
choices=running_server_names,
|
|
46
|
+
).unsafe_ask()
|
|
47
|
+
except KeyboardInterrupt:
|
|
48
|
+
error("Aborted by user!")
|
|
49
|
+
exit(1)
|
|
45
50
|
else:
|
|
46
51
|
post_fix = "system" if system_folders else "user"
|
|
47
52
|
name = f"{APPNAME}-{name}-{post_fix}"
|
|
@@ -135,3 +140,36 @@ def print_log_worker(logs_stream: Iterable[bytes]) -> None:
|
|
|
135
140
|
"the container."
|
|
136
141
|
)
|
|
137
142
|
print(log)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def get_name_from_container_name(container_name: str) -> str:
|
|
146
|
+
"""
|
|
147
|
+
Get the node/server/store name from a container name.
|
|
148
|
+
|
|
149
|
+
Parameters
|
|
150
|
+
----------
|
|
151
|
+
container_name : str
|
|
152
|
+
The name of the container
|
|
153
|
+
|
|
154
|
+
Returns
|
|
155
|
+
-------
|
|
156
|
+
str
|
|
157
|
+
The name of the node/server/store
|
|
158
|
+
"""
|
|
159
|
+
# Container name is structured as: f"{APPNAME}-{name}-{post_fix}"
|
|
160
|
+
# Take into account that name can contain '-'
|
|
161
|
+
return "-".join(container_name.split("-")[1:-1])
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def attach_logs(*labels: list[str]) -> None:
|
|
165
|
+
"""
|
|
166
|
+
Attach to the logs of the given labels.
|
|
167
|
+
|
|
168
|
+
Parameters
|
|
169
|
+
----------
|
|
170
|
+
labels : list[str]
|
|
171
|
+
The labels to attach to
|
|
172
|
+
"""
|
|
173
|
+
command = ["devspace", "logs", "--follow", "--label-selector", ",".join(labels)]
|
|
174
|
+
process = Popen(command, stdout=None, stderr=None)
|
|
175
|
+
process.wait()
|