vantage6 5.0.0a34__tar.gz → 5.0.0a35__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.

Files changed (95) hide show
  1. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/PKG-INFO +3 -3
  2. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/pyproject.toml +3 -3
  3. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/tests_cli/test_node_cli.py +13 -51
  4. vantage6-5.0.0a35/vantage6/cli/algostore/new.py +120 -0
  5. vantage6-5.0.0a35/vantage6/cli/algostore/remove.py +36 -0
  6. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/algostore/start.py +10 -7
  7. vantage6-5.0.0a35/vantage6/cli/algostore/stop.py +58 -0
  8. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/cli.py +31 -33
  9. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/common/new.py +28 -3
  10. vantage6-5.0.0a35/vantage6/cli/common/remove.py +54 -0
  11. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/common/start.py +30 -1
  12. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/common/stop.py +79 -1
  13. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/common/utils.py +45 -4
  14. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/configuration_manager.py +26 -13
  15. vantage6-5.0.0a35/vantage6/cli/configuration_wizard.py +222 -0
  16. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/context/node.py +10 -17
  17. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/globals.py +20 -0
  18. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/node/attach.py +1 -0
  19. vantage6-5.0.0a35/vantage6/cli/node/files.py +29 -0
  20. vantage6-5.0.0a35/vantage6/cli/node/new.py +380 -0
  21. vantage6-5.0.0a35/vantage6/cli/node/remove.py +37 -0
  22. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/node/restart.py +30 -51
  23. vantage6-5.0.0a35/vantage6/cli/node/start.py +111 -0
  24. vantage6-5.0.0a35/vantage6/cli/node/stop.py +71 -0
  25. vantage6-5.0.0a35/vantage6/cli/server/new.py +109 -0
  26. vantage6-5.0.0a35/vantage6/cli/server/remove.py +31 -0
  27. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/server/start.py +8 -6
  28. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/server/stop.py +10 -39
  29. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/template/algo_store_config.j2 +1 -1
  30. vantage6-5.0.0a35/vantage6/cli/template/node_config.j2 +336 -0
  31. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/utils.py +0 -2
  32. vantage6-5.0.0a34/vantage6/cli/algostore/new.py +0 -39
  33. vantage6-5.0.0a34/vantage6/cli/algostore/remove.py +0 -52
  34. vantage6-5.0.0a34/vantage6/cli/algostore/stop.py +0 -96
  35. vantage6-5.0.0a34/vantage6/cli/configuration_wizard.py +0 -606
  36. vantage6-5.0.0a34/vantage6/cli/node/clean.py +0 -46
  37. vantage6-5.0.0a34/vantage6/cli/node/files.py +0 -42
  38. vantage6-5.0.0a34/vantage6/cli/node/new.py +0 -60
  39. vantage6-5.0.0a34/vantage6/cli/node/remove.py +0 -113
  40. vantage6-5.0.0a34/vantage6/cli/node/start.py +0 -334
  41. vantage6-5.0.0a34/vantage6/cli/node/stop.py +0 -131
  42. vantage6-5.0.0a34/vantage6/cli/server/new.py +0 -41
  43. vantage6-5.0.0a34/vantage6/cli/server/remove.py +0 -52
  44. vantage6-5.0.0a34/vantage6/cli/template/node_config.j2 +0 -33
  45. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/.gitignore +0 -0
  46. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/Makefile +0 -0
  47. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/README.md +0 -0
  48. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/tests_cli/__init__.py +0 -0
  49. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/tests_cli/test_client_script.py +0 -0
  50. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/tests_cli/test_example.py +0 -0
  51. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/tests_cli/test_server_cli.py +0 -0
  52. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/tests_cli/test_wizard.py +0 -0
  53. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/__init__.py +0 -0
  54. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/algorithm/create.py +0 -0
  55. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/algorithm/generate_algorithm_json.py +0 -0
  56. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/algorithm/update.py +0 -0
  57. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/algostore/attach.py +0 -0
  58. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/algostore/files.py +0 -0
  59. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/algostore/list.py +0 -0
  60. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/common/decorator.py +0 -0
  61. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/config.py +0 -0
  62. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/context/__init__.py +0 -0
  63. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/context/algorithm_store.py +0 -0
  64. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/context/base_server.py +0 -0
  65. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/context/server.py +0 -0
  66. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/dev/create.py +0 -0
  67. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/dev/data/km_dataset.csv +0 -0
  68. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/dev/remove.py +0 -0
  69. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/node/common/__init__.py +0 -0
  70. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/node/create_private_key.py +0 -0
  71. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/node/list.py +0 -0
  72. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/node/set_api_key.py +0 -0
  73. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/node/version.py +0 -0
  74. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/prometheus/monitoring_manager.py +0 -0
  75. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/prometheus/prometheus.yml +0 -0
  76. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/rabbitmq/__init__.py +0 -0
  77. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/rabbitmq/definitions.py +0 -0
  78. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/rabbitmq/queue_manager.py +0 -0
  79. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/rabbitmq/rabbitmq.config +0 -0
  80. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/server/attach.py +0 -0
  81. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/server/common/__init__.py +0 -0
  82. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/server/files.py +0 -0
  83. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/server/import_.py +0 -0
  84. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/server/list.py +0 -0
  85. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/server/shell.py +0 -0
  86. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/server/version.py +0 -0
  87. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/template/server_config.j2 +0 -0
  88. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/test/algo_test_scripts/algo_test_arguments.py +0 -0
  89. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/test/algo_test_scripts/algo_test_script.py +0 -0
  90. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/test/client_script.py +0 -0
  91. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/test/common/diagnostic_runner.py +0 -0
  92. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/test/feature_tester.py +0 -0
  93. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/test/integration_test.py +0 -0
  94. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/use/context.py +0 -0
  95. {vantage6-5.0.0a34 → vantage6-5.0.0a35}/vantage6/cli/use/namespace.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vantage6
