vantage6 4.3.0b5__tar.gz → 4.3.0b6__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 (76) hide show
  1. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/PKG-INFO +4 -2
  2. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/tests_cli/test_node_cli.py +7 -6
  3. vantage6-4.3.0b6/vantage6/cli/__build__ +1 -0
  4. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/common/decorator.py +21 -8
  5. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/common/start.py +1 -1
  6. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/common/utils.py +24 -3
  7. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/context/node.py +9 -2
  8. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/dev/create.py +23 -1
  9. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/attach.py +2 -1
  10. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/common/__init__.py +1 -17
  11. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/start.py +5 -47
  12. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/stop.py +52 -19
  13. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/attach.py +1 -1
  14. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/common/__init__.py +1 -16
  15. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/import_.py +1 -1
  16. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6.egg-info/PKG-INFO +4 -2
  17. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6.egg-info/requires.txt +2 -2
  18. vantage6-4.3.0b5/vantage6/cli/__build__ +0 -1
  19. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/setup.cfg +0 -0
  20. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/setup.py +0 -0
  21. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/tests_cli/__init__.py +0 -0
  22. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/tests_cli/test_example.py +0 -0
  23. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/tests_cli/test_server_cli.py +0 -0
  24. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/tests_cli/test_wizard.py +0 -0
  25. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/__init__.py +0 -0
  26. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/_version.py +0 -0
  27. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/algorithm/create.py +0 -0
  28. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/algorithm/update.py +0 -0
  29. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/algostore/attach.py +0 -0
  30. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/algostore/files.py +0 -0
  31. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/algostore/list.py +0 -0
  32. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/algostore/new.py +0 -0
  33. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/algostore/start.py +0 -0
  34. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/algostore/stop.py +0 -0
  35. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/cli.py +0 -0
  36. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/configuration_manager.py +0 -0
  37. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/configuration_wizard.py +0 -0
  38. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/context/__init__.py +0 -0
  39. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/context/algorithm_store.py +0 -0
  40. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/context/base_server.py +0 -0
  41. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/context/server.py +0 -0
  42. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/dev/remove.py +0 -0
  43. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/dev/start.py +0 -0
  44. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/dev/stop.py +0 -0
  45. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/globals.py +0 -0
  46. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/clean.py +0 -0
  47. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/create_private_key.py +0 -0
  48. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/files.py +0 -0
  49. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/list.py +0 -0
  50. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/new.py +0 -0
  51. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/remove.py +0 -0
  52. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/set_api_key.py +0 -0
  53. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/node/version.py +0 -0
  54. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/rabbitmq/__init__.py +0 -0
  55. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/rabbitmq/definitions.py +0 -0
  56. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/rabbitmq/queue_manager.py +0 -0
  57. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/rabbitmq/rabbitmq.config +0 -0
  58. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/files.py +0 -0
  59. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/list.py +0 -0
  60. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/new.py +0 -0
  61. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/remove.py +0 -0
  62. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/shell.py +0 -0
  63. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/start.py +0 -0
  64. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/stop.py +0 -0
  65. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/server/version.py +0 -0
  66. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/template/node_config.j2 +0 -0
  67. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/template/server_config.j2 +0 -0
  68. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/template/server_import_config.j2 +0 -0
  69. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/test/common/diagnostic_runner.py +0 -0
  70. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/test/feature_tester.py +0 -0
  71. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/test/integration_test.py +0 -0
  72. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6/cli/utils.py +0 -0
  73. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6.egg-info/SOURCES.txt +0 -0
  74. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6.egg-info/dependency_links.txt +0 -0
  75. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6.egg-info/entry_points.txt +0 -0
  76. {vantage6-4.3.0b5 → vantage6-4.3.0b6}/vantage6.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vantage6
3
- Version: 4.3.0b5
3
+ Version: 4.3.0b6
4
4
  Summary: vantage6 command line interface
5
5
  Home-page: https://github.com/vantage6/vantage6
6
6
  Requires-Python: >=3.10
