vantage6 4.2.2__py3-none-any.whl → 4.3.0b3__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 (49) hide show
  1. tests_cli/test_node_cli.py +1 -1
  2. tests_cli/test_server_cli.py +5 -5
  3. tests_cli/test_wizard.py +8 -9
  4. vantage6/cli/__build__ +1 -1
  5. vantage6/cli/_version.py +1 -1
  6. vantage6/cli/algostore/attach.py +32 -0
  7. vantage6/cli/algostore/new.py +55 -0
  8. vantage6/cli/algostore/start.py +102 -0
  9. vantage6/cli/algostore/stop.py +60 -0
  10. vantage6/cli/cli.py +20 -0
  11. vantage6/cli/common/decorator.py +92 -0
  12. vantage6/cli/common/start.py +232 -0
  13. vantage6/cli/configuration_manager.py +13 -23
  14. vantage6/cli/configuration_wizard.py +134 -60
  15. vantage6/cli/context/__init__.py +86 -0
  16. vantage6/cli/context/algorithm_store.py +130 -0
  17. vantage6/cli/context/base_server.py +89 -0
  18. vantage6/cli/{context.py → context/node.py} +12 -174
  19. vantage6/cli/context/server.py +127 -0
  20. vantage6/cli/dev/create.py +4 -3
  21. vantage6/cli/dev/remove.py +5 -3
  22. vantage6/cli/dev/start.py +2 -1
  23. vantage6/cli/dev/stop.py +2 -1
  24. vantage6/cli/globals.py +24 -0
  25. vantage6/cli/node/common/__init__.py +10 -4
  26. vantage6/cli/node/create_private_key.py +1 -1
  27. vantage6/cli/node/files.py +1 -1
  28. vantage6/cli/node/list.py +1 -1
  29. vantage6/cli/node/new.py +3 -2
  30. vantage6/cli/node/remove.py +1 -1
  31. vantage6/cli/node/set_api_key.py +1 -1
  32. vantage6/cli/node/start.py +7 -6
  33. vantage6/cli/rabbitmq/queue_manager.py +1 -1
  34. vantage6/cli/server/attach.py +3 -3
  35. vantage6/cli/server/common/__init__.py +5 -3
  36. vantage6/cli/server/files.py +1 -1
  37. vantage6/cli/server/import_.py +7 -3
  38. vantage6/cli/server/list.py +9 -5
  39. vantage6/cli/server/new.py +3 -2
  40. vantage6/cli/server/shell.py +3 -3
  41. vantage6/cli/server/start.py +26 -110
  42. vantage6/cli/server/stop.py +3 -4
  43. vantage6/cli/server/version.py +2 -2
  44. {vantage6-4.2.2.dist-info → vantage6-4.3.0b3.dist-info}/METADATA +3 -3
  45. vantage6-4.3.0b3.dist-info/RECORD +68 -0
  46. vantage6-4.2.2.dist-info/RECORD +0 -58
  47. {vantage6-4.2.2.dist-info → vantage6-4.3.0b3.dist-info}/WHEEL +0 -0
  48. {vantage6-4.2.2.dist-info → vantage6-4.3.0b3.dist-info}/entry_points.txt +0 -0
  49. {vantage6-4.2.2.dist-info → vantage6-4.3.0b3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,130 @@
1
+ from __future__ import annotations
2
+
3
+ from vantage6.common.globals import APPNAME, InstanceType
4
+ from vantage6.cli.configuration_manager import ServerConfigurationManager
5
+ from vantage6.cli.globals import (
6
+ DEFAULT_SERVER_SYSTEM_FOLDERS as S_FOL,
7
+ ServerType,
8
+ AlgoStoreGlobals,
9
+ )
10
+ from vantage6.cli._version import __version__
11
+ from vantage6.cli.context.base_server import BaseServerContext
12
+
13
+
14
+ class AlgorithmStoreContext(BaseServerContext):
15
+ """
16
+ A context class for the algorithm store server.
17
+
18
+ Parameters
19
+ ----------
20
+ instance_name : str
21
+ Name of the configuration instance, corresponds to the filename
22
+ of the configuration file.
23
+ system_folders : bool, optional
24
+ System wide or user configuration, by default S_FOL
25
+ """
26
+
27
+ INST_CONFIG_MANAGER = ServerConfigurationManager
28
+
29
+ def __init__(self, instance_name: str, system_folders: bool = S_FOL):
30
+ super().__init__(
31
+ InstanceType.ALGORITHM_STORE, instance_name, system_folders=system_folders
32
+ )
33
+ self.log.info("vantage6 version '%s'", __version__)
34
+
35
+ def get_database_uri(self) -> str:
36
+ """
37
+ Obtain the database uri from the environment or the configuration. The
38
+ `VANTAGE6_DB_URI` environment variable is used by the Docker container,
39
+ but can also be set by the user.
40
+
41
+ Returns
42
+ -------
43
+ str
44
+ string representation of the database uri
45
+ """
46
+ return super().get_database_uri(AlgoStoreGlobals.DB_URI_ENV_VAR)
47
+
48
+ @property
49
+ def docker_container_name(self) -> str:
50
+ """
51
+ Name of the docker container that the server is running in.
52
+
53
+ Returns
54
+ -------
55
+ str
56
+ Server's docker container name
57
+ """
58
+ return f"{APPNAME}-{self.name}-{self.scope}-{ServerType.ALGORITHM_STORE}"
59
+
60
+ @classmethod
61
+ def from_external_config_file(
62
+ cls, path: str, system_folders: bool = S_FOL
63
+ ) -> AlgorithmStoreContext:
64
+ """
65
+ Create a server context from an external configuration file. External
66
+ means that the configuration file is not located in the default folders
67
+ but its location is specified by the user.
68
+
69
+ Parameters
70
+ ----------
71
+ path : str
72
+ Path of the configuration file
73
+ system_folders : bool, optional
74
+ System wide or user configuration, by default S_FOL
75
+
76
+ Returns
77
+ -------
78
+ AlgorithmStoreContext
79
+ Server context object
80
+ """
81
+ return super().from_external_config_file(
82
+ path,
83
+ ServerType.ALGORITHM_STORE,
84
+ AlgoStoreGlobals.CONFIG_NAME_ENV_VAR,
85
+ system_folders,
86
+ )
87
+
88
+ @classmethod
89
+ def config_exists(cls, instance_name: str, system_folders: bool = S_FOL) -> bool:
90
+ """
91
+ Check if a configuration file exists.
92
+
93
+ Parameters
94
+ ----------
95
+ instance_name : str
96
+ Name of the configuration instance, corresponds to the filename
97
+ of the configuration file.
98
+ system_folders : bool, optional
99
+ System wide or user configuration, by default S_FOL
100
+
101
+ Returns
102
+ -------
103
+ bool
104
+ Whether the configuration file exists or not
105
+ """
106
+ return super().config_exists(
107
+ InstanceType.ALGORITHM_STORE, instance_name, system_folders
108
+ )
109
+
110
+ @classmethod
111
+ def available_configurations(
112
+ cls, system_folders: bool = S_FOL
113
+ ) -> tuple[list, list]:
114
+ """
115
+ Find all available server configurations in the default folders.
116
+
117
+ Parameters
118
+ ----------
119
+ system_folders : bool, optional
120
+ System wide or user configuration, by default S_FOL
121
+
122
+ Returns
123
+ -------
124
+ tuple[list, list]
125
+ The first list contains validated configuration files, the second
126
+ list contains invalid configuration files.
127
+ """
128
+ return super().available_configurations(
129
+ InstanceType.ALGORITHM_STORE, system_folders
130
+ )
@@ -0,0 +1,89 @@
1
+ from __future__ import annotations
2
+
3
+ import os.path
4
+
5
+ from sqlalchemy.engine.url import make_url
6
+
7
+ from vantage6.common.context import AppContext
8
+ from vantage6.cli.globals import (
9
+ DEFAULT_SERVER_SYSTEM_FOLDERS as S_FOL,
10
+ ServerType,
11
+ )
12
+
13
+
14
+ class BaseServerContext(AppContext):
15
+ """
16
+ Base context for a vantage6 server or algorithm store server
17
+
18
+ Contains functions that the ServerContext and AlgorithmStoreContext have
19
+ in common.
20
+ """
21
+
22
+ def get_database_uri(self, db_env_var: str) -> str:
23
+ """
24
+ Obtain the database uri from the environment or the configuration.
25
+
26
+ Parameters
27
+ ----------
28
+ db_env_var : str
29
+ Name of the environment variable that contains the database uri
30
+
31
+ Returns
32
+ -------
33
+ str
34
+ string representation of the database uri
35
+ """
36
+ uri = os.environ.get(db_env_var) or self.config["uri"]
37
+ url = make_url(uri)
38
+
39
+ if url.host is None and not os.path.isabs(url.database):
40
+ # We're dealing with a relative path here of a local database, when
41
+ # we're running the server outside of docker. Therefore we need to
42
+ # prepend the data directory to the database name, but after the
43
+ # driver name (e.g. sqlite:////db.sqlite ->
44
+ # sqlite:////data_dir>/db.sqlite)
45
+
46
+ # find index of database name
47
+ idx_db_name = str(url).find(url.database)
48
+
49
+ # add the datadir to the right location in the database uri
50
+ return str(url)[:idx_db_name] + str(self.data_dir / url.database)
51
+
52
+ return uri
53
+
54
+ @classmethod
55
+ def from_external_config_file(
56
+ cls,
57
+ path: str,
58
+ server_type: ServerType,
59
+ config_name_env_var: str,
60
+ system_folders: bool = S_FOL,
61
+ ) -> BaseServerContext:
62
+ """
63
+ Create a server context from an external configuration file. External
64
+ means that the configuration file is not located in the default folders
65
+ but its location is specified by the user.
66
+
67
+ Parameters
68
+ ----------
69
+ path : str
70
+ Path of the configuration file
71
+ server_type : ServerType
72
+ Type of server, either 'server' or 'algorithm-store'
73
+ config_name_env_var : str
74
+ Name of the environment variable that contains the name of the
75
+ configuration
76
+ system_folders : bool, optional
77
+ System wide or user configuration, by default S_FOL
78
+
79
+ Returns
80
+ -------
81
+ ServerContext
82
+ Server context object
83
+ """
84
+ cls = super().from_external_config_file(path, server_type, system_folders)
85
+ # if we are running a server in a docker container, the name is taken
86
+ # from the name of the config file (which is usually a default). Get
87
+ # the config name from environment if it is given.
88
+ cls.name = os.environ.get(config_name_env_var) or cls.name
89
+ return cls
@@ -1,183 +1,19 @@
1
- """
2
- The context module in the CLI package contains the definition of the
3
- ServerContext and NodeContext classes. These contexts are related to the host
4
- system and therefore part of the CLI package.
5
-
6
- Both classes are derived from the abstract AppContext class. And provide the
7
- node and server with naming conventions, standard file locations, and in the
8
- case of the node with a local database URIs.
9
-
10
- *Server Context*
11
- A class to provide context for the server, both for development mode as
12
- for production.
13
-
14
- *Node Context*
15
- In case the node is run in development mode, this context will also used by
16
- the node package. Normally the node uses the
17
- `vantage6.node.context.DockerNodeContext` which provides the same
18
- functionality but is tailored to the Docker environment.
19
-
20
- """
21
- # TODO BvB 2023-01-10 we should have a look at all context classes and define
22
- # them in the same place. Now the DockerNodeContext is defined in the node, but
23
- # the server only has a TestServerContext there. This should be made consistent
24
1
  from __future__ import annotations
25
2
 
26
3
  import os.path
27
4
 
28
5
  from pathlib import Path
29
6
 
30
- from sqlalchemy.engine.url import make_url
31
-
32
7
  from vantage6.common.context import AppContext
33
- from vantage6.common.globals import APPNAME
34
- from vantage6.cli.configuration_manager import (
35
- NodeConfigurationManager,
36
- ServerConfigurationManager,
37
- )
38
- from vantage6.cli.globals import (
39
- DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL,
40
- DEFAULT_SERVER_SYSTEM_FOLDERS as S_FOL,
41
- )
8
+ from vantage6.common.globals import APPNAME, InstanceType
9
+ from vantage6.cli.configuration_manager import NodeConfigurationManager
10
+ from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
42
11
  from vantage6.cli._version import __version__
43
12
 
44
13
 
45
- class ServerContext(AppContext):
46
- """
47
- Server context
48
-
49
- Parameters
50
- ----------
51
- instance_name : str
52
- Name of the configuration instance, corresponds to the filename
53
- of the configuration file.
54
- system_folders : bool, optional
55
- System wide or user configuration, by default S_FOL
56
- """
57
-
58
- # The server configuration manager is aware of the structure of the server
59
- # configuration file and makes sure only valid configuration can be loaded.
60
- INST_CONFIG_MANAGER = ServerConfigurationManager
61
-
62
- def __init__(self, instance_name: str, system_folders: bool = S_FOL):
63
- super().__init__("server", instance_name, system_folders=system_folders)
64
- self.log.info(f"vantage6 version '{__version__}'")
65
-
66
- def get_database_uri(self) -> str:
67
- """
68
- Obtain the database uri from the environment or the configuration. The
69
- `VANTAGE6_DB_URI` environment variable is used by the Docker container,
70
- but can also be set by the user.
71
-
72
- Returns
73
- -------
74
- str
75
- string representation of the database uri
76
- """
77
- uri = os.environ.get("VANTAGE6_DB_URI") or self.config["uri"]
78
- url = make_url(uri)
79
-
80
- if url.host is None and not os.path.isabs(url.database):
81
- # We're dealing with a relative path here of a local database, when
82
- # we're running the server outside of docker. Therefore we need to
83
- # prepend the data directory to the database name, but after the
84
- # driver name (e.g. sqlite:////db.sqlite ->
85
- # sqlite:////data_dir>/db.sqlite)
86
-
87
- # find index of database name
88
- idx_db_name = str(url).find(url.database)
89
-
90
- # add the datadir to the right location in the database uri
91
- return str(url)[:idx_db_name] + str(self.data_dir / url.database)
92
-
93
- return uri
94
-
95
- @property
96
- def docker_container_name(self) -> str:
97
- """
98
- Name of the docker container that the server is running in.
99
-
100
- Returns
101
- -------
102
- str
103
- Server's docker container name
104
- """
105
- return f"{APPNAME}-{self.name}-{self.scope}-server"
106
-
107
- @classmethod
108
- def from_external_config_file(
109
- cls, path: str, system_folders: bool = S_FOL
110
- ) -> ServerContext:
111
- """
112
- Create a server context from an external configuration file. External
113
- means that the configuration file is not located in the default folders
114
- but its location is specified by the user.
115
-
116
- Parameters
117
- ----------
118
- path : str
119
- Path of the configuration file
120
- system_folders : bool, optional
121
- System wide or user configuration, by default S_FOL
122
-
123
- Returns
124
- -------
125
- ServerContext
126
- Server context object
127
- """
128
- cls = super().from_external_config_file(path, "server", system_folders)
129
- # if we are running a server in a docker container, the name is taken
130
- # from the name of the config file (which is usually a default). Get
131
- # the config name from environment if it is given.
132
- cls.name = os.environ.get("VANTAGE6_CONFIG_NAME") or cls.name
133
- return cls
134
-
135
- @classmethod
136
- def config_exists(cls, instance_name: str, system_folders: bool = S_FOL) -> bool:
137
- """
138
- Check if a configuration file exists.
139
-
140
- Parameters
141
- ----------
142
- instance_name : str
143
- Name of the configuration instance, corresponds to the filename
144
- of the configuration file.
145
- system_folders : bool, optional
146
- System wide or user configuration, by default S_FOL
147
-
148
- Returns
149
- -------
150
- bool
151
- Whether the configuration file exists or not
152
- """
153
- return super().config_exists(
154
- "server", instance_name, system_folders=system_folders
155
- )
156
-
157
- @classmethod
158
- def available_configurations(
159
- cls, system_folders: bool = S_FOL
160
- ) -> tuple[list, list]:
161
- """
162
- Find all available server configurations in the default folders.
163
-
164
- Parameters
165
- ----------
166
- system_folders : bool, optional
167
- System wide or user configuration, by default S_FOL
168
-
169
- Returns
170
- -------
171
- tuple[list, list]
172
- The first list contains validated configuration files, the second
173
- list contains invalid configuration files.
174
- """
175
- return super().available_configurations("server", system_folders)
176
-
177
-
178
14
  class NodeContext(AppContext):
179
15
  """
180
- Node context
16
+ Node context object for the host system.
181
17
 
182
18
  See DockerNodeContext for the node instance mounts when running as a
183
19
  dockerized service.
@@ -200,8 +36,8 @@ class NodeContext(AppContext):
200
36
  def __init__(
201
37
  self, instance_name: str, system_folders: bool = N_FOL, config_file: str = None
202
38
  ):
203
- super().__init__("node", instance_name, system_folders, config_file)
204
- self.log.info(f"vantage6 version '{__version__}'")
39
+ super().__init__(InstanceType.NODE, instance_name, system_folders, config_file)
40
+ self.log.info("vantage6 version '%s'", __version__)
205
41
 
206
42
  @classmethod
207
43
  def from_external_config_file(
@@ -224,7 +60,9 @@ class NodeContext(AppContext):
224
60
  NodeContext
225
61
  Node context object
226
62
  """
227
- return super().from_external_config_file(path, "node", system_folders)
63
+ return super().from_external_config_file(
64
+ path, InstanceType.NODE, system_folders
65
+ )
228
66
 
229
67
  @classmethod
230
68
  def config_exists(cls, instance_name: str, system_folders: bool = N_FOL) -> bool:
@@ -245,7 +83,7 @@ class NodeContext(AppContext):
245
83
  Whether the configuration file exists or not
246
84
  """
247
85
  return super().config_exists(
248
- "node", instance_name, system_folders=system_folders
86
+ InstanceType.NODE, instance_name, system_folders=system_folders
249
87
  )
250
88
 
251
89
  @classmethod
@@ -266,7 +104,7 @@ class NodeContext(AppContext):
266
104
  The first list contains validated configuration files, the second
267
105
  list contains invalid configuration files.
268
106
  """
269
- return super().available_configurations("node", system_folders)
107
+ return super().available_configurations(InstanceType.NODE, system_folders)
270
108
 
271
109
  @staticmethod
272
110
  def type_data_folder(system_folders: bool = N_FOL) -> Path:
@@ -283,7 +121,7 @@ class NodeContext(AppContext):
283
121
  Path
284
122
  Path to the data folder
285
123
  """
286
- return AppContext.type_data_folder("node", system_folders)
124
+ return AppContext.type_data_folder(InstanceType.NODE, system_folders)
287
125
 
288
126
  @property
289
127
  def databases(self) -> dict:
@@ -0,0 +1,127 @@
1
+ from __future__ import annotations
2
+
3
+ from vantage6.common.globals import APPNAME, InstanceType
4
+ from vantage6.cli.configuration_manager import ServerConfigurationManager
5
+ from vantage6.cli.globals import (
6
+ DEFAULT_SERVER_SYSTEM_FOLDERS as S_FOL,
7
+ ServerType,
8
+ ServerGlobals,
9
+ )
10
+ from vantage6.cli._version import __version__
11
+ from vantage6.cli.context.base_server import BaseServerContext
12
+
13
+
14
+ class ServerContext(BaseServerContext):
15
+ """
16
+ Server context
17
+
18
+ Parameters
19
+ ----------
20
+ instance_name : str
21
+ Name of the configuration instance, corresponds to the filename
22
+ of the configuration file.
23
+ system_folders : bool, optional
24
+ System wide or user configuration, by default S_FOL
25
+ """
26
+
27
+ # The server configuration manager is aware of the structure of the server
28
+ # configuration file and makes sure only valid configuration can be loaded.
29
+ INST_CONFIG_MANAGER = ServerConfigurationManager
30
+
31
+ def __init__(self, instance_name: str, system_folders: bool = S_FOL):
32
+ super().__init__(
33
+ InstanceType.SERVER, instance_name, system_folders=system_folders
34
+ )
35
+ self.log.info("vantage6 version '%s'", __version__)
36
+
37
+ def get_database_uri(self) -> str:
38
+ """
39
+ Obtain the database uri from the environment or the configuration. The
40
+ `VANTAGE6_DB_URI` environment variable is used by the Docker container,
41
+ but can also be set by the user.
42
+
43
+ Returns
44
+ -------
45
+ str
46
+ string representation of the database uri
47
+ """
48
+ return super().get_database_uri(ServerGlobals.DB_URI_ENV_VAR)
49
+
50
+ @property
51
+ def docker_container_name(self) -> str:
52
+ """
53
+ Name of the docker container that the server is running in.
54
+
55
+ Returns
56
+ -------
57
+ str
58
+ Server's docker container name
59
+ """
60
+ return f"{APPNAME}-{self.name}-{self.scope}-{ServerType.V6SERVER}"
61
+
62
+ @classmethod
63
+ def from_external_config_file(
64
+ cls, path: str, system_folders: bool = S_FOL
65
+ ) -> ServerContext:
66
+ """
67
+ Create a server context from an external configuration file. External
68
+ means that the configuration file is not located in the default folders
69
+ but its location is specified by the user.
70
+
71
+ Parameters
72
+ ----------
73
+ path : str
74
+ Path of the configuration file
75
+ system_folders : bool, optional
76
+ System wide or user configuration, by default S_FOL
77
+
78
+ Returns
79
+ -------
80
+ ServerContext
81
+ Server context object
82
+ """
83
+ return super().from_external_config_file(
84
+ path, ServerType.V6SERVER, ServerGlobals.CONFIG_NAME_ENV_VAR, system_folders
85
+ )
86
+
87
+ @classmethod
88
+ def config_exists(cls, instance_name: str, system_folders: bool = S_FOL) -> bool:
89
+ """
90
+ Check if a configuration file exists.
91
+
92
+ Parameters
93
+ ----------
94
+ instance_name : str
95
+ Name of the configuration instance, corresponds to the filename
96
+ of the configuration file.
97
+ system_folders : bool, optional
98
+ System wide or user configuration, by default S_FOL
99
+
100
+ Returns
101
+ -------
102
+ bool
103
+ Whether the configuration file exists or not
104
+ """
105
+ return super().config_exists(
106
+ InstanceType.SERVER, instance_name, system_folders=system_folders
107
+ )
108
+
109
+ @classmethod
110
+ def available_configurations(
111
+ cls, system_folders: bool = S_FOL
112
+ ) -> tuple[list, list]:
113
+ """
114
+ Find all available server configurations in the default folders.
115
+
116
+ Parameters
117
+ ----------
118
+ system_folders : bool, optional
119
+ System wide or user configuration, by default S_FOL
120
+
121
+ Returns
122
+ -------
123
+ tuple[list, list]
124
+ The first list contains validated configuration files, the second
125
+ list contains invalid configuration files.
126
+ """
127
+ return super().available_configurations(InstanceType.SERVER, system_folders)
@@ -5,11 +5,12 @@ import click
5
5
  from jinja2 import Environment, FileSystemLoader
6
6
  from colorama import Fore, Style
7
7
 
8
- from vantage6.common.globals import APPNAME
8
+ from vantage6.common.globals import APPNAME, InstanceType
9
9
  from vantage6.common import info, error, generate_apikey
10
10
 
11
11
  from vantage6.cli.globals import PACKAGE_FOLDER
12
- from vantage6.cli.context import ServerContext, NodeContext
12
+ from vantage6.cli.context.server import ServerContext
13
+ from vantage6.cli.context.node import NodeContext
13
14
  from vantage6.cli.server.common import get_server_context
14
15
  from vantage6.cli.server.import_ import cli_server_import
15
16
  from vantage6.cli.utils import prompt_config_name
@@ -233,7 +234,7 @@ def create_vserver_import_config(node_configs: list[dict], server_name: str) ->
233
234
  server_import_config = template.render(
234
235
  organizations=organizations, collaboration=collaboration
235
236
  )
236
- folders = ServerContext.instance_folders("server", server_name, False)
237
+ folders = ServerContext.instance_folders(InstanceType.SERVER, server_name, False)
237
238
 
238
239
  demo_dir = Path(folders["dev"])
239
240
  demo_dir.mkdir(parents=True, exist_ok=True)
@@ -6,10 +6,12 @@ from pathlib import Path
6
6
  import click
7
7
 
8
8
  from vantage6.common import info
9
- from vantage6.cli.context import ServerContext, NodeContext
9
+ from vantage6.cli.context.server import ServerContext
10
+ from vantage6.cli.context.node import NodeContext
10
11
  from vantage6.cli.server.common import click_insert_context
11
12
  from vantage6.cli.server.remove import cli_server_remove
12
13
  from vantage6.cli.utils import remove_file
14
+ from vantage6.common.globals import InstanceType
13
15
 
14
16
 
15
17
  @click.command()
@@ -30,14 +32,14 @@ def remove_demo_network(click_ctx: click.Context, ctx: ServerContext) -> None:
30
32
  # removing the server import config
31
33
  info("Deleting demo import config file")
32
34
  server_configs = ServerContext.instance_folders(
33
- "server", ctx.name, system_folders=False
35
+ InstanceType.SERVER, ctx.name, system_folders=False
34
36
  )
35
37
  import_config_to_del = Path(server_configs["dev"]) / f"{ctx.name}.yaml"
36
38
  remove_file(import_config_to_del, "import_configuration")
37
39
 
38
40
  # also remove the server folder
39
41
  server_configs = ServerContext.instance_folders(
40
- "server", ctx.name, system_folders=True
42
+ InstanceType.SERVER, ctx.name, system_folders=True
41
43
  )
42
44
  server_folder = server_configs["data"]
43
45
  if server_folder.is_dir():
vantage6/cli/dev/start.py CHANGED
@@ -1,7 +1,8 @@
1
1
  import subprocess
2
2
  import click
3
3
 
4
- from vantage6.cli.context import ServerContext, NodeContext
4
+ from vantage6.cli.context.server import ServerContext
5
+ from vantage6.cli.context.node import NodeContext
5
6
  from vantage6.cli.server.common import click_insert_context
6
7
  from vantage6.cli.server.start import cli_server_start
7
8
 
vantage6/cli/dev/stop.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import click
2
2
 
3
- from vantage6.cli.context import ServerContext, NodeContext
3
+ from vantage6.cli.context.server import ServerContext
4
+ from vantage6.cli.context.node import NodeContext
4
5
  from vantage6.cli.server.common import click_insert_context
5
6
  from vantage6.cli.server.stop import cli_server_stop
6
7
  from vantage6.cli.node.stop import cli_node_stop
vantage6/cli/globals.py CHANGED
@@ -1,6 +1,7 @@
1
1
  """
2
2
  This module contains global variables that are used throughout the CLI.
3
3
  """
4
+ from enum import Enum
4
5
  from pathlib import Path
5
6
  from vantage6.common.globals import APPNAME
6
7
 
@@ -39,3 +40,26 @@ ALGORITHM_TEMPLATE_REPO = "gh:vantage6/v6-algorithm-template.git"
39
40
 
40
41
  # image to use for diagnostics in `v6 test` commands
41
42
  DIAGNOSTICS_IMAGE = "harbor2.vantage6.ai/algorithms/diagnostic"
43
+
44
+
45
+ class ServerType(str, Enum):
46
+ """Enum containing server types"""
47
+
48
+ V6SERVER = "server"
49
+ ALGORITHM_STORE = "algorithm-store"
50
+
51
+
52
+ class ServerGlobals(str, Enum):
53
+ """Enum containing server environment variables"""
54
+
55
+ DB_URI_ENV_VAR = "VANTAGE6_DB_URI"
56
+ CONFIG_NAME_ENV_VAR = "VANTAGE6_CONFIG_NAME"
57
+ PORT = "5000"
58
+
59
+
60
+ class AlgoStoreGlobals(str, Enum):
61
+ """Enum containing algorithm store environment variables"""
62
+
63
+ DB_URI_ENV_VAR = "VANTAGE6_ALGO_STORE_DB_URI"
64
+ CONFIG_NAME_ENV_VAR = "VANTAGE6_ALGO_STORE_CONFIG_NAME"
65
+ PORT = "5002" # 5001 is the default UI port