3
- Version: 5.0.0a34
3
+ Version: 5.0.0a35
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>
@@ -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.0a34
22
- Requires-Dist: vantage6-common==5.0.0a34
21
+ Requires-Dist: vantage6-client==5.0.0a35
22
+ Requires-Dist: vantage6-common==5.0.0a35
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.0a34"
7
+ version = "5.0.0a35"
8
8
  description = "vantage6 command line interface"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -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.0a34",
33
- "vantage6-client==5.0.0a34",
32
+ "vantage6-common==5.0.0a35",
33
+ "vantage6-client==5.0.0a35",
34
34
  ]
35
35
 
36
36
  [project.optional-dependencies]
@@ -1,28 +1,27 @@
1
- import unittest
1
+ import contextlib
2
2
  import logging
3
3
  import os
4
- import contextlib
5
-
6
- from unittest.mock import MagicMock, patch
7
- from pathlib import Path
4
+ import unittest
8
5
  from io import BytesIO, StringIO
6
+ from pathlib import Path
7
+ from unittest.mock import MagicMock, patch
8
+
9
9
  from click.testing import CliRunner
10
- from docker.errors import APIError
11
10
 
12
- from vantage6.common.globals import Ports
13
- from vantage6.cli.globals import APPNAME
14
11
  from vantage6.common import STRING_ENCODING
12
+ from vantage6.common.globals import Ports
13
+
15
14
  from vantage6.cli.common.utils import print_log_worker
15
+ from vantage6.cli.globals import APPNAME
16
+ from vantage6.cli.node.attach import cli_node_attach
17
+ from vantage6.cli.node.common import create_client_and_authenticate
18
+ from vantage6.cli.node.create_private_key import cli_node_create_private_key
19
+ from vantage6.cli.node.files import cli_node_files
16
20
  from vantage6.cli.node.list import cli_node_list
17
21
  from vantage6.cli.node.new import cli_node_new_configuration
18
- from vantage6.cli.node.files import cli_node_files
19
- from vantage6.cli.node.start import cli_node_start
20
22
  from vantage6.cli.node.restart import cli_node_restart
23
+ from vantage6.cli.node.start import cli_node_start
21
24
  from vantage6.cli.node.stop import cli_node_stop