@@ -117,7 +117,9 @@ This repository is home to 6 PyPi packages:
117
117
  * [vantage6-algorithm-tools](https://pypi.org/project/vantage6-algorithm-tools) -> _Python tools to facilitate algorithm development_
118
118
  * [vantage6-node](https://pypi.org/project/vantage6-node) -> _Node application package_
119
119
  * [vantage6-server](https://pypi.org/project/vantage6-server) -> _Server application package_
120
- * [vantage6-common](https://pypi.org/project/vantage6-common) -> _Server application package_
120
+ * [vantage6-algorithm-store](https://pypi.org/project/vantage6-algorithm-store) -> _Algorithm store application package_
121
+ * [vantage6-common](https://pypi.org/project/vantage6-common) -> _Package with common vantage6 functions_
122
+ * [vantage6-backend-common](https://pypi.org/project/vantage6-backend-common) -> _Package with functions common to central server and algorithm store_
121
123
 
122
124
  **Note that when using vantage6 you do not install the _server_ and _node_ packages. These are delivered to you in Docker images.**
123
125
 
@@ -11,6 +11,7 @@ from docker.errors import APIError
11
11
 
12
12
  from vantage6.cli.globals import APPNAME
13
13
  from vantage6.common import STRING_ENCODING
14
+ from vantage6.cli.common.utils import print_log_worker
14
15
  from vantage6.cli.node.list import cli_node_list
15
16
  from vantage6.cli.node.new import cli_node_new_configuration
16
17
  from vantage6.cli.node.files import cli_node_files
@@ -19,7 +20,7 @@ from vantage6.cli.node.stop import cli_node_stop
19
20
  from vantage6.cli.node.attach import cli_node_attach
20
21
  from vantage6.cli.node.create_private_key import cli_node_create_private_key
21
22
  from vantage6.cli.node.clean import cli_node_clean
22
- from vantage6.cli.node.common import create_client_and_authenticate, print_log_worker
23
+ from vantage6.cli.node.common import create_client_and_authenticate
23
24
 
24
25
 
25
26
  class NodeCLITest(unittest.TestCase):
@@ -207,7 +208,7 @@ class NodeCLITest(unittest.TestCase):
207
208
 
208
209
  @patch("docker.DockerClient.volumes")
209
210
  @patch("vantage6.cli.node.start.pull_if_newer")
210
- @patch("vantage6.cli.node.start.NodeContext")
211
+ @patch("vantage6.cli.common.decorator.get_context")
211
212
  @patch("docker.DockerClient.containers")
212
213
  @patch("vantage6.cli.node.start.check_docker_running", return_value=True)
213
214
  def test_start(self, check_docker, client, context, pull, volumes):
@@ -248,7 +249,9 @@ class NodeCLITest(unittest.TestCase):
248
249
 
249
250
  @patch("docker.DockerClient.containers")
250
251
  @patch("vantage6.cli.node.stop.check_docker_running", return_value=True)
251
- def test_stop(self, check_docker, containers):
252
+ @patch("vantage6.cli.node.stop.NodeContext")
253
+ @patch("vantage6.cli.node.stop.delete_volume_if_exists")
254
+ def test_stop(self, delete_volume, node_context, check_docker, containers):
252
255
  container1 = MagicMock()
253
256
  container1.name = f"{APPNAME}-iknl-user"
254
257
  containers.list.return_value = [container1]
@@ -257,9 +260,7 @@ class NodeCLITest(unittest.TestCase):
257
260
 
258
261
  result = runner.invoke(cli_node_stop, ["--name", "iknl"])
259
262
 
260
- self.assertEqual(
261
- result.output, "[info ] - Stopped the vantage6-iknl-user Node.\n"
262
- )
263
+ self.assertEqual(result.output, "[info ] - Stopped the iknl Node.\n")
263
264
 
264
265
  self.assertEqual(result.exit_code, 0)
265
266
 
@@ -0,0 +1 @@
1
+ 6
@@ -1,16 +1,18 @@
1
1
  from functools import wraps
2
+ from pathlib import Path
2
3
  import click
3
4
 
4
5
  from vantage6.common import error
5
6
  from vantage6.common.globals import InstanceType
6
7
  from vantage6.cli.configuration_wizard import select_configuration_questionaire
7
- from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
8
8
  from vantage6.cli.context import select_context_class, get_context
9
9
 
10
10
 
11
- # TODO to make this decorator usable by nodes as well, we should make the
12
- # default for --user/--system configurable
13
- def click_insert_context(type_: InstanceType) -> callable:
11
+ def click_insert_context(
12
+ type_: InstanceType,
13
+ include_name: bool = False,
14
+ include_system_folders: bool = False,
15
+ ) -> callable:
14
16
  """
15
17
  Supply the Click function with an additional context parameter. The context
16
18
  is passed to the function as the first argument.
@@ -19,6 +21,10 @@ def click_insert_context(type_: InstanceType) -> callable:
19
21
  ----------
20
22
  type_ : InstanceType
21
23
  The type of instance for which the context should be inserted
24
+ include_name : bool
25
+ Include the name of the configuration as an argument
26
+ include_system_folders : bool
27
+ Include whether or not to use the system folders as an argument
22
28
 
23
29
  Returns
24
30
  -------
@@ -38,19 +44,19 @@ def click_insert_context(type_: InstanceType) -> callable:
38
44
  "-c",
39
45
  "--config",
40
46
  default=None,
41
- help="Absolute path to " "configuration-file; overrides --name",
47
+ help="Path to configuration-file; overrides --name",
42
48
  )
43
49
  @click.option(
44
50
  "--system",
45
51
  "system_folders",
46
52
  flag_value=True,
47
- help="Use system folders instead of user folders. This " "is the default",
53
+ help="Use system folders instead of user folders. This is the default",
48
54
  )
49
55
  @click.option(
50
56
  "--user",
51
57
  "system_folders",
52
58
  flag_value=False,
53
- default=DEFAULT_SERVER_SYSTEM_FOLDERS,
59
+ default=False if type_ == InstanceType.NODE else True,
54
60
  help="Use user folders instead of system folders",
55
61
  )
56
62
  @wraps(func)
@@ -85,7 +91,14 @@ def click_insert_context(type_: InstanceType) -> callable:
85
91
  exit(1)
86
92
 
87
93
  ctx = get_context(type_, name, system_folders)
88
- return func(ctx, *args, **kwargs)
94
+ extra_args = []
95
+ if include_name:
96
+ if not name:
97
+ name = Path(config).stem
98
+ extra_args.append(name)
99
+ if include_system_folders:
100
+ extra_args.append(system_folders)
101
+ return func(ctx, *extra_args, *args, **kwargs)
89
102
 
90
103
  return decorator
91
104
 
@@ -13,7 +13,7 @@ from vantage6.common.context import AppContext
13
13
  from vantage6.common.globals import InstanceType, APPNAME, DEFAULT_DOCKER_REGISTRY
14
14
  from vantage6.common.docker.addons import check_docker_running, pull_if_newer
15
15
  from vantage6.cli.context import AlgorithmStoreContext, ServerContext
16
- from vantage6.cli.server.common import print_log_worker
16
+ from vantage6.cli.common.utils import print_log_worker
17
17
  from vantage6.cli.utils import check_config_name_allowed
18
18
  from vantage6.cli.globals import ServerGlobals, AlgoStoreGlobals
19
19
 
@@ -1,11 +1,12 @@
1
1
  import questionary as q
2
- import docker
2
+ from colorama import Fore, Style
3
3
  import click
4
+ from typing import Iterable
5
+ import docker
4
6
 
5
- from colorama import Fore, Style
6
7
 
7
8
  from vantage6.common import warning, error
8
- from vantage6.common.globals import APPNAME, InstanceType
9
+ from vantage6.common.globals import APPNAME, InstanceType, STRING_ENCODING
9
10
  from vantage6.cli.context import select_context_class
10
11
 
11
12
 
@@ -114,3 +115,23 @@ def get_server_configuration_list(instance_type: InstanceType.SERVER) -> None:
114
115
  click.echo("-" * 85)
115
116
  if len(f1) + len(f2):
116
117
  warning(f"{Fore.RED}Failed imports: {len(f1)+len(f2)}{Style.RESET_ALL}")
118
+
119
+
120
+ def print_log_worker(logs_stream: Iterable[bytes]) -> None:
121
+ """
122
+ Print the logs from the logs stream.
123
+
124
+ Parameters
125
+ ----------
126
+ logs_stream : Iterable[bytes]
127
+ Output of the container.attach() method
128
+ """
129
+ for log in logs_stream:
130
+ try:
131
+ print(log.decode(STRING_ENCODING), end="")
132
+ except UnicodeDecodeError:
133
+ print(
134
+ "ERROR DECODING LOGS!!! Printing raw bytes. Please check the logs in "
135
+ "the container."
136
+ )
137
+ print(log)
@@ -34,11 +34,18 @@ class NodeContext(AppContext):
34
34
  INST_CONFIG_MANAGER = NodeConfigurationManager
35
35
 
36
36
  def __init__(
37
- self, instance_name: str, system_folders: bool = N_FOL, config_file: str = None
37
+ self,
38
+ instance_name: str,
39
+ system_folders: bool = N_FOL,
40
+ config_file: str = None,
41
+ print_log_header: bool = True,
38
42
  ):
39
43
  super().__init__(InstanceType.NODE, instance_name, system_folders, config_file)
40
44
  self.log.info("vantage6 version '%s'", __version__)
41
45
 
46
+ if print_log_header:
47
+ self.log.info(f"vantage6 version '{__version__}'")
48
+
42
49
  @classmethod
43
50
  def from_external_config_file(
44
51
  cls, path: str, system_folders: bool = N_FOL
@@ -61,7 +68,7 @@ class NodeContext(AppContext):
61
68
  Node context object
62
69
  """
63
70
  return super().from_external_config_file(
64
- path, InstanceType.NODE, system_folders
71
+ Path(path).resolve(), InstanceType.NODE, system_folders
65
72
  )
66
73
 
67
74
  @classmethod
@@ -1,6 +1,6 @@
1
1
  from pathlib import Path
2
2
  import csv
3
-
3
+ import yaml
4
4
  import click
5
5
  from jinja2 import Environment, FileSystemLoader
6
6
  from colorama import Fore, Style
@@ -445,6 +445,28 @@ def create_demo_network(
445
445
  keep=False,
446
446
  wait=True,
447
447
  )
448
+ info(
449
+ "Development network was set up successfully! You can now start the "
450
+ f"server and nodes with {Fore.GREEN}v6 server start-demo-network"
451
+ f"{Style.RESET_ALL}"
452
+ )
453
+ # find user credentials to print. Read from server import file
454
+ with open(server_import_config, "r") as f:
455
+ server_import_config = yaml.safe_load(f)
456
+
457
+ try:
458
+ user = server_import_config["organizations"][0]["users"][0]
459
+ username = user["username"]
460
+ password = user["password"]
461
+ info(
462
+ "You can login with the following credentials:\n"
463
+ f"Username: {username}\n"
464
+ f"Password: {password}\n"
465
+ )
466
+ except KeyError:
467
+ # No user found, skip printing credentials
468
+ pass
469
+
448
470
  return {
449
471
  "node_configs": node_config,
450
472
  "server_import_config": server_import_config,
@@ -10,8 +10,9 @@ from vantage6.common import warning, error, info
10
10
  from vantage6.common.globals import APPNAME
11
11
  from vantage6.common.docker.addons import check_docker_running
12
12
 
13
+ from vantage6.cli.common.utils import print_log_worker
13
14
  from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
14
- from vantage6.cli.node.common import find_running_node_names, print_log_worker
15
+ from vantage6.cli.node.common import find_running_node_names
15
16
 
16
17
 
17
18
  @click.command()
@@ -2,34 +2,18 @@
2
2
  Common functions that are used in node CLI commands
3
3
  """
4
4
 
5
- from typing import Iterable
6
-
7
5
  import questionary as q
8
6
  import docker
9
7
  from colorama import Fore, Style
10
8
 
11
9
  from vantage6.common import error, info, debug
12
- from vantage6.common.globals import STRING_ENCODING, APPNAME, InstanceType
10
+ from vantage6.common.globals import APPNAME, InstanceType
13
11
  from vantage6.client import UserClient
14
12
 
15
13
  from vantage6.cli.context.node import NodeContext
16
14
  from vantage6.cli.configuration_wizard import select_configuration_questionaire
17
15
 
18
16
 
19
- # helper functions
20
- def print_log_worker(logs_stream: Iterable[bytes]) -> None:
21
- """
22
- Print the logs from the logs stream.
23
-
24
- Parameters
25
- ----------
26
- logs_stream : Iterable[bytes]
27
- Output of the container.attach() method
28
- """
29
- for log in logs_stream:
30
- print(log.decode(STRING_ENCODING), end="")
31
-
32
-
33
17
  def create_client(ctx: NodeContext) -> UserClient:
34
18
  """
35
19
  Create a client instance.
@@ -1,11 +1,9 @@
1
- import sys
2
1
  from pathlib import Path
3
2
  from threading import Thread
4
3
  import time
5
4
  import os.path
6
5
 
7
6
  import click
8
- import questionary as q
9
7
  import docker
10
8
 
11
9
  from colorama import Fore, Style
@@ -24,35 +22,15 @@ from vantage6.common.docker.addons import (
24
22
  check_docker_running,
25
23
  )
26
24
 
25
+ from vantage6.cli.common.decorator import click_insert_context
27
26
  from vantage6.cli.context.node import NodeContext
28
- from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
29
- from vantage6.cli.configuration_wizard import (
30
- configuration_wizard,
31
- select_configuration_questionaire,
32
- )
27
+ from vantage6.cli.common.utils import print_log_worker
28
+ from vantage6.cli.node.common import create_client
33
29
  from vantage6.cli.utils import check_config_name_allowed
34
30
  from vantage6.cli import __version__
35
- from vantage6.cli.node.common import print_log_worker, create_client
36
31
 
37
32
 
38
33
  @click.command()
39
- @click.option("-n", "--name", default=None, help="Configuration name")
40
- @click.option(
41
- "-c", "--config", default=None, help="Path to configuration-file; overrides NAME"
42
- )
43
- @click.option(
44
- "--system",
45
- "system_folders",
46
- flag_value=True,
47
- help="Search for the configuration in the system folders",
48
- )
49
- @click.option(
50
- "--user",
51
- "system_folders",
52
- flag_value=False,
53
- default=N_FOL,
54
- help="Search for the configuration in the user folders. This is " "the default",
55
- )
56
34
  @click.option("-i", "--image", default=None, help="Node Docker image to use")
57
35
  @click.option(
58
36
  "--keep/--auto-remove",
@@ -75,9 +53,10 @@ from vantage6.cli.node.common import print_log_worker, create_client
75
53
  help="Override vantage6 source code in container with the source"
76
54
  " code in this path",
77
55
  )
56
+ @click_insert_context(InstanceType.NODE, include_name=True, include_system_folders=True)
78
57
  def cli_node_start(
58
+ ctx: NodeContext,
79
59
  name: str,
80
- config: str,
81
60
  system_folders: bool,
82
61
  image: str,
83
62
  keep: bool,
@@ -93,27 +72,6 @@ def cli_node_start(
93
72
  info("Finding Docker daemon")
94
73
  docker_client = docker.from_env()
95
74
  NodeContext.LOGGING_ENABLED = False
96
- if config:
97
- name = Path(config).stem
98
- ctx = NodeContext(name, system_folders, config)
99
-
100
- else:
101
- # in case no name is supplied, ask the user to select one
102
- if not name:
103
- name = select_configuration_questionaire(InstanceType.NODE, system_folders)
104
-
105
- # check that config exists, if not a questionaire will be invoked
106
- if not NodeContext.config_exists(name, system_folders):
107
- warning(f"Configuration {Fore.RED}{name}{Style.RESET_ALL} does not exist.")
108
-
109
- if q.confirm("Create this configuration now?").ask():
110
- configuration_wizard(InstanceType.NODE, name, system_folders)
111
-
112
- else:
113
- error("Config file couldn't be loaded")
114
- sys.exit(0)
115
-
116
- ctx = NodeContext(name, system_folders)
117
75
 
118
76
  # check if config name is allowed docker name, else exit
119
77
  check_config_name_allowed(ctx.name)
@@ -3,10 +3,16 @@ import questionary as q
3
3
  import docker
4
4
 
5
5
  from colorama import Fore, Style
6
+ from vantage6.cli.context import NodeContext
6
7
 
7
8
  from vantage6.common import warning, error, info
8
9
  from vantage6.common.globals import APPNAME
9
- from vantage6.common.docker.addons import check_docker_running
10
+ from vantage6.common.docker.addons import (
11
+ check_docker_running,
12
+ delete_volume_if_exists,
13
+ get_server_config_name,
14
+ stop_container,
15
+ )
10
16
  from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
11
17
 
12
18
  from vantage6.cli.node.common import find_running_node_names
@@ -58,30 +64,57 @@ def cli_node_stop(
58
64
  )
59
65
 
60
66
  if all_nodes:
61
- for name in running_node_names:
62
- container = client.containers.get(name)
63
- if force:
64
- container.kill()
65
- else:
66
- container.stop()
67
- info(f"Stopped the {Fore.GREEN}{name}{Style.RESET_ALL} Node.")
67
+ for container_name in running_node_names:
68
+ _stop_node(client, container_name, force, system_folders)
68
69
  else:
69
70
  if not name:
70
- name = q.select(
71
+ container_name = q.select(
71
72
  "Select the node you wish to stop:", choices=running_node_names
72
73
  ).ask()
73
74
  else:
74
75
  post_fix = "system" if system_folders else "user"
75
- name = f"{APPNAME}-{name}-{post_fix}"
76
+ container_name = f"{APPNAME}-{name}-{post_fix}"
76
77
 
77
- if name in running_node_names:
78
- container = client.containers.get(name)
79
- # Stop the container. Using stop() gives the container 10s to exit
80
- # itself, if not then it will be killed
81
- if force:
82
- container.kill()
83
- else:
84
- container.stop()
78
+ if container_name in running_node_names:
79
+ _stop_node(client, container_name, force, system_folders)
85
80
  info(f"Stopped the {Fore.GREEN}{name}{Style.RESET_ALL} Node.")
86
81
  else:
87
- error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running?")
82
+ error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running?!")
83
+
84
+
85
+ def _stop_node(
86
+ client: docker.DockerClient, container_name: str, force: bool, system_folders: bool
87
+ ) -> None:
88
+ """
89
+ Stop a node
90
+
91
+ Parameters
92
+ ----------
93
+ client : docker.DockerClient
94
+ Docker client
95
+ name : str
96
+ Name of the node container to stop
97
+ force : bool
98
+ Whether to force the node to stop
99
+ system_folders : bool
100
+ Whether to use system folders or not
101
+ """
102
+ container = client.containers.get(container_name)
103
+ # Stop the container. Using stop() gives the container 10s to exit
104
+ # itself, if not then it will be killed
105
+ stop_container(container, force)
106
+
107
+ # Also delete volumes. This is done here rather than within the node container when
108
+ # it is stopped, because at that point the volumes are still in use. Here, the node
109
+ # has already been stopped
110
+ scope = "system" if system_folders else "user"
111
+ config_name = get_server_config_name(container_name, scope)
112
+ ctx = NodeContext(config_name, system_folders, print_log_header=False)
113
+ docker_client = docker.from_env()
114
+ for volume in [
115
+ ctx.docker_volume_name,
116
+ ctx.docker_squid_volume_name,
117
+ ctx.docker_ssh_volume_name,
118
+ ctx.docker_vpn_volume_name,
119
+ ]:
120
+ delete_volume_if_exists(docker_client, volume)
@@ -12,7 +12,7 @@ from vantage6.common.docker.addons import check_docker_running
12
12
  from vantage6.common.globals import APPNAME, InstanceType
13
13
 
14
14
  from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
15
- from vantage6.cli.server.common import print_log_worker
15
+ from vantage6.cli.common.utils import print_log_worker
16
16
 
17
17
 
18
18
  @click.command()
@@ -1,10 +1,8 @@
1
- from typing import Iterable
2
-
3
1
  from docker.client import DockerClient
4
2
  from colorama import Fore, Style
5
3
 
6
4
  from vantage6.common import error, info
7
- from vantage6.common.globals import STRING_ENCODING, APPNAME
5
+ from vantage6.common.globals import APPNAME
8
6
  from vantage6.common.docker.addons import remove_container, get_container
9
7
  from vantage6.common.context import AppContext
10
8
 
@@ -49,19 +47,6 @@ def get_server_context(
49
47
  return ctx
50
48
 
51
49
 
52
- def print_log_worker(logs_stream: Iterable[bytes]) -> None:
53
- """
54
- Print the logs from the docker container to the terminal.
55
-
56
- Parameters
57
- ----------
58
- logs_stream : Iterable[bytes]
59
- Output of the `container.attach(.)` method
60
- """
61
- for log in logs_stream:
62
- print(log.decode(STRING_ENCODING), end="")
63
-
64
-
65
50
  def stop_ui(client: DockerClient, ctx: ServerContext) -> None:
66
51
  """
67
52
  Check if the UI container is running, and if so, stop and remove it.
@@ -17,7 +17,7 @@ from vantage6.common.globals import (
17
17
  from vantage6.cli.context.server import ServerContext
18
18
  from vantage6.cli.utils import check_config_name_allowed
19
19
  from vantage6.cli.common.decorator import click_insert_context
20
- from vantage6.cli.server.common import print_log_worker
20
+ from vantage6.cli.common.utils import print_log_worker
21
21
 
22
22
 
23
23
  # TODO this method has a lot of duplicated code from `start`
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vantage6
3
- Version: 4.3.0b5
3
+ Version: 4.3.0b6
4
4
  Summary: vantage6 command line interface
5
5
  Home-page: https://github.com/vantage6/vantage6
6
6
  Requires-Python: >=3.10
@@ -117,7 +117,9 @@ This repository is home to 6 PyPi packages:
117
117
  * [vantage6-algorithm-tools](https://pypi.org/project/vantage6-algorithm-tools) -> _Python tools to facilitate algorithm development_
118
118
  * [vantage6-node](https://pypi.org/project/vantage6-node) -> _Node application package_
119
119
  * [vantage6-server](https://pypi.org/project/vantage6-server) -> _Server application package_
120
- * [vantage6-common](https://pypi.org/project/vantage6-common) -> _Server application package_
120
+ * [vantage6-algorithm-store](https://pypi.org/project/vantage6-algorithm-store) -> _Algorithm store application package_
121
+ * [vantage6-common](https://pypi.org/project/vantage6-common) -> _Package with common vantage6 functions_
122
+ * [vantage6-backend-common](https://pypi.org/project/vantage6-backend-common) -> _Package with functions common to central server and algorithm store_
121
123
 
122
124
  **Note that when using vantage6 you do not install the _server_ and _node_ packages. These are delivered to you in Docker images.**
123
125
 
@@ -8,8 +8,8 @@ questionary==1.10.0
8
8
  rich==13.5.2
9
9
  schema==0.7.5
10
10
  SQLAlchemy==1.4.46
11
- vantage6-common==4.3.0b5
12
- vantage6-client==4.3.0b5
11
+ vantage6-common==4.3.0b6
12
+ vantage6-client==4.3.0b6
13
13
 
14
14
  [dev]
15
15
  coverage==6.4.4
@@ -1 +0,0 @@
1
- 5
File without changes
File without changes