vantage6 5.0.0a33__py3-none-any.whl → 5.0.0a34__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.
- vantage6/cli/algostore/new.py +24 -46
- vantage6/cli/algostore/start.py +33 -67
- vantage6/cli/algostore/stop.py +75 -40
- vantage6/cli/common/new.py +60 -0
- vantage6/cli/common/start.py +17 -223
- vantage6/cli/common/stop.py +1 -1
- vantage6/cli/common/utils.py +212 -16
- vantage6/cli/configuration_manager.py +65 -0
- vantage6/cli/configuration_wizard.py +95 -76
- vantage6/cli/context/algorithm_store.py +7 -6
- vantage6/cli/context/base_server.py +22 -30
- vantage6/cli/context/node.py +4 -0
- vantage6/cli/context/server.py +16 -7
- vantage6/cli/globals.py +12 -11
- vantage6/cli/node/common/__init__.py +1 -1
- vantage6/cli/node/create_private_key.py +9 -6
- vantage6/cli/node/set_api_key.py +7 -4
- vantage6/cli/node/start.py +1 -1
- vantage6/cli/node/stop.py +7 -7
- vantage6/cli/server/import_.py +1 -2
- vantage6/cli/server/list.py +0 -3
- vantage6/cli/server/new.py +13 -51
- vantage6/cli/server/shell.py +1 -1
- vantage6/cli/server/start.py +17 -17
- vantage6/cli/server/stop.py +64 -15
- vantage6/cli/template/algo_store_config.j2 +195 -22
- vantage6/cli/template/server_config.j2 +255 -33
- {vantage6-5.0.0a33.dist-info → vantage6-5.0.0a34.dist-info}/METADATA +4 -4
- {vantage6-5.0.0a33.dist-info → vantage6-5.0.0a34.dist-info}/RECORD +31 -31
- vantage6/cli/template/server_import_config.j2 +0 -31
- {vantage6-5.0.0a33.dist-info → vantage6-5.0.0a34.dist-info}/WHEEL +0 -0
- {vantage6-5.0.0a33.dist-info → vantage6-5.0.0a34.dist-info}/entry_points.txt +0 -0
|
@@ -18,6 +18,7 @@ from vantage6.common.globals import (
|
|
|
18
18
|
|
|
19
19
|
from vantage6.cli.config import CliConfig
|
|
20
20
|
from vantage6.cli.configuration_manager import (
|
|
21
|
+
AlgorithmStoreConfigurationManager,
|
|
21
22
|
NodeConfigurationManager,
|
|
22
23
|
ServerConfigurationManager,
|
|
23
24
|
)
|
|
@@ -283,7 +284,9 @@ def _get_allowed_algorithm_stores() -> list[str]:
|
|
|
283
284
|
return allowed_algorithm_stores
|
|
284
285
|
|
|
285
286
|
|
|
286
|
-
def
|
|
287
|
+
def _add_common_server_config(
|
|
288
|
+
config: dict, instance_type: InstanceType, instance_name: str
|
|
289
|
+
) -> dict:
|
|
287
290
|
"""
|
|
288
291
|
Part of the questionaire that is common to all server types (vantage6
|
|
289
292
|
server and algorithm store server).
|
|
@@ -300,52 +303,26 @@ def _get_common_server_config(instance_type: InstanceType, instance_name: str) -
|
|
|
300
303
|
dict
|
|
301
304
|
Dictionary with new (partial) server configuration
|
|
302
305
|
"""
|
|
303
|
-
|
|
304
|
-
[
|
|
305
|
-
{
|
|
306
|
-
"type": "text",
|
|
307
|
-
"name": "description",
|
|
308
|
-
"message": "Enter a human-readable description:",
|
|
309
|
-
},
|
|
310
|
-
{"type": "text", "name": "ip", "message": "ip:", "default": "0.0.0.0"},
|
|
311
|
-
{
|
|
312
|
-
"type": "text",
|
|
313
|
-
"name": "port",
|
|
314
|
-
"message": "Enter port to which the server listens:",
|
|
315
|
-
"default": (
|
|
316
|
-
str(Ports.DEV_SERVER)
|
|
317
|
-
if instance_type == InstanceType.SERVER
|
|
318
|
-
else str(Ports.DEV_ALGO_STORE)
|
|
319
|
-
),
|
|
320
|
-
},
|
|
321
|
-
]
|
|
306
|
+
backend_config = (
|
|
307
|
+
config["server"] if instance_type == InstanceType.SERVER else config["store"]
|
|
322
308
|
)
|
|
323
309
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
"type": "select",
|
|
335
|
-
"name": "allow_drop_all",
|
|
336
|
-
"message": "Allowed to drop all tables: ",
|
|
337
|
-
"choices": ["True", "False"],
|
|
338
|
-
},
|
|
339
|
-
]
|
|
340
|
-
)
|
|
341
|
-
)
|
|
310
|
+
backend_config["port"] = q.text(
|
|
311
|
+
"Enter port to which the server listens:",
|
|
312
|
+
default=(
|
|
313
|
+
str(Ports.DEV_SERVER)
|
|
314
|
+
if instance_type == InstanceType.SERVER
|
|
315
|
+
else str(Ports.DEV_ALGO_STORE)
|
|
316
|
+
),
|
|
317
|
+
).unsafe_ask()
|
|
342
318
|
|
|
343
319
|
res = q.select(
|
|
344
320
|
"Which level of logging would you like?",
|
|
345
|
-
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"
|
|
321
|
+
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
|
322
|
+
default="INFO",
|
|
346
323
|
).unsafe_ask()
|
|
347
324
|
|
|
348
|
-
|
|
325
|
+
backend_config["logging"] = {
|
|
349
326
|
"level": res,
|
|
350
327
|
"file": f"{instance_name}.log",
|
|
351
328
|
"use_console": True,
|
|
@@ -359,25 +336,42 @@ def _get_common_server_config(instance_type: InstanceType, instance_name: str) -
|
|
|
359
336
|
{"name": "socketio.server", "level": "warning"},
|
|
360
337
|
{"name": "engineio.server", "level": "warning"},
|
|
361
338
|
{"name": "sqlalchemy.engine", "level": "warning"},
|
|
362
|
-
{"name": "requests_oauthlib.oauth2_session", "level": "warning"},
|
|
363
339
|
],
|
|
364
340
|
}
|
|
365
341
|
|
|
366
|
-
|
|
342
|
+
backend_config["api_path"] = DEFAULT_API_PATH
|
|
367
343
|
|
|
368
|
-
|
|
344
|
+
# === Database settings ===
|
|
345
|
+
config["database"]["volumePath"] = q.text(
|
|
346
|
+
"Where is your server database located on the host machine?",
|
|
347
|
+
default=f"{Path.cwd()}/dev/.db/db_pv_server",
|
|
348
|
+
).unsafe_ask()
|
|
369
349
|
|
|
350
|
+
config["database"]["k8sNodeName"] = q.text(
|
|
351
|
+
"What is the name of the k8s node where the databases are running?",
|
|
352
|
+
default="docker-desktop",
|
|
353
|
+
).unsafe_ask()
|
|
370
354
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
355
|
+
is_production = q.confirm(
|
|
356
|
+
"Do you want to use production settings for this server? If not, the server will "
|
|
357
|
+
"be configured to be more suitable for development or testing purposes.",
|
|
358
|
+
default=True,
|
|
359
|
+
).unsafe_ask()
|
|
360
|
+
|
|
361
|
+
if is_production:
|
|
362
|
+
config = _add_production_server_config(config)
|
|
363
|
+
|
|
364
|
+
return config, is_production
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def server_configuration_questionaire(instance_name: str) -> dict[str, Any]:
|
|
374
368
|
"""
|
|
375
369
|
Kubernetes-specific questionnaire to generate Helm values for server.
|
|
376
370
|
|
|
377
371
|
Parameters
|
|
378
372
|
----------
|
|
379
373
|
instance_name : str
|
|
380
|
-
Name of the server instance
|
|
374
|
+
Name of the server instance.
|
|
381
375
|
|
|
382
376
|
Returns
|
|
383
377
|
-------
|
|
@@ -389,14 +383,23 @@ def server_configuration_questionaire(
|
|
|
389
383
|
kube_namespace = cli_config.get_last_namespace()
|
|
390
384
|
|
|
391
385
|
# Initialize config with basic structure
|
|
392
|
-
config = {"server": {}, "database": {}, "ui": {}}
|
|
386
|
+
config = {"server": {}, "database": {}, "ui": {}, "rabbitmq": {}}
|
|
393
387
|
|
|
388
|
+
config, is_production = _add_common_server_config(
|
|
389
|
+
config, InstanceType.SERVER, instance_name
|
|
390
|
+
)
|
|
391
|
+
if not is_production:
|
|
392
|
+
config["server"]["jwt"] = {
|
|
393
|
+
"secret": "constant_development_secret`",
|
|
394
|
+
}
|
|
395
|
+
config["server"]["dev"] = {
|
|
396
|
+
"host_uri": "host.docker.internal",
|
|
397
|
+
"store_in_local_cluster": True,
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
# TODO v5+ these should be removed, latest should usually be used so question is
|
|
401
|
+
# not needed. However, for now we want to specify alpha/beta images.
|
|
394
402
|
# === Server settings ===
|
|
395
|
-
config["server"]["description"] = q.text(
|
|
396
|
-
"Enter a human-readable description:",
|
|
397
|
-
default=f"Vantage6 server {instance_name}",
|
|
398
|
-
).unsafe_ask()
|
|
399
|
-
|
|
400
403
|
config["server"]["image"] = q.text(
|
|
401
404
|
"Server Docker image:",
|
|
402
405
|
default="harbor2.vantage6.ai/infrastructure/server:latest",
|
|
@@ -408,29 +411,36 @@ def server_configuration_questionaire(
|
|
|
408
411
|
default="harbor2.vantage6.ai/infrastructure/ui:latest",
|
|
409
412
|
).unsafe_ask()
|
|
410
413
|
|
|
411
|
-
# === Database settings ===
|
|
412
|
-
config["database"]["volumePath"] = q.text(
|
|
413
|
-
"Where is your server database located on the host machine?",
|
|
414
|
-
default=f"{Path.cwd()}/dev/.db/db_pv_server",
|
|
415
|
-
).unsafe_ask()
|
|
416
|
-
|
|
417
|
-
config["database"]["k8sNodeName"] = q.text(
|
|
418
|
-
"What is the name of the k8s node where the databases are running?",
|
|
419
|
-
default="docker-desktop",
|
|
420
|
-
).unsafe_ask()
|
|
421
|
-
|
|
422
414
|
# === Keycloak settings ===
|
|
423
415
|
keycloak_url = f"http://vantage6-auth-keycloak.{kube_namespace}.svc.cluster.local"
|
|
424
416
|
config["server"]["keycloakUrl"] = keycloak_url
|
|
425
417
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
418
|
+
return config
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
def _add_production_server_config(config: dict) -> dict:
|
|
422
|
+
"""
|
|
423
|
+
Add the production server configuration to the config
|
|
424
|
+
|
|
425
|
+
Parameters
|
|
426
|
+
----------
|
|
427
|
+
config : dict
|
|
428
|
+
The config to add the production server configuration to
|
|
432
429
|
|
|
433
|
-
|
|
430
|
+
Returns
|
|
431
|
+
-------
|
|
432
|
+
dict
|
|
433
|
+
The config with the production server configuration added
|
|
434
|
+
"""
|
|
435
|
+
info("For production environments, it is recommended to use an external database.")
|
|
436
|
+
info("Please provide the URI of the external database.")
|
|
437
|
+
info("Example: postgresql://username:password@localhost:5432/vantage6")
|
|
438
|
+
|
|
439
|
+
config["database"]["external"] = True
|
|
440
|
+
config["database"]["uri"] = q.text(
|
|
441
|
+
"Database URI:",
|
|
442
|
+
default="postgresql://vantage6:vantage6@localhost:5432/vantage6",
|
|
443
|
+
).unsafe_ask()
|
|
434
444
|
|
|
435
445
|
return config
|
|
436
446
|
|
|
@@ -450,7 +460,17 @@ def algo_store_configuration_questionaire(instance_name: str) -> dict:
|
|
|
450
460
|
dict
|
|
451
461
|
Dictionary with the new server configuration
|
|
452
462
|
"""
|
|
453
|
-
config =
|
|
463
|
+
config = {"store": {}, "database": {}}
|
|
464
|
+
|
|
465
|
+
config, is_production = _add_common_server_config(
|
|
466
|
+
config, InstanceType.ALGORITHM_STORE, instance_name
|
|
467
|
+
)
|
|
468
|
+
if not is_production:
|
|
469
|
+
config["store"]["dev"] = {
|
|
470
|
+
"host_uri": "host.docker.internal",
|
|
471
|
+
"disable_review": True,
|
|
472
|
+
"review_own_algorithm": True,
|
|
473
|
+
}
|
|
454
474
|
|
|
455
475
|
default_v6_server_uri = f"http://localhost:{Ports.DEV_SERVER}{DEFAULT_API_PATH}"
|
|
456
476
|
default_root_username = "admin"
|
|
@@ -472,6 +492,7 @@ def algo_store_configuration_questionaire(instance_name: str) -> dict:
|
|
|
472
492
|
}
|
|
473
493
|
|
|
474
494
|
# ask about openness of the algorithm store
|
|
495
|
+
config["policies"] = {}
|
|
475
496
|
is_open = q.confirm(
|
|
476
497
|
"Do you want to open the algorithm store to the public? This will allow anyone "
|
|
477
498
|
"to view the algorithms, but they cannot modify them.",
|
|
@@ -523,11 +544,9 @@ def configuration_wizard(
|
|
|
523
544
|
config = node_configuration_questionaire(dirs, instance_name)
|
|
524
545
|
elif type_ == InstanceType.SERVER:
|
|
525
546
|
conf_manager = ServerConfigurationManager
|
|
526
|
-
config = server_configuration_questionaire(
|
|
527
|
-
instance_name=instance_name,
|
|
528
|
-
)
|
|
547
|
+
config = server_configuration_questionaire(instance_name)
|
|
529
548
|
else:
|
|
530
|
-
conf_manager =
|
|
549
|
+
conf_manager = AlgorithmStoreConfigurationManager
|
|
531
550
|
config = algo_store_configuration_questionaire(instance_name)
|
|
532
551
|
|
|
533
552
|
# in the case of an environment we need to add it to the current
|
|
@@ -3,11 +3,10 @@ from __future__ import annotations
|
|
|
3
3
|
from vantage6.common.globals import APPNAME, InstanceType
|
|
4
4
|
|
|
5
5
|
from vantage6.cli import __version__
|
|
6
|
-
from vantage6.cli.configuration_manager import
|
|
6
|
+
from vantage6.cli.configuration_manager import AlgorithmStoreConfigurationManager
|
|
7
7
|
from vantage6.cli.context.base_server import BaseServerContext
|
|
8
8
|
from vantage6.cli.globals import (
|
|
9
9
|
DEFAULT_SERVER_SYSTEM_FOLDERS as S_FOL,
|
|
10
|
-
AlgoStoreGlobals,
|
|
11
10
|
ServerType,
|
|
12
11
|
)
|
|
13
12
|
|
|
@@ -25,7 +24,7 @@ class AlgorithmStoreContext(BaseServerContext):
|
|
|
25
24
|
System wide or user configuration, by default S_FOL
|
|
26
25
|
"""
|
|
27
26
|
|
|
28
|
-
INST_CONFIG_MANAGER =
|
|
27
|
+
INST_CONFIG_MANAGER = AlgorithmStoreConfigurationManager
|
|
29
28
|
|
|
30
29
|
def __init__(self, instance_name: str, system_folders: bool = S_FOL):
|
|
31
30
|
super().__init__(
|
|
@@ -44,7 +43,7 @@ class AlgorithmStoreContext(BaseServerContext):
|
|
|
44
43
|
str
|
|
45
44
|
string representation of the database uri
|
|
46
45
|
"""
|
|
47
|
-
return super().get_database_uri(
|
|
46
|
+
return super().get_database_uri()
|
|
48
47
|
|
|
49
48
|
@property
|
|
50
49
|
def docker_container_name(self) -> str:
|
|
@@ -60,7 +59,7 @@ class AlgorithmStoreContext(BaseServerContext):
|
|
|
60
59
|
|
|
61
60
|
@classmethod
|
|
62
61
|
def from_external_config_file(
|
|
63
|
-
cls, path: str, system_folders: bool = S_FOL
|
|
62
|
+
cls, path: str, system_folders: bool = S_FOL, in_container: bool = False
|
|
64
63
|
) -> AlgorithmStoreContext:
|
|
65
64
|
"""
|
|
66
65
|
Create a server context from an external configuration file. External
|
|
@@ -73,6 +72,8 @@ class AlgorithmStoreContext(BaseServerContext):
|
|
|
73
72
|
Path of the configuration file
|
|
74
73
|
system_folders : bool, optional
|
|
75
74
|
System wide or user configuration, by default S_FOL
|
|
75
|
+
in_container : bool, optional
|
|
76
|
+
Whether the application is running inside a container, by default False
|
|
76
77
|
|
|
77
78
|
Returns
|
|
78
79
|
-------
|
|
@@ -82,8 +83,8 @@ class AlgorithmStoreContext(BaseServerContext):
|
|
|
82
83
|
return super().from_external_config_file(
|
|
83
84
|
path,
|
|
84
85
|
ServerType.ALGORITHM_STORE,
|
|
85
|
-
AlgoStoreGlobals.CONFIG_NAME_ENV_VAR.value,
|
|
86
86
|
system_folders,
|
|
87
|
+
in_container,
|
|
87
88
|
)
|
|
88
89
|
|
|
89
90
|
@classmethod
|
|
@@ -5,6 +5,7 @@ import os.path
|
|
|
5
5
|
from sqlalchemy.engine.url import make_url
|
|
6
6
|
|
|
7
7
|
from vantage6.common.context import AppContext
|
|
8
|
+
|
|
8
9
|
from vantage6.cli.globals import (
|
|
9
10
|
DEFAULT_SERVER_SYSTEM_FOLDERS as S_FOL,
|
|
10
11
|
ServerType,
|
|
@@ -19,35 +20,29 @@ class BaseServerContext(AppContext):
|
|
|
19
20
|
in common.
|
|
20
21
|
"""
|
|
21
22
|
|
|
22
|
-
def get_database_uri(self
|
|
23
|
+
def get_database_uri(self) -> str:
|
|
23
24
|
"""
|
|
24
25
|
Obtain the database uri from the environment or the configuration.
|
|
25
26
|
|
|
26
|
-
Parameters
|
|
27
|
-
----------
|
|
28
|
-
db_env_var : str
|
|
29
|
-
Name of the environment variable that contains the database uri
|
|
30
|
-
|
|
31
27
|
Returns
|
|
32
28
|
-------
|
|
33
29
|
str
|
|
34
30
|
string representation of the database uri
|
|
35
31
|
"""
|
|
36
|
-
uri
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return str(url)[:idx_db_name] + str(self.data_dir / url.database)
|
|
32
|
+
# within container, the uri is set in the config file
|
|
33
|
+
if self.in_container:
|
|
34
|
+
return self.config.get("uri")
|
|
35
|
+
|
|
36
|
+
# outside container, the uri is set in the values.yaml in a different location
|
|
37
|
+
is_db_external = self.config.get("database", {}).get("external", False)
|
|
38
|
+
if is_db_external:
|
|
39
|
+
uri = self.config["database"]["uri"]
|
|
40
|
+
else:
|
|
41
|
+
db_conf = self.config["database"]
|
|
42
|
+
uri = (
|
|
43
|
+
f"postgresql://{db_conf['username']}:{db_conf['password']}@"
|
|
44
|
+
f"{self.helm_release_name}-postgres-service:5432/{db_conf['name']}"
|
|
45
|
+
)
|
|
51
46
|
|
|
52
47
|
return uri
|
|
53
48
|
|
|
@@ -56,8 +51,8 @@ class BaseServerContext(AppContext):
|
|
|
56
51
|
cls,
|
|
57
52
|
path: str,
|
|
58
53
|
server_type: ServerType,
|
|
59
|
-
config_name_env_var: str,
|
|
60
54
|
system_folders: bool = S_FOL,
|
|
55
|
+
in_container: bool = False,
|
|
61
56
|
) -> BaseServerContext:
|
|
62
57
|
"""
|
|
63
58
|
Create a server context from an external configuration file. External
|
|
@@ -70,20 +65,17 @@ class BaseServerContext(AppContext):
|
|
|
70
65
|
Path of the configuration file
|
|
71
66
|
server_type : ServerType
|
|
72
67
|
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
68
|
system_folders : bool, optional
|
|
77
69
|
System wide or user configuration, by default S_FOL
|
|
70
|
+
in_container : bool, optional
|
|
71
|
+
Whether the application is running inside a container, by default False
|
|
78
72
|
|
|
79
73
|
Returns
|
|
80
74
|
-------
|
|
81
75
|
ServerContext
|
|
82
76
|
Server context object
|
|
83
77
|
"""
|
|
84
|
-
cls = super().from_external_config_file(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
# the config name from environment if it is given.
|
|
88
|
-
cls.name = os.environ.get(config_name_env_var) or cls.name
|
|
78
|
+
cls = super().from_external_config_file(
|
|
79
|
+
path, server_type, system_folders, in_container
|
|
80
|
+
)
|
|
89
81
|
return cls
|
vantage6/cli/context/node.py
CHANGED
|
@@ -25,6 +25,8 @@ class NodeContext(AppContext):
|
|
|
25
25
|
_description_, by default N_FOL
|
|
26
26
|
config_file : str, optional
|
|
27
27
|
_description_, by default None
|
|
28
|
+
in_container : bool, optional
|
|
29
|
+
Whether the application is running inside a container, by default False
|
|
28
30
|
"""
|
|
29
31
|
|
|
30
32
|
# The server configuration manager is aware of the structure of the server
|
|
@@ -38,6 +40,7 @@ class NodeContext(AppContext):
|
|
|
38
40
|
config_file: str = None,
|
|
39
41
|
print_log_header: bool = True,
|
|
40
42
|
logger_prefix: str = "",
|
|
43
|
+
in_container: bool = False,
|
|
41
44
|
):
|
|
42
45
|
super().__init__(
|
|
43
46
|
InstanceType.NODE,
|
|
@@ -46,6 +49,7 @@ class NodeContext(AppContext):
|
|
|
46
49
|
config_file=config_file,
|
|
47
50
|
print_log_header=print_log_header,
|
|
48
51
|
logger_prefix=logger_prefix,
|
|
52
|
+
in_container=in_container,
|
|
49
53
|
)
|
|
50
54
|
if print_log_header:
|
|
51
55
|
self.log.info("vantage6 version '%s'", __version__)
|
vantage6/cli/context/server.py
CHANGED
|
@@ -10,7 +10,6 @@ from vantage6.cli.context.base_server import BaseServerContext
|
|
|
10
10
|
from vantage6.cli.globals import (
|
|
11
11
|
DEFAULT_SERVER_SYSTEM_FOLDERS as S_FOL,
|
|
12
12
|
PROMETHEUS_DIR,
|
|
13
|
-
ServerGlobals,
|
|
14
13
|
ServerType,
|
|
15
14
|
)
|
|
16
15
|
|
|
@@ -32,9 +31,17 @@ class ServerContext(BaseServerContext):
|
|
|
32
31
|
# configuration file and makes sure only valid configuration can be loaded.
|
|
33
32
|
INST_CONFIG_MANAGER = ServerConfigurationManager
|
|
34
33
|
|
|
35
|
-
def __init__(
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
instance_name: str,
|
|
37
|
+
system_folders: bool = S_FOL,
|
|
38
|
+
in_container: bool = False,
|
|
39
|
+
):
|
|
36
40
|
super().__init__(
|
|
37
|
-
InstanceType.SERVER,
|
|
41
|
+
InstanceType.SERVER,
|
|
42
|
+
instance_name,
|
|
43
|
+
system_folders=system_folders,
|
|
44
|
+
in_container=in_container,
|
|
38
45
|
)
|
|
39
46
|
self.log.info("vantage6 version '%s'", __version__)
|
|
40
47
|
|
|
@@ -47,7 +54,7 @@ class ServerContext(BaseServerContext):
|
|
|
47
54
|
str
|
|
48
55
|
string representation of the database uri
|
|
49
56
|
"""
|
|
50
|
-
return super().get_database_uri(
|
|
57
|
+
return super().get_database_uri()
|
|
51
58
|
|
|
52
59
|
@property
|
|
53
60
|
def docker_container_name(self) -> str:
|
|
@@ -59,7 +66,7 @@ class ServerContext(BaseServerContext):
|
|
|
59
66
|
str
|
|
60
67
|
Server's docker container name
|
|
61
68
|
"""
|
|
62
|
-
return f"{APPNAME}-{self.name}-{self.scope}-{ServerType.V6SERVER}"
|
|
69
|
+
return f"{APPNAME}-{self.name}-{self.scope}-{ServerType.V6SERVER.value}"
|
|
63
70
|
|
|
64
71
|
@property
|
|
65
72
|
def prometheus_container_name(self) -> str:
|
|
@@ -87,7 +94,7 @@ class ServerContext(BaseServerContext):
|
|
|
87
94
|
|
|
88
95
|
@classmethod
|
|
89
96
|
def from_external_config_file(
|
|
90
|
-
cls, path: str, system_folders: bool = S_FOL
|
|
97
|
+
cls, path: str, system_folders: bool = S_FOL, in_container: bool = False
|
|
91
98
|
) -> ServerContext:
|
|
92
99
|
"""
|
|
93
100
|
Create a server context from an external configuration file. External
|
|
@@ -100,6 +107,8 @@ class ServerContext(BaseServerContext):
|
|
|
100
107
|
Path of the configuration file
|
|
101
108
|
system_folders : bool, optional
|
|
102
109
|
System wide or user configuration, by default S_FOL
|
|
110
|
+
in_container : bool, optional
|
|
111
|
+
Whether the application is running inside a container, by default False
|
|
103
112
|
|
|
104
113
|
Returns
|
|
105
114
|
-------
|
|
@@ -109,8 +118,8 @@ class ServerContext(BaseServerContext):
|
|
|
109
118
|
return super().from_external_config_file(
|
|
110
119
|
path,
|
|
111
120
|
ServerType.V6SERVER,
|
|
112
|
-
ServerGlobals.CONFIG_NAME_ENV_VAR.value,
|
|
113
121
|
system_folders,
|
|
122
|
+
in_container,
|
|
114
123
|
)
|
|
115
124
|
|
|
116
125
|
@classmethod
|
vantage6/cli/globals.py
CHANGED
|
@@ -56,6 +56,12 @@ DEFAULT_PROMETHEUS_IMAGE = "prom/prometheus"
|
|
|
56
56
|
PROMETHEUS_CONFIG = "prometheus.yml"
|
|
57
57
|
PROMETHEUS_DIR = "prometheus"
|
|
58
58
|
|
|
59
|
+
# template folder
|
|
60
|
+
TEMPLATE_FOLDER = PACKAGE_FOLDER / APPNAME / "cli" / "template"
|
|
61
|
+
SERVER_TEMPLATE_FILE = "server_config.j2"
|
|
62
|
+
NODE_TEMPLATE_FILE = "node_config.j2"
|
|
63
|
+
ALGO_STORE_TEMPLATE_FILE = "algo_store_config.j2"
|
|
64
|
+
|
|
59
65
|
|
|
60
66
|
# datasets included in the nodes of the dev network
|
|
61
67
|
class DefaultDatasets(StrEnumBase):
|
|
@@ -72,15 +78,10 @@ class ServerType(StrEnumBase):
|
|
|
72
78
|
ALGORITHM_STORE = "algorithm-store"
|
|
73
79
|
|
|
74
80
|
|
|
75
|
-
class
|
|
76
|
-
"""Enum containing
|
|
77
|
-
|
|
78
|
-
DB_URI_ENV_VAR = "VANTAGE6_DB_URI"
|
|
79
|
-
CONFIG_NAME_ENV_VAR = "VANTAGE6_CONFIG_NAME"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
class AlgoStoreGlobals(StrEnumBase):
|
|
83
|
-
"""Enum containing algorithm store environment variables"""
|
|
81
|
+
class ChartName(StrEnumBase):
|
|
82
|
+
"""Enum containing chart names"""
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
SERVER = "server"
|
|
85
|
+
ALGORITHM_STORE = "store"
|
|
86
|
+
NODE = "node"
|
|
87
|
+
AUTH = "auth"
|
|
@@ -109,6 +109,6 @@ def find_running_node_names(client: docker.DockerClient) -> list[str]:
|
|
|
109
109
|
List of names of running nodes
|
|
110
110
|
"""
|
|
111
111
|
running_nodes = client.containers.list(
|
|
112
|
-
filters={"label": f"{APPNAME}-type={InstanceType.NODE}"}
|
|
112
|
+
filters={"label": f"{APPNAME}-type={InstanceType.NODE.value}"}
|
|
113
113
|
)
|
|
114
114
|
return [node.name for node in running_nodes]
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
+
|
|
2
3
|
import click
|
|
3
4
|
from colorama import Fore, Style
|
|
4
5
|
|
|
5
6
|
from vantage6.common import (
|
|
6
|
-
|
|
7
|
+
bytes_to_base64s,
|
|
8
|
+
debug,
|
|
7
9
|
error,
|
|
8
10
|
info,
|
|
9
|
-
|
|
10
|
-
bytes_to_base64s,
|
|
11
|
+
warning,
|
|
11
12
|
)
|
|
12
|
-
|
|
13
13
|
from vantage6.common.encryption import RSACryptor
|
|
14
|
+
|
|
14
15
|
from vantage6.cli.context.node import NodeContext
|
|
15
16
|
from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
|
|
16
|
-
from vantage6.cli.node.common import
|
|
17
|
+
from vantage6.cli.node.common import create_client_and_authenticate, select_node
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
@click.command()
|
|
@@ -28,7 +29,7 @@ from vantage6.cli.node.common import select_node, create_client_and_authenticate
|
|
|
28
29
|
"--system",
|
|
29
30
|
"system_folders",
|
|
30
31
|
flag_value=True,
|
|
31
|
-
help="Search for configuration in system folders rather than
|
|
32
|
+
help="Search for configuration in system folders rather than user folders",
|
|
32
33
|
)
|
|
33
34
|
@click.option(
|
|
34
35
|
"--user",
|
|
@@ -137,6 +138,8 @@ def cli_node_create_private_key(
|
|
|
137
138
|
|
|
138
139
|
# update config file
|
|
139
140
|
info("Updating configuration")
|
|
141
|
+
# TODO v5+ this probably messes up the current config as the template is used...
|
|
142
|
+
# Fix when reimplementing this in v5
|
|
140
143
|
ctx.config["encryption"]["private_key"] = str(file_)
|
|
141
144
|
ctx.config_manager.put(ctx.config)
|
|
142
145
|
ctx.config_manager.save(ctx.config_file)
|
vantage6/cli/node/set_api_key.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import click
|
|
2
2
|
import questionary as q
|
|
3
3
|
|
|
4
|
-
from vantage6.common import error, info
|
|
4
|
+
from vantage6.common import ensure_config_dir_writable, error, info
|
|
5
|
+
|
|
6
|
+
from vantage6.cli.configuration_wizard import NodeConfigurationManager
|
|
5
7
|
from vantage6.cli.context.node import NodeContext
|
|
6
8
|
from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
|
|
7
|
-
from vantage6.cli.configuration_wizard import NodeConfigurationManager
|
|
8
9
|
from vantage6.cli.node.common import select_node
|
|
9
10
|
|
|
10
11
|
|
|
@@ -15,7 +16,7 @@ from vantage6.cli.node.common import select_node
|
|
|
15
16
|
"--system",
|
|
16
17
|
"system_folders",
|
|
17
18
|
flag_value=True,
|
|
18
|
-
help="Search for configuration in system folders rather than
|
|
19
|
+
help="Search for configuration in system folders rather than user folders",
|
|
19
20
|
)
|
|
20
21
|
@click.option(
|
|
21
22
|
"--user",
|
|
@@ -50,6 +51,8 @@ def cli_node_set_api_key(name: str, api_key: str, system_folders: bool) -> None:
|
|
|
50
51
|
|
|
51
52
|
# set new api key, and save the file
|
|
52
53
|
ctx.config["api_key"] = api_key
|
|
54
|
+
# TODO v5+ this probably messes up the current config as the template is used...
|
|
55
|
+
# Fix when reimplementing this in v5
|
|
53
56
|
conf_mgr.put(ctx.config)
|
|
54
57
|
conf_mgr.save(ctx.config_file)
|
|
55
|
-
info("Your new API key has been uploaded to the config file
|
|
58
|
+
info(f"Your new API key has been uploaded to the config file {ctx.config_file}.")
|
vantage6/cli/node/start.py
CHANGED
|
@@ -77,7 +77,7 @@ def cli_node_start(
|
|
|
77
77
|
|
|
78
78
|
# check that this node is not already running
|
|
79
79
|
running_nodes = docker_client.containers.list(
|
|
80
|
-
filters={"label": f"{APPNAME}-type={InstanceType.NODE}"}
|
|
80
|
+
filters={"label": f"{APPNAME}-type={InstanceType.NODE.value}"}
|
|
81
81
|
)
|
|
82
82
|
|
|
83
83
|
suffix = "system" if system_folders else "user"
|
vantage6/cli/node/stop.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import time
|
|
2
|
+
|
|
2
3
|
import click
|
|
3
|
-
import questionary as q
|
|
4
4
|
import docker
|
|
5
|
-
|
|
5
|
+
import questionary as q
|
|
6
6
|
from colorama import Fore, Style
|
|
7
|
-
from vantage6.cli.context import NodeContext
|
|
8
7
|
|
|
9
|
-
from vantage6.common import
|
|
10
|
-
from vantage6.common.globals import APPNAME
|
|
8
|
+
from vantage6.common import error, info, warning
|
|
11
9
|
from vantage6.common.docker.addons import (
|
|
12
10
|
check_docker_running,
|
|
13
11
|
delete_volume_if_exists,
|
|
14
12
|
get_server_config_name,
|
|
15
13
|
stop_container,
|
|
16
14
|
)
|
|
17
|
-
from vantage6.
|
|
15
|
+
from vantage6.common.globals import APPNAME
|
|
18
16
|
|
|
17
|
+
from vantage6.cli.context import NodeContext
|
|
18
|
+
from vantage6.cli.globals import DEFAULT_NODE_SYSTEM_FOLDERS as N_FOL
|
|
19
19
|
from vantage6.cli.node.common import find_running_node_names
|
|
20
20
|
|
|
21
21
|
|
|
@@ -25,7 +25,7 @@ from vantage6.cli.node.common import find_running_node_names
|
|
|
25
25
|
"--system",
|
|
26
26
|
"system_folders",
|
|
27
27
|
flag_value=True,
|
|
28
|
-
help="Search for configuration in system folders instead of
|
|
28
|
+
help="Search for configuration in system folders instead of user folders",
|
|
29
29
|
)
|
|
30
30
|
@click.option(
|
|
31
31
|
"--user",
|