22
- from vantage6.cli.node.attach import cli_node_attach
23
- from vantage6.cli.node.create_private_key import cli_node_create_private_key
24
- from vantage6.cli.node.clean import cli_node_clean
25
- from vantage6.cli.node.common import create_client_and_authenticate
26
25
 
27
26
 
28
27
  class NodeCLITest(unittest.TestCase):
@@ -302,25 +301,6 @@ class NodeCLITest(unittest.TestCase):
302
301
  runner.invoke(cli_node_attach)
303
302
  attach_logs.assert_called_once_with("app=node")
304
303
 
305
- @patch("vantage6.cli.node.clean.q")
306
- @patch("docker.DockerClient.volumes")
307
- @patch("vantage6.cli.node.clean.check_docker_running", return_value=True)
308
- def test_clean(self, check_docker, volumes, q):
309
- """Clean Docker volumes without errors."""
310
- volume1 = MagicMock()
311
- volume1.name = "some-name-tmpvol"
312
- volumes.list.return_value = [volume1]
313
-
314
- question = MagicMock(name="pop-the-question")
315
- question.ask.return_value = True
316
- q.confirm.return_value = question
317
-
318
- runner = CliRunner()
319
- result = runner.invoke(cli_node_clean)
320
-
321
- # check exit code
322
- self.assertEqual(result.exit_code, 0)
323
-
324
304
  @patch("vantage6.cli.node.create_private_key.create_client_and_authenticate")
325
305
  @patch("vantage6.cli.node.common.NodeContext")
326
306
  @patch("vantage6.cli.node.create_private_key.NodeContext")
@@ -387,24 +367,6 @@ class NodeCLITest(unittest.TestCase):
387
367
 
388
368
  self.assertEqual(result.exit_code, 1)
389
369
 
390
- @patch("vantage6.cli.node.clean.q")
391
- @patch("docker.DockerClient.volumes")
392
- @patch("vantage6.common.docker.addons.check_docker_running")
393
- def test_clean_docker_error(self, check_docker, volumes, q):
394
- volume1 = MagicMock()
395
- volume1.name = "some-name-tmpvol"
396
- volume1.remove.side_effect = APIError("Testing")
397
- volumes.list.return_value = [volume1]
398
- question = MagicMock(name="pop-the-question")
399
- question.ask.return_value = True
400
- q.confirm.return_value = question
401
-
402
- runner = CliRunner()
403
- result = runner.invoke(cli_node_clean)
404
-
405
- # check exit code
406
- self.assertEqual(result.exit_code, 1)
407
-
408
370
  def test_print_log_worker(self):
409
371
  stream = BytesIO("Hello!".encode(STRING_ENCODING))
410
372
  temp_stdout = StringIO()
