• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vantage6 / vantage6 / 18191710511

02 Oct 2025 11:30AM UTC coverage: 29.08%. First build
18191710511

Pull #2287

github

web-flow
Merge 3e2880106 into d88a9c354
Pull Request #2287: Change/#1510 and reinstate the dev network commands

17 of 48 new or added lines in 10 files covered. (35.42%)

196 of 674 relevant lines covered (29.08%)

0.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

34.62
/vantage6/vantage6/cli/context/__init__.py
1
"""
2
The context module in the CLI package contains the Context classes of instances
3
started from the CLI, such as nodes and servers. These contexts are related to
4
the host system and therefore part of the CLI package.
5

6
All classes are derived from the abstract AppContext class and provide the
7
vantage6 applications with naming conventions, standard file locations, and
8
more.
9
"""
10

11
from colorama import Fore, Style
1✔
12

13
from vantage6.common import error
1✔
14
from vantage6.common.globals import InstanceType
1✔
15

16
from vantage6.cli.context.algorithm_store import AlgorithmStoreContext
1✔
17
from vantage6.cli.context.auth import AuthContext
1✔
18
from vantage6.cli.context.node import NodeContext
1✔
19
from vantage6.cli.context.server import ServerContext
1✔
20

21

22
def select_context_class(
1✔
23
    type_: InstanceType,
24
) -> ServerContext | NodeContext | AlgorithmStoreContext | AuthContext:
25
    """
26
    Select the context class based on the type of instance.
27

28
    Parameters
29
    ----------
30
    type_ : InstanceType
31
        The type of instance for which the context should be inserted
32

33
    Returns
34
    -------
35
    ServerContext | NodeContext | AlgorithmStoreContext | AuthContext
36
        Specialized subclass of AppContext for the given instance type
37

38
    Raises
39
    ------
40
    NotImplementedError
41
        If the type_ is not implemented
42
    """
43
    if type_ == InstanceType.SERVER:
×
44
        return ServerContext
×
45
    elif type_ == InstanceType.ALGORITHM_STORE:
×
46
        return AlgorithmStoreContext
×
47
    elif type_ == InstanceType.NODE:
×
48
        return NodeContext
×
49
    elif type_ == InstanceType.AUTH:
×
50
        return AuthContext
×
51
    else:
52
        raise NotImplementedError
×
53

54

55
def get_context(
1✔
56
    type_: InstanceType, name: str, system_folders: bool, is_sandbox: bool = False
57
) -> ServerContext | NodeContext | AlgorithmStoreContext:
58
    """
59
    Load the server context from the configuration file.
60

61
    Parameters
62
    ----------
63
    type_ : InstanceType
64
        The type of instance to get the context for
65
    name : str
66
        Name of the instance
67
    system_folders : bool
68
        Wether to use system folders or if False, the user folders
69
    is_sandbox : bool
70
        Whether the configuration is a sandbox configuration, by default False
71
    Returns
72
    -------
73
    AppContext
74
        Specialized subclass context of AppContext for the given instance type
75
    """
76
    ctx_class = select_context_class(type_)
×
NEW
77
    if not ctx_class.config_exists(name, system_folders, is_sandbox=is_sandbox):
×
78
        scope = "system" if system_folders else "user"
×
79
        error(
×
80
            f"Configuration {Fore.RED}{name}{Style.RESET_ALL} does not "
81
            f"exist in the {Fore.RED}{scope}{Style.RESET_ALL} folders!"
82
        )
83
        exit(1)
×
84

85
    # We do not want to log this here, we do this in the container and not on
86
    # the host. We only want CLI logging here.
87
    ctx_class.LOGGING_ENABLED = False
×
88

89
    # create server context, and initialize db
NEW
90
    ctx = ctx_class(name, system_folders=system_folders, is_sandbox=is_sandbox)
×
91

92
    return ctx
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc