vantage6 4.0.2__py3-none-any.whl → 4.1.0b0__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.

Files changed (39) hide show
  1. tests_cli/test_node_cli.py +60 -55
  2. tests_cli/test_server_cli.py +30 -30
  3. vantage6/cli/_version.py +1 -1
  4. vantage6/cli/cli.py +102 -0
  5. vantage6/cli/{dev.py → dev/create.py} +18 -151
  6. vantage6/cli/dev/remove.py +63 -0
  7. vantage6/cli/dev/start.py +52 -0
  8. vantage6/cli/dev/stop.py +30 -0
  9. vantage6/cli/node/attach.py +58 -0
  10. vantage6/cli/node/clean.py +40 -0
  11. vantage6/cli/node/common/__init__.py +124 -0
  12. vantage6/cli/node/create_private_key.py +139 -0
  13. vantage6/cli/node/files.py +34 -0
  14. vantage6/cli/node/list.py +62 -0
  15. vantage6/cli/node/new.py +46 -0
  16. vantage6/cli/node/remove.py +103 -0
  17. vantage6/cli/node/set_api_key.py +45 -0
  18. vantage6/cli/node/start.py +311 -0
  19. vantage6/cli/node/stop.py +73 -0
  20. vantage6/cli/node/version.py +47 -0
  21. vantage6/cli/server/attach.py +54 -0
  22. vantage6/cli/server/common/__init__.py +146 -0
  23. vantage6/cli/server/files.py +16 -0
  24. vantage6/cli/server/import_.py +144 -0
  25. vantage6/cli/server/list.py +60 -0
  26. vantage6/cli/server/new.py +50 -0
  27. vantage6/cli/server/shell.py +42 -0
  28. vantage6/cli/server/start.py +302 -0
  29. vantage6/cli/server/stop.py +158 -0
  30. vantage6/cli/server/version.py +46 -0
  31. {vantage6-4.0.2.dist-info → vantage6-4.1.0b0.dist-info}/METADATA +7 -6
  32. vantage6-4.1.0b0.dist-info/RECORD +52 -0
  33. vantage6-4.1.0b0.dist-info/entry_points.txt +5 -0
  34. vantage6/cli/node.py +0 -1092
  35. vantage6/cli/server.py +0 -1033
  36. vantage6-4.0.2.dist-info/RECORD +0 -28
  37. vantage6-4.0.2.dist-info/entry_points.txt +0 -4
  38. {vantage6-4.0.2.dist-info → vantage6-4.1.0b0.dist-info}/WHEEL +0 -0
  39. {vantage6-4.0.2.dist-info → vantage6-4.1.0b0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,158 @@
1
+ import itertools
2
+
3
+ import click
4
+ import questionary as q
5
+ import docker
6
+ from colorama import (Fore, Style)
7
+ from docker.client import DockerClient
8
+
9
+ from vantage6.common import info, warning, error
10
+ from vantage6.common.docker.addons import (
11
+ check_docker_running, remove_container,
12
+ get_server_config_name, get_container, get_num_nonempty_networks,
13
+ get_network, delete_network, remove_container_if_exists
14
+ )
15
+ from vantage6.common.globals import APPNAME
16
+ from vantage6.cli.rabbitmq import split_rabbitmq_uri
17
+
18
+ from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
19
+ from vantage6.cli.context import ServerContext
20
+ from vantage6.cli.utils import remove_file
21
+ from vantage6.cli.server.common import get_server_context, stop_ui
22
+
23
+
24
+ @click.command()
25
+ @click.option("-n", "--name", default=None, help="Configuration name")
26
+ @click.option('--system', 'system_folders', flag_value=True)
27
+ @click.option('--user', 'system_folders', flag_value=False,
28
+ default=DEFAULT_SERVER_SYSTEM_FOLDERS)
29
+ @click.option('--all', 'all_servers', flag_value=True, help="Stop all servers")
30
+ def cli_server_stop(name: str, system_folders: bool, all_servers: bool):
31
+ """
32
+ Stop one or all running server(s).
33
+ """
34
+ check_docker_running()
35
+ client = docker.from_env()
36
+
37
+ running_servers = client.containers.list(
38
+ filters={"label": f"{APPNAME}-type=server"})
39
+
40
+ if not running_servers:
41
+ warning("No servers are currently running.")
42
+ return
43
+
44
+ running_server_names = [server.name for server in running_servers]
45
+
46
+ if all_servers:
47
+ for container_name in running_server_names:
48
+ _stop_server_containers(client, container_name, system_folders)
49
+ return
50
+
51
+ # make sure we have a configuration name to work with
52
+ if not name:
53
+ container_name = q.select("Select the server you wish to stop:",
54
+ choices=running_server_names).ask()
55
+ else:
56
+ post_fix = "system" if system_folders else "user"
57
+ container_name = f"{APPNAME}-{name}-{post_fix}-server"
58
+
59
+ if container_name not in running_server_names:
60
+ error(f"{Fore.RED}{name}{Style.RESET_ALL} is not running!")
61
+ return
62
+
63
+ _stop_server_containers(client, container_name, system_folders)
64
+
65
+
66
+ def _stop_server_containers(client: DockerClient, container_name: str,
67
+ system_folders: bool) -> None:
68
+ """
69
+ Given a server's name, kill its docker container and related (RabbitMQ)
70
+ containers.
71
+
72
+ Parameters
73
+ ----------
74
+ client : DockerClient
75
+ Docker client
76
+ container_name : str
77
+ Name of the server to stop
78
+ system_folders : bool
79
+ Wether to use system folders or not
80
+ """
81
+ # kill the server
82
+ remove_container_if_exists(client, name=container_name)
83
+ info(f"Stopped the {Fore.GREEN}{container_name}{Style.RESET_ALL} server.")
84
+
85
+ # find the configuration name from the docker container name
86
+ # server name is formatted as f"{APPNAME}-{self.name}-{self.scope}-server"
87
+ scope = "system" if system_folders else "user"
88
+ config_name = get_server_config_name(container_name, scope)
89
+
90
+ ctx = get_server_context(config_name, system_folders)
91
+
92
+ # kill the UI container (if it exists)
93
+ stop_ui(client, ctx)
94
+
95
+ # delete the server network
96
+ network_name = f"{APPNAME}-{ctx.name}-{ctx.scope}-network"
97
+ network = get_network(client, name=network_name)
98
+ delete_network(network, kill_containers=False)
99
+
100
+ # kill RabbitMQ if it exists and no other servers are using to it (i.e. it
101
+ # is not in other docker networks with other containers)
102
+ rabbit_uri = ctx.config.get('rabbitmq', {}).get('uri')
103
+ if rabbit_uri:
104
+ rabbit_container_name = split_rabbitmq_uri(
105
+ rabbit_uri=rabbit_uri)['host']
106
+ rabbit_container = get_container(client, name=rabbit_container_name)
107
+ if rabbit_container and \
108
+ get_num_nonempty_networks(rabbit_container) == 0:
109
+ remove_container(rabbit_container, kill=True)
110
+ info(f"Stopped the {Fore.GREEN}{rabbit_container_name}"
111
+ f"{Style.RESET_ALL} container.")
112
+
113
+
114
+ # TODO this should be refactored into its own module and get a click command
115
+ # attached
116
+ @click.pass_context
117
+ def vserver_remove(
118
+ click_ctx: click.Context, ctx: ServerContext, name: str,
119
+ system_folders: bool, force: bool
120
+ ) -> None:
121
+ """
122
+ Function to remove a server.
123
+
124
+ Parameters
125
+ ----------
126
+ ctx : ServerContext
127
+ Server context object
128
+ name : str
129
+ Name of the server to remove
130
+ system_folders : bool
131
+ Whether to use system folders or not
132
+ force : bool
133
+ Whether to ask for confirmation before removing or not
134
+ """
135
+ check_docker_running()
136
+
137
+ # first stop server
138
+ click_ctx.invoke(
139
+ cli_server_stop, name=name, system_folders=system_folders,
140
+ all_servers=False
141
+ )
142
+
143
+ if not force:
144
+ if not q.confirm(
145
+ "This server will be deleted permanently including its "
146
+ "configuration. Are you sure?", default=False
147
+ ).ask():
148
+ info("Server will not be deleted")
149
+ exit(0)
150
+
151
+ # now remove the folders...
152
+ info(f"Removing configuration file {ctx.config_file}")
153
+ remove_file(ctx.config_file, 'configuration')
154
+
155
+ info(f"Removing log file {ctx.log_file}")
156
+ for handler in itertools.chain(ctx.log.handlers, ctx.log.root.handlers):
157
+ handler.close()
158
+ remove_file(ctx.log_file, 'log')
@@ -0,0 +1,46 @@
1
+ import click
2
+ import questionary as q
3
+ import docker
4
+
5
+ from vantage6.common import error
6
+ from vantage6.common.docker.addons import check_docker_running
7
+ from vantage6.common.globals import APPNAME
8
+ from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
9
+ from vantage6.cli import __version__
10
+
11
+
12
+ @click.command()
13
+ @click.option("-n", "--name", default=None, help="Configuration name")
14
+ @click.option('--system', 'system_folders', flag_value=True)
15
+ @click.option('--user', 'system_folders', flag_value=False,
16
+ default=DEFAULT_SERVER_SYSTEM_FOLDERS)
17
+ def cli_server_version(name: str, system_folders: bool) -> None:
18
+ """
19
+ Print the version of the vantage6 server.
20
+ """
21
+ check_docker_running()
22
+ client = docker.from_env()
23
+
24
+ running_servers = client.containers.list(
25
+ filters={"label": f"{APPNAME}-type=server"})
26
+ running_server_names = [server.name for server in running_servers]
27
+
28
+ if not name:
29
+ if not running_server_names:
30
+ error("No servers are running! You can only check the version for "
31
+ "servers that are running")
32
+ exit(1)
33
+ name = q.select("Select the server you wish to inspect:",
34
+ choices=running_server_names).ask()
35
+ else:
36
+ post_fix = "system" if system_folders else "user"
37
+ name = f"{APPNAME}-{name}-{post_fix}"
38
+
39
+ if name in running_server_names:
40
+ container = client.containers.get(name)
41
+ version = container.exec_run(cmd='vserver-local version',
42
+ stdout=True)
43
+ click.echo({"server": version.output.decode('utf-8'),
44
+ "cli": __version__})
45
+ else:
46
+ error(f"Server {name} is not running! Cannot provide version...")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vantage6
3
- Version: 4.0.2
3
+ Version: 4.1.0b0
4
4
  Summary: vantage6 command line interface
5
5
  Home-page: https://github.com/vantage6/vantage6
6
6
  Requires-Python: >=3.10
@@ -13,8 +13,8 @@ Requires-Dist: jinja2 ==3.1.2
13
13
  Requires-Dist: questionary ==1.10.0
14
14
  Requires-Dist: schema ==0.7.5
15
15
  Requires-Dist: SQLAlchemy ==1.4.46
16
- Requires-Dist: vantage6-common ==4.0.2
17
- Requires-Dist: vantage6-client ==4.0.2
16
+ Requires-Dist: vantage6-common ==4.1.0b0
17
+ Requires-Dist: vantage6-client ==4.1.0b0
18
18
  Provides-Extra: dev
19
19
  Requires-Dist: coverage ==6.4.4 ; extra == 'dev'
20
20
 
@@ -67,10 +67,11 @@ These docker images are used by the _vantage6 CLI_ package, which can be install
67
67
 
68
68
  `pip install vantage6`
69
69
 
70
- This will install the CLI which enables you to use the commands:
70
+ This will install the CLI which enables you to use (among others) the commands
71
+ to manage your nodes and servers:
71
72
 
72
- * `vnode CMD [OPTIONS]`
73
- * `vserver CMD [OPTIONS]`
73
+ * `v6 node CMD [OPTIONS]`
74
+ * `v6 server CMD [OPTIONS]`
74
75
 
75
76
  You can find more (user) documentation at [Gitbook (docs.vantage6.ai)](https://docs.vantage6.ai). If you have any questions, suggestions or just want to chat about federated learning: join our [Dircord (https://discord.gg/yAyFf6Y)](https://discord.gg/yAyFf6Y) channel.
76
77
 
@@ -0,0 +1,52 @@
1
+ tests_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ tests_cli/test_example.py,sha256=TV8JA52UR-Yh1WeVwx8g8ngA9ZTiRCwsJkUKxsXUXMg,147
3
+ tests_cli/test_node_cli.py,sha256=LtnGjHbCJq95eH3vVIeSbVvbX1_DMgP0mVLRqcdP4ss,15454
4
+ tests_cli/test_server_cli.py,sha256=AYI6NQpI76OxIOHvWx87B1E-q3hgc6Dh4efD82LYuOA,6202
5
+ tests_cli/test_wizard.py,sha256=dRrOScN79z8nKGNWmn6tPAVfnDOmCsGckiDJMKufhms,3580
6
+ vantage6/cli/__build__,sha256=X-zrZv_IbzjZUnhsbWlsecLbwjndTpG0ZynXOif7V-k,1
7
+ vantage6/cli/__init__.py,sha256=dEbhLHe9VfU3otY3CQkMVrj39uPGWjqzAvHW2B2Flgs,62
8
+ vantage6/cli/_version.py,sha256=zLeITsnn0rsnz3i-X-GBvMrFwOkMmN6DaNzDlBLS8L4,683
9
+ vantage6/cli/cli.py,sha256=QK2Te28CWBKrI9tLuB9qCOm5Wr4TA8VzWJ6chSF8Phk,3796
10
+ vantage6/cli/configuration_manager.py,sha256=4EHlOW16nfIiplzA0sw9udc4-VLKcmdKgWzzFa5Nw7A,3841
11
+ vantage6/cli/configuration_wizard.py,sha256=c8L4xm9_HYjAkyTmRmLDMwzTDqdKdgnBZy915TAIfRI,11569
12
+ vantage6/cli/context.py,sha256=Q8d-PYq_hBB8chXv1qlI9jYfVVIv2X6BOC-PGmWgptw,13183
13
+ vantage6/cli/globals.py,sha256=5mo7pv45gXhDtG7phSYdK_D9_LPFuBM8bVABgt-J-BY,778
14
+ vantage6/cli/utils.py,sha256=Lx1xYKXDBeHjJpXGkVAhidy79P-zV3TOQYfa2nMbvSs,2353
15
+ vantage6/cli/dev/create.py,sha256=orkcbMcdQg5OQsmi3EuBGzMsuWsG73dx0SqbWW_TeDc,11256
16
+ vantage6/cli/dev/remove.py,sha256=qNqZwAaTIqdjkHIcr1pjTMSqlTDmcaPz87NkSMhT-ws,2362
17
+ vantage6/cli/dev/start.py,sha256=IJbXzezMx4MK7rO9nx3AvidEZfdUL5mX0gA7AlwETLU,1629
18
+ vantage6/cli/dev/stop.py,sha256=XDvjyxxU4gVnC9sKHxYMLYPmDwRq_4lnpXE9imO614Q,993
19
+ vantage6/cli/node/attach.py,sha256=n7mJaDJq7tngMVigXe0_JBAdueV_5YEz8FmVOvAF-PU,2152
20
+ vantage6/cli/node/clean.py,sha256=1C0bTEuc6UO-GBIWUsp9YgO_sK5O5Mg-zZYnsCmd2OE,1088
21
+ vantage6/cli/node/create_private_key.py,sha256=U0kuXmB-POneJzB8rxQ9AHRaqrmp_S54isRkG2a7rhg,4988
22
+ vantage6/cli/node/files.py,sha256=ELpTvGKiPsfSH8kiYrnHfM4Fb8AES8uJF3L2sGQJ27c,1331
23
+ vantage6/cli/node/list.py,sha256=b8ht09bvzVFiQx909r8zeTruCWC2uLyrNVeiipCjgAI,1707
24
+ vantage6/cli/node/new.py,sha256=01sp9005TidvHA_awuaahBHV1-LImspStLTYhruek_A,1858
25
+ vantage6/cli/node/remove.py,sha256=kLMK2Xsfgwrb3FuqRc9cKCadc8p0P3dLTLt9wN1_sBg,3564
26
+ vantage6/cli/node/set_api_key.py,sha256=cJXWe1G5m2LTlyhBX85KFlCcL7voO-YNHUvhnsrwHhE,1796
27
+ vantage6/cli/node/start.py,sha256=qcXjSV_3E4tpVr_gkzptC-fNZyJqRp5mQLsFCTrtPsw,11878
28
+ vantage6/cli/node/stop.py,sha256=08SWafKBpCY_pnMopRkcIcHNaBoxqRHmlDSfQDzWjuQ,2704
29
+ vantage6/cli/node/version.py,sha256=HD0iCf2VGZK8HVYfNcMpDAQdxYQ--5ff10XYCsX7Hf4,1843
30
+ vantage6/cli/node/common/__init__.py,sha256=nUDpIehzfX9Zd3tL2Wa9nP5940SH27gcXGRiCHcxjrA,3166
31
+ vantage6/cli/rabbitmq/__init__.py,sha256=0cuoLZ3V1199PKI-Ew37leZmh77SOAYa8CKMLUUBgBs,737
32
+ vantage6/cli/rabbitmq/definitions.py,sha256=aGFdwxzi7R28uaDS60iW3a-JCkV2F5w_T3oede0kWds,536
33
+ vantage6/cli/rabbitmq/queue_manager.py,sha256=CG2Lx5RCpf2AjzaCvj9vrwrqJOlWbEqf89auX2iuXcU,7613
34
+ vantage6/cli/rabbitmq/rabbitmq.config,sha256=LYAQAEoXaF472XeJDYXc9JfWSETIzPRIR2W-JB2i7fU,136
35
+ vantage6/cli/server/attach.py,sha256=TKibcEhqeMrTX3MQ5OkKlkqBs2pSSsZDh_yiaAoNOpw,1930
36
+ vantage6/cli/server/files.py,sha256=owBO6lj_ucHY00MxJUOOdacz4NbdOqp-vrfkVrGjPUE,481
37
+ vantage6/cli/server/import_.py,sha256=Up3IAK3c9jyFpr7y9_zl4HNViFj6jT9OLh_S6v6t5Hs,4611
38
+ vantage6/cli/server/list.py,sha256=p5SRRGsz6G83Hc53eYoySWi32egm7jie_lo1gkS0NCk,1734
39
+ vantage6/cli/server/new.py,sha256=ZHnjWlEKXOMdu6WYHDcrD62Qc2au-YuYIv2SW2KXS7M,1913
40
+ vantage6/cli/server/shell.py,sha256=SRw-CrD_ro9DRfqCI6IlifJk_UDr6EIke5ypN4-85yo,1384
41
+ vantage6/cli/server/start.py,sha256=ywhKaw-ryJQW2k6byZmr8Dz40CylpKrgToxP85HlNUA,10761
42
+ vantage6/cli/server/stop.py,sha256=Lij7NSiVcgPWyQFB4-p-P2zbkdWOZAk08LKHZhYqxU0,5446
43
+ vantage6/cli/server/version.py,sha256=upvy6VdO3XGfovEW-2Ybc0c0niM2ieCOrz1SlsBrqkw,1743
44
+ vantage6/cli/server/common/__init__.py,sha256=kUcDOfGuNvf8j7g5er9D_7z8IHRk53QBQ2E0NcZ_1iE,4818
45
+ vantage6/cli/template/node_config.j2,sha256=-IyUquZl4jRxb5DRBWvEbZFwz2lFtHG_1reZoSkeees,495
46
+ vantage6/cli/template/server_config.j2,sha256=d6O_K-VzJC3GHbCGVbXRWB4jTEzJHPz1VC7t3U8e0Tc,367
47
+ vantage6/cli/template/server_import_config.j2,sha256=PRB0ym_FYjx9vhkmY9C0xzlv_85Y5kBfWdUYs089bNQ,1844
48
+ vantage6-4.1.0b0.dist-info/METADATA,sha256=cJN7zX4mviFvksp0LkDuxnVS7vMTAs56O09T21niepU,5910
49
+ vantage6-4.1.0b0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
50
+ vantage6-4.1.0b0.dist-info/entry_points.txt,sha256=YFBvwjxoeAGxYyPC-YevEgOBBYRGaXkS6jiOGGCLNy0,157
51
+ vantage6-4.1.0b0.dist-info/top_level.txt,sha256=CYDIBS8jEfFq5YCs_Fuit54K9-3wdosZppTrsymIoUk,19
52
+ vantage6-4.1.0b0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ v6 = vantage6.cli.cli:cli_complete
3
+ vdev = vantage6.cli.cli:cli_dev
4
+ vnode = vantage6.cli.cli:cli_node
5
+ vserver = vantage6.cli.cli:cli_server