@@ -0,0 +1,120 @@
1
+ import click
2
+ import questionary as q
3
+
4
+ from vantage6.common.globals import (
5
+ DEFAULT_API_PATH,
6
+ InstanceType,
7
+ Ports,
8
+ )
9
+
10
+ from vantage6.cli.common.new import new
11
+ from vantage6.cli.configuration_wizard import add_common_server_config
12
+ from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
13
+
14
+
15
+ @click.command()
16
+ @click.option(
17
+ "-n", "--name", default=None, help="Name of the configuration you want to use."
18
+ )
19
+ @click.option(
20
+ "--system",
21
+ "system_folders",
22
+ flag_value=True,
23
+ help="Use system folders instead of user folders. This is the default",
24
+ )
25
+ @click.option(
26
+ "--user",
27
+ "system_folders",
28
+ flag_value=False,
29
+ default=DEFAULT_SERVER_SYSTEM_FOLDERS,
30
+ help="Use user folders instead of system folders",
31
+ )
32
+ @click.option("--context", default=None, help="Kubernetes context to use")
33
+ @click.option(
34
+ "--namespace",
35
+ default=None,
36
+ help="Kubernetes namespace to use",
37
+ )
38
+ def cli_algo_store_new(
39
+ name: str, system_folders: bool, namespace: str, context: str
40
+ ) -> None:
41
+ """
42
+ Create a new server configuration.
43
+ """
44
+
45
+ new(
46
+ questionnaire_function=algo_store_configuration_questionaire,
47
+ name=name,
48
+ system_folders=system_folders,
49
+ namespace=namespace,
50
+ context=context,
51
+ type_=InstanceType.ALGORITHM_STORE,
52
+ )
53
+
54
+
55
+ def algo_store_configuration_questionaire(instance_name: str) -> dict:
56
+ """
57
+ Questionary to generate a config file for the algorithm store server
58
+ instance.
59
+
60
+ Parameters
61
+ ----------
62
+ instance_name : str
63
+ Name of the server instance.
64
+
65
+ Returns
66
+ -------
67
+ dict
68
+ Dictionary with the new server configuration
69
+ """
70
+ config = {"store": {}, "database": {}}
71
+
72
+ config, is_production = add_common_server_config(
73
+ config, InstanceType.ALGORITHM_STORE, instance_name
74
+ )
75
+ if not is_production:
76
+ config["store"]["dev"] = {
77
+ "host_uri": "host.docker.internal",
78
+ "disable_review": True,
79
+ "review_own_algorithm": True,
80
+ }
81
+
82
+ default_v6_server_uri = f"http://localhost:{Ports.DEV_SERVER}{DEFAULT_API_PATH}"
83
+ default_root_username = "admin"
84
+
85
+ v6_server_uri = q.text(
86
+ "What is the Vantage6 server linked to the algorithm store? "
87
+ "Provide the link to the server endpoint.",
88
+ default=default_v6_server_uri,
89
+ ).unsafe_ask()
90
+
91
+ root_username = q.text(
92
+ "What is the username of the root user?",
93
+ default=default_root_username,
94
+ ).unsafe_ask()
95
+
96
+ config["root_user"] = {
97
+ "v6_server_uri": v6_server_uri,
98
+ "username": root_username,
99
+ }
100
+
101
+ # ask about openness of the algorithm store
102
+ config["policies"] = {}
103
+ is_open = q.confirm(
104
+ "Do you want to open the algorithm store to the public? This will allow anyone "
105
+ "to view the algorithms, but they cannot modify them.",
106
+ default=False,
107
+ ).unsafe_ask()
108
+ if is_open:
109
+ open_algos_policy = "public"
110
+ else:
111
+ is_open_to_whitelist = q.confirm(
112
+ "Do you want to allow all authenticated users to access "
113
+ "the algorithms in the store? If not allowing this, you will have to assign"
114
+ " the appropriate permissions to each user individually.",
115
+ default=True,
116
+ ).unsafe_ask()
117
+ open_algos_policy = "authenticated" if is_open_to_whitelist else "private"
118
+ config["policies"]["algorithm_view"] = open_algos_policy
119
+
120
+ return config
@@ -0,0 +1,36 @@
1
+ import click
2
+
3
+ from vantage6.common.globals import InstanceType
4
+
5
+ from vantage6.cli.common.decorator import click_insert_context
6
+ from vantage6.cli.common.remove import execute_remove
7
+ from vantage6.cli.context import AlgorithmStoreContext
8
+ from vantage6.cli.globals import InfraComponentName
9
+
10
+
11
+ @click.command()
12
+ @click_insert_context(
13
+ type_=InstanceType.ALGORITHM_STORE, include_name=True, include_system_folders=True
14
+ )
15
+ @click.option("-f", "--force", "force", flag_value=True)
16
+ def cli_algo_store_remove(
17
+ ctx: AlgorithmStoreContext, name: str, system_folders: bool, force: bool
18
+ ) -> None:
19
+ """
20
+ Function to remove an algorithm store.
21
+
22
+ Parameters
23
+ ----------
24
+ ctx : AlgorithmStoreContext
25
+ Algorithm store context object
26
+ force : bool
27
+ Whether to ask for confirmation before removing or not
28
+ """
29
+ execute_remove(
30
+ ctx,
31
+ InstanceType.ALGORITHM_STORE,
32
+ InfraComponentName.ALGORITHM_STORE,
33
+ name,
34
+ system_folders,
35
+ force,
36
+ )
@@ -9,12 +9,12 @@ from vantage6.common.globals import (
9
9
  from vantage6.cli.common.decorator import click_insert_context
10
10
  from vantage6.cli.common.start import (
11
11
  helm_install,
12
+ prestart_checks,
12
13
  start_port_forward,
13
14
  )
14
15
  from vantage6.cli.common.utils import (
15
16
  attach_logs,
16
17
  create_directory_if_not_exists,
17
- select_context_and_namespace,
18
18
  )
19
19
  from vantage6.cli.context.algorithm_store import AlgorithmStoreContext
20
20
  from vantage6.cli.globals import ChartName
@@ -30,9 +30,13 @@ from vantage6.cli.globals import ChartName
30
30
  default=False,
31
31
  help="Print server logs to the console after start",
32
32
  )
