• 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

71.88
/vantage6/vantage6/cli/context/server.py
1
from __future__ import annotations
1✔
2

3
from pathlib import Path
1✔
4

5
from vantage6.common.globals import APPNAME, InstanceType
1✔
6

7
from vantage6.cli import __version__
1✔
8
from vantage6.cli.configuration_manager import ServerConfigurationManager
1✔
9
from vantage6.cli.context.base_server import BaseServerContext
1✔
10
from vantage6.cli.globals import (
1✔
11
    DEFAULT_SERVER_SYSTEM_FOLDERS as S_FOL,
12
    PROMETHEUS_DIR,
13
    ServerType,
14
)
15

16

17
class ServerContext(BaseServerContext):
1✔
18
    """
19
    Server context
20

21
    Parameters
22
    ----------
23
    instance_name : str
24
        Name of the configuration instance, corresponds to the filename
25
        of the configuration file.
26
    system_folders : bool, optional
27
        System wide or user configuration, by default S_FOL
28
    """
29

30
    # The server configuration manager is aware of the structure of the server
31
    # configuration file and makes sure only valid configuration can be loaded.
32
    INST_CONFIG_MANAGER = ServerConfigurationManager
1✔
33

34
    def __init__(
1✔
35
        self,
36
        instance_name: str,
37
        system_folders: bool = S_FOL,
38
        in_container: bool = False,
39
        is_sandbox: bool = False,
40
    ):
41
        super().__init__(
×
42
            InstanceType.SERVER,
43
            instance_name,
44
            system_folders=system_folders,
45
            in_container=in_container,
46
            is_sandbox=is_sandbox,
47
        )
48
        self.log.info("vantage6 version '%s'", __version__)
×
49

50
    def get_database_uri(self) -> str:
1✔
51
        """
52
        Obtain the database uri from the environment or the configuration.
53

54
        Returns
55
        -------
56
        str
57
            string representation of the database uri
58
        """
59
        return super().get_database_uri()
×
60

61
    @property
1✔
62
    def docker_container_name(self) -> str:
1✔
63
        """
64
        Name of the docker container that the server is running in.
65

66
        Returns
67
        -------
68
        str
69
            Server's docker container name
70
        """
71
        return f"{APPNAME}-{self.name}-{self.scope}-{ServerType.V6SERVER.value}"
×
72

73
    @property
1✔
74
    def prometheus_container_name(self) -> str:
1✔
75
        """
76
        Get the name of the Prometheus Docker container for this server.
77

78
        Returns
79
        -------
80
        str
81
            Prometheus container name, unique to this server instance.
82
        """
83
        return f"{APPNAME}-{self.name}-{self.scope}-prometheus"
×
84

85
    @property
1✔
86
    def prometheus_dir(self) -> Path:
1✔
87
        """
88
        Get the Prometheus directory path.
89

90
        Returns
91
        -------
92
        Path
93
            Path to the Prometheus directory
94
        """
95
        return self.data_dir / PROMETHEUS_DIR
×
96

97
    @classmethod
1✔
98
    def from_external_config_file(
1✔
99
        cls, path: str, system_folders: bool = S_FOL, in_container: bool = False
100
    ) -> ServerContext:
101
        """
102
        Create a server context from an external configuration file. External
103
        means that the configuration file is not located in the default folders
104
        but its location is specified by the user.
105

106
        Parameters
107
        ----------
108
        path : str
109
            Path of the configuration file
110
        system_folders : bool, optional
111
            System wide or user configuration, by default S_FOL
112
        in_container : bool, optional
113
            Whether the application is running inside a container, by default False
114

115
        Returns
116
        -------
117
        ServerContext
118
            Server context object
119
        """
120
        return super().from_external_config_file(
×
121
            path,
122
            ServerType.V6SERVER,
123
            system_folders,
124
            in_container,
125
        )
126

127
    @classmethod
1✔
128
    def config_exists(
1✔
129
        cls, instance_name: str, system_folders: bool = S_FOL, is_sandbox: bool = False
130
    ) -> bool:
131
        """
132
        Check if a configuration file exists.
133

134
        Parameters
135
        ----------
136
        instance_name : str
137
            Name of the configuration instance, corresponds to the filename
138
            of the configuration file.
139
        system_folders : bool, optional
140
            System wide or user configuration, by default S_FOL
141
        is_sandbox : bool, optional
142
            Whether the configuration is a sandbox configuration, by default False
143
        Returns
144
        -------
145
        bool
146
            Whether the configuration file exists or not
147
        """
148
        return super().config_exists(
×
149
            InstanceType.SERVER,
150
            instance_name,
151
            system_folders=system_folders,
152
            is_sandbox=is_sandbox,
153
        )
154

155
    @classmethod
1✔
156
    def available_configurations(
1✔
157
        cls, system_folders: bool = S_FOL, is_sandbox: bool = False
158
    ) -> tuple[list, list]:
159
        """
160
        Find all available server configurations in the default folders.
161

162
        Parameters
163
        ----------
164
        system_folders : bool, optional
165
            System wide or user configuration, by default S_FOL
166
        is_sandbox : bool, optional
167
            Whether the configuration is a sandbox configuration, by default False
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
        """
NEW
175
        return super().available_configurations(
×
176
            InstanceType.SERVER, system_folders, is_sandbox
177
        )
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