33
- @click_insert_context(InstanceType.ALGORITHM_STORE)
33
+ @click_insert_context(
34
+ InstanceType.ALGORITHM_STORE, include_name=True, include_system_folders=True
35
+ )
34
36
  def cli_algo_store_start(
35
37
  ctx: AlgorithmStoreContext,
38
+ name: str,
39
+ system_folders: bool,
36
40
  context: str,
37
41
  namespace: str,
38
42
  ip: str,
@@ -43,9 +47,9 @@ def cli_algo_store_start(
43
47
  Start the algorithm store.
44
48
  """
45
49
  info("Starting algorithm store...")
46
- context, namespace = select_context_and_namespace(
47
- context=context,
48
- namespace=namespace,
50
+
51
+ prestart_checks(
52
+ ctx, InstanceType.ALGORITHM_STORE, name, system_folders, context, namespace
49
53
  )
50
54
 
51
55
  create_directory_if_not_exists(ctx.log_dir)
@@ -58,10 +62,9 @@ def cli_algo_store_start(
58
62
  namespace=namespace,
59
63
  )
60
64
 
61
- # port forward for server
62
65
  info("Port forwarding for algorithm store")
63
66
  start_port_forward(
64
- service_name=f"{ctx.helm_release_name}-vantage6-algorithm-store-service",
67
+ service_name=f"{ctx.helm_release_name}-store-service",
65
68
  service_port=ctx.config["store"].get("port", Ports.DEV_ALGO_STORE.value),
66
69
  port=port or ctx.config["store"].get("port", Ports.DEV_ALGO_STORE.value),
67
70
  ip=ip,
@@ -0,0 +1,58 @@
1
+ import click
2
+
3
+ from vantage6.common import info
4
+ from vantage6.common.globals import InstanceType
5
+
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
8
+
9
+
10
+ @click.command()
11
+ @click.option("-n", "--name", default=None, help="Configuration name")
12
+ @click.option("--context", default=None, help="Kubernetes context to use")
13
+ @click.option("--namespace", default=None, help="Kubernetes namespace to use")
14
+ @click.option(
15
+ "--system",
16
+ "system_folders",
17
+ flag_value=True,
18
+ default=DEFAULT_SERVER_SYSTEM_FOLDERS,
19
+ help="Search for configuration in system folders instead of user folders. "
20
+ "This is the default.",
21
+ )
22
+ @click.option(
23
+ "--user",
24
+ "system_folders",
25
+ flag_value=False,
26
+ help="Search for configuration in the user folders instead of system folders.",
27
+ )
28
+ @click.option("--all", "all_stores", flag_value=True, help="Stop all algorithm stores")
29
+ def cli_algo_store_stop(
30
+ name: str,
31
+ context: str,
32
+ namespace: str,
33
+ system_folders: bool,
34
+ all_stores: bool,
35
+ ):
36
+ """
37
+ Stop one or all running algorithm store(s).
38
+ """
39
+ execute_stop(
40
+ stop_function=_stop_store,
41
+ instance_type=InstanceType.ALGORITHM_STORE,
42
+ infra_component=InfraComponentName.ALGORITHM_STORE,
43
+ stop_all=all_stores,
44
+ to_stop=name,
45
+ namespace=namespace,
46
+ context=context,
47
+ system_folders=system_folders,
48
+ )
49
+
50
+
51
+ def _stop_store(store_name: str, namespace: str, context: str) -> None:
52
+ info(f"Stopping store {store_name}...")
53
+
54
+ helm_uninstall(release_name=store_name, context=context, namespace=namespace)
55
+
56
+ stop_port_forward(service_name=f"{store_name}-store-service")
57
+
58
+ info(f"Store {store_name} stopped successfully.")
@@ -1,17 +1,19 @@
1
1
  import click
2
2
 
3
- from vantage6.cli.server.attach import cli_server_attach
4
- from vantage6.cli.server.files import cli_server_files
5
- from vantage6.cli.server.import_ import cli_server_import
6
- from vantage6.cli.server.list import cli_server_configuration_list
7
- from vantage6.cli.server.new import cli_server_new
8
- from vantage6.cli.server.remove import cli_server_remove
9
- from vantage6.cli.server.shell import cli_server_shell
10
- from vantage6.cli.server.start import cli_server_start
11
- from vantage6.cli.server.stop import cli_server_stop
12
- from vantage6.cli.server.version import cli_server_version
3
+ from vantage6.cli.algorithm.create import cli_algorithm_create
4
+ from vantage6.cli.algorithm.generate_algorithm_json import (
5
+ cli_algorithm_generate_algorithm_json,
6
+ )
7
+ from vantage6.cli.algorithm.update import cli_algorithm_update
8
+ from vantage6.cli.algostore.attach import cli_algo_store_attach
9
+ from vantage6.cli.algostore.files import cli_algo_store_files
10
+ from vantage6.cli.algostore.list import cli_algo_store_configuration_list
11
+ from vantage6.cli.algostore.new import cli_algo_store_new
12
+ from vantage6.cli.algostore.remove import cli_algo_store_remove
13
+ from vantage6.cli.algostore.start import cli_algo_store_start
14
+ from vantage6.cli.algostore.stop import cli_algo_store_stop
15
+ from vantage6.cli.globals import CLICommandName
13
16
  from vantage6.cli.node.attach import cli_node_attach
14
- from vantage6.cli.node.clean import cli_node_clean
15
17
  from vantage6.cli.node.create_private_key import cli_node_create_private_key
16
18
  from vantage6.cli.node.files import cli_node_files
17
19
  from vantage6.cli.node.list import cli_node_list
@@ -22,29 +24,26 @@ from vantage6.cli.node.set_api_key import cli_node_set_api_key
22
24
  from vantage6.cli.node.start import cli_node_start
23
25
  from vantage6.cli.node.stop import cli_node_stop
24
26
  from vantage6.cli.node.version import cli_node_version
25
- from vantage6.cli.algorithm.create import cli_algorithm_create
26
- from vantage6.cli.algorithm.update import cli_algorithm_update
27
- from vantage6.cli.algorithm.generate_algorithm_json import (
28
- cli_algorithm_generate_algorithm_json,
29
- )
27
+ from vantage6.cli.server.attach import cli_server_attach
28
+ from vantage6.cli.server.files import cli_server_files
29
+ from vantage6.cli.server.import_ import cli_server_import
30
+ from vantage6.cli.server.list import cli_server_configuration_list
31
+ from vantage6.cli.server.new import cli_server_new
32
+ from vantage6.cli.server.remove import cli_server_remove
33
+ from vantage6.cli.server.shell import cli_server_shell
34
+ from vantage6.cli.server.start import cli_server_start
35
+ from vantage6.cli.server.stop import cli_server_stop
36
+ from vantage6.cli.server.version import cli_server_version
30
37
 
31
38
  # from vantage6.cli.test.client_script import cli_test_client_script
32
- from vantage6.cli.test.feature_tester import cli_test_features
33
-
34
39
  # from vantage6.cli.test.integration_test import cli_test_integration
35
- from vantage6.cli.algostore.attach import cli_algo_store_attach
36
- from vantage6.cli.algostore.new import cli_algo_store_new
37
- from vantage6.cli.algostore.start import cli_algo_store_start
38
- from vantage6.cli.algostore.stop import cli_algo_store_stop
39
- from vantage6.cli.algostore.files import cli_algo_store_files
40
- from vantage6.cli.algostore.list import cli_algo_store_configuration_list
41
- from vantage6.cli.algostore.remove import cli_algo_store_remove
40
+ from vantage6.cli.test.feature_tester import cli_test_features
42
41
  from vantage6.cli.use.context import cli_use_context
43
42
  from vantage6.cli.use.namespace import cli_use_namespace
44
43
 
45
44
 
46
45
  # Define the server group
47
- @click.group(name="server")
46
+ @click.group(name=CLICommandName.SERVER.value)
48
47
  def cli_server() -> None:
49
48
  """
50
49
  Manage your vantage6 server instances.
@@ -65,7 +64,7 @@ cli_server.add_command(cli_server_version, name="version")
65
64
 
66
65
 
67
66
  # Define the node group
68
- @click.group(name="node")
67
+ @click.group(name=CLICommandName.NODE.value)
69
68
  def cli_node() -> None:
70
69
  """
71
70
  Manage your vantage6 node instances.
@@ -74,7 +73,6 @@ def cli_node() -> None:
74
73
 
75
74
  # Define the commands for the node group
76
75
  cli_node.add_command(cli_node_attach, name="attach")
77
- cli_node.add_command(cli_node_clean, name="clean")
78
76
  cli_node.add_command(cli_node_create_private_key, name="create-private-key")
79
77
  cli_node.add_command(cli_node_files, name="files")
80
78
  cli_node.add_command(cli_node_list, name="list")
@@ -88,7 +86,7 @@ cli_node.add_command(cli_node_version, name="version")
88
86
 
89
87
 
90
88
  # Define the dev group
91
- @click.group(name="dev")
89
+ @click.group(name=CLICommandName.DEV.value)
92
90
  def cli_dev() -> None:
93
91
  """
94
92
  Quickly manage a test network with a server and several nodes.
@@ -101,7 +99,7 @@ def cli_dev() -> None:
101
99
 
102
100
 
103
101
  # Define the algorithm group
104
- @click.group(name="algorithm")
102
+ @click.group(name=CLICommandName.ALGORITHM.value)
105
103
  def cli_algorithm() -> None:
106
104
  """
107
105
  Manage your vantage6 algorithms.
@@ -117,7 +115,7 @@ cli_algorithm.add_command(
117
115
 
118
116
 
119
117
  # Define the test group
120
- @click.group(name="test")
118
+ @click.group(name=CLICommandName.TEST.value)
121
119
  def cli_test() -> None:
122
120
  """
123
121
  Execute tests on your vantage6 infrastructure.
@@ -131,7 +129,7 @@ cli_test.add_command(cli_test_features, name="feature-test")
131
129
 
132
130
 
133
131
  # Define the algorithm-store group
134
- @click.group(name="algorithm-store")
132
+ @click.group(name=CLICommandName.ALGORITHM_STORE.value)
135
133
  def cli_algo_store() -> None:
136
134
  """
137
135
  Manage your vantage6 algorithm store server instances.
@@ -149,7 +147,7 @@ cli_algo_store.add_command(cli_algo_store_remove, name="remove")
149
147
 
150
148
 
151
149
  # Add the use group
152
- @click.group(name="use")
150
+ @click.group(name=CLICommandName.USE.value)
153
151
  def cli_use() -> None:
154
152
  """
155
153
  Manage Kubernetes context and namespace.
@@ -11,8 +11,31 @@ from vantage6.cli.utils import check_config_name_allowed, prompt_config_name
11
11
 
12
12
 
13
13
  def new(
14
- name: str, system_folders: bool, namespace: str, context: str, type_: InstanceType
15
- ):
14
+ questionnaire_function: callable,
15
+ name: str,
16
+ system_folders: bool,
17
+ namespace: str,
18
+ context: str,
19
+ type_: InstanceType,
20
+ ) -> None:
21
+ """
22
+ Create a new configuration.
23
+
24
+ Parameters
25
+ ----------
26
+ questionnaire_function : callable
27
+ Function to generate the configuration
28
+ name : str
29
+ Name of the configuration
30
+ system_folders : bool
31
+ Whether to store the configuration in the system folders
32
+ namespace : str
33
+ Namespace to use
34
+ context : str
35
+ Context to use
36
+ type_ : InstanceType
37
+ Type of the configuration (node, server, algorithm store, etc)
38
+ """
16
39
  cli_config = CliConfig()
17
40
  context, namespace = cli_config.compare_changes_config(
18
41
  context=context,
@@ -47,7 +70,9 @@ def new(
47
70
 
48
71
  # create config in ctx location
49
72
  try:
50
- cfg_file = configuration_wizard(type_, name, system_folders)
73
+ cfg_file = configuration_wizard(
74
+ questionnaire_function, type_, name, system_folders
75
+ )
51
76
  except KeyboardInterrupt:
52
77
  error("Configuration creation aborted.")
53
78
  exit(1)
@@ -0,0 +1,54 @@
1
+ import itertools
2
+ from pathlib import Path
3
+ from shutil import rmtree
4
+
5
+ import questionary as q
6
+
7
+ from vantage6.common import (
8
+ error,
9
+ info,
10
+ )
11
+ from vantage6.common.context import AppContext
12
+ from vantage6.common.globals import InstanceType
13
+
14
+ from vantage6.cli.common.utils import check_running
15
+ from vantage6.cli.globals import InfraComponentName
16
+ from vantage6.cli.utils import remove_file
17
+
18
+
19
+ def execute_remove(
20
+ ctx: AppContext,
21
+ instance_type: InstanceType,
22
+ infra_component: InfraComponentName,
23
+ name: str,
24
+ system_folders: bool,
25
+ force: bool,
26
+ ) -> None:
27
+ if check_running(ctx.helm_release_name, instance_type, name, system_folders):
28
+ error(
29
+ f"The {infra_component.value} {name} is still running! Please stop the "
30
+ f"{infra_component.value} before deleting it."
31
+ )
32
+ exit(1)
33
+
34
+ if not force:
35
+ if not q.confirm(
36
+ f"This {infra_component.value} will be deleted permanently including its "
37
+ "configuration. Are you sure?",
38
+ default=False,
39
+ ).ask():
40
+ info(f"The {infra_component.value} {name} will not be deleted")
41
+ exit(0)
42
+
43
+ # remove the config file
44
+ remove_file(ctx.config_file, "configuration")
45
+
46
+ # ensure log files are closed before removing
47
+ log_dir = Path(ctx.log_file.parent)
48
+ if log_dir.exists():
49
+ info(f"Removing log directory: {log_dir}")
50
+ for handler in itertools.chain(ctx.log.handlers, ctx.log.root.handlers):
51
+ handler.close()
52
+ # remove the whole folder with all the log files. This may also still contain
53
+ # other files like (for the server) RabbitMQ configuration etc
54
+ rmtree(log_dir)
@@ -10,6 +10,7 @@ import docker
10
10
  from docker.client import DockerClient
11
11
 
12
12
  from vantage6.common import error, info, warning
13
+ from vantage6.common.context import AppContext
13
14
  from vantage6.common.docker.addons import pull_image
14
15
  from vantage6.common.globals import (
15
16
  DEFAULT_ALGO_STORE_IMAGE,
@@ -21,8 +22,36 @@ from vantage6.common.globals import (
21
22
  InstanceType,
22
23
  )
23
24
 
25
+ from vantage6.cli.common.utils import (
26
+ check_running,
27
+ select_context_and_namespace,
28
+ )
24
29
  from vantage6.cli.globals import ChartName
25
- from vantage6.cli.utils import validate_input_cmd_args
30
+ from vantage6.cli.utils import check_config_name_allowed, validate_input_cmd_args
31
+
32
+
33
+ def prestart_checks(
34
+ ctx: AppContext,
35
+ instance_type: InstanceType,
36
+ name: str,
37
+ system_folders: bool,
38
+ context: str,
39
+ namespace: str,
40
+ ) -> None:
41
+ """
42
+ Run pre-start checks for an instance.
43
+ """
44
+
45
+ check_config_name_allowed(ctx.name)
46
+
47
+ if check_running(ctx.helm_release_name, instance_type, name, system_folders):
48
+ error(f"Instance '{name}' is already running.")
49
+ exit(1)
50
+
51
+ context, namespace = select_context_and_namespace(
52
+ context=context,
53
+ namespace=namespace,
54
+ )
26
55
 
27
56
 
28
57
  def pull_infra_image(