7.3. Command line interface#
This page contains the API reference of the functions in the vantage package. This package contains the Command-Line Interface (CLI) of the Vantage6 framework.
7.3.1. Node CLI#
vantage6.cli.node#
7.3.2. Server CLI#
7.3.3. vantage6.cli.context#
The context module in the CLI package contains the definition of the ServerContext and NodeContext classes. These contexts are related to the host system and therefore part of the CLI package.
Both classes are derived from the abstract AppContext class. And provide the node and server with naming conventions, standard file locations, and in the case of the node with a local database URIs.
- Server Context
A class to provide context for the server, both for development mode as for production.
- Node Context
In case the node is run in development mode, this context will also used by the node package. Normally the node uses the vantage6.node.context.DockerNodeContext which provides the same functionality but is tailored to the Docker environment.
- class NodeContext(instance_name, environment='application', system_folders=False, config_file=None)#
Bases:
AppContext
Node context
See DockerNodeContext for the node instance mounts when running as a dockerized service.
- Parameters:
instance_name (str) – Name of the configuration instance, corresponds to the filename of the configuration file.
environment (str, optional) – DTAP environment to be loaded, by default N_ENV
system_folders (bool, optional) – _description_, by default N_FOL
config_file (str, optional) – _description_, by default None
- INST_CONFIG_MANAGER#
alias of
NodeConfigurationManager
- classmethod available_configurations(system_folders=False)#
Find all available server configurations in the default folders.
- Parameters:
system_folders (bool, optional) – System wide or user configuration, by default N_FOL
- Returns:
The first list contains validated configuration files, the second list contains invalid configuration files.
- Return type:
tuple[list, list]
- classmethod config_exists(instance_name, environment='application', system_folders=False)#
Check if a configuration file exists.
- Parameters:
instance_name (str) – Name of the configuration instance, corresponds to the filename of the configuration file.
environment (str, optional) – DTAP environment that needs to be present, by default N_ENV
system_folders (bool, optional) – System wide or user configuration, by default N_FOL
- Returns:
Whether the configuration file exists or not
- Return type:
bool
- property databases: dict#
Dictionary of local databases that are available for this node.
- Returns:
dictionary with database names as keys and their corresponding paths as values.
- Return type:
dict
- property docker_container_name: str#
Docker container name of the node.
- Returns:
Node’s Docker container name
- Return type:
str
- property docker_network_name: str#
Private Docker network name which is unique for this node.
- Returns:
Docker network name
- Return type:
str
- property docker_squid_volume_name: str#
Docker volume in which the SSH configuration is stored.
- Returns:
Docker volume name
- Return type:
str
- property docker_ssh_volume_name: str#
Docker volume in which the SSH configuration is stored.
- Returns:
Docker volume name
- Return type:
str
- docker_temporary_volume_name(run_id)#
Docker volume in which temporary data is stored. Temporary data is linked to a specific run. Multiple algorithm containers can have the same run id, and therefore the share same temporary volume.
- Parameters:
run_id (int) – run id provided by the server
- Returns:
Docker volume name
- Return type:
str
- property docker_volume_name: str#
Docker volume in which task data is stored. In case a file based database is used, this volume contains the database file as well.
- Returns:
Docker volume name
- Return type:
str
- property docker_vpn_volume_name: str#
Docker volume in which the VPN configuration is stored.
- Returns:
Docker volume name
- Return type:
str
- classmethod from_external_config_file(path, environment='application', system_folders=False)#
Create a node context from an external configuration file. External means that the configuration file is not located in the default folders but its location is specified by the user.
- Parameters:
path (str) – Path of the configuration file
environment (str, optional) – DTAP environment to be loaded, by default N_ENV
system_folders (bool, optional) – System wide or user configuration, by default N_FOL
- Returns:
Node context object
- Return type:
- get_database_uri(label='default')#
Obtain the database URI for a specific database.
- Parameters:
label (str, optional) – Database label, by default “default”
- Returns:
URI to the database
- Return type:
str
- static type_data_folder(system_folders=False)#
Obtain OS specific data folder where to store node specific data.
- Parameters:
system_folders (bool, optional) – System wide or user configuration
- Returns:
Path to the data folder
- Return type:
Path
- class ServerContext(instance_name, environment='prod', system_folders=True)#
Bases:
AppContext
Server context
- Parameters:
instance_name (str) – Name of the configuration instance, corresponds to the filename of the configuration file.
environment (str, optional) – DTAP environment to load from the configuration file, by default S_ENV
system_folders (bool, optional) – System wide or user configuration, by default S_FOL
- INST_CONFIG_MANAGER#
alias of
ServerConfigurationManager
- classmethod available_configurations(system_folders=True)#
Find all available server configurations in the default folders.
- Parameters:
system_folders (bool, optional) – System wide or user configuration, by default S_FOL
- Returns:
The first list contains validated configuration files, the second list contains invalid configuration files.
- Return type:
tuple[list, list]
- classmethod config_exists(instance_name, environment='prod', system_folders=True)#
Check if a configuration file exists.
- Parameters:
instance_name (str) – Name of the configuration instance, corresponds to the filename of the configuration file.
environment (str, optional) – DTAP environment that needs to be present, by default S_ENV
system_folders (bool, optional) – System wide or user configuration, by default S_FOL
- Returns:
Whether the configuration file exists or not
- Return type:
bool
- property docker_container_name: str#
Name of the docker container that the server is running in.
- Returns:
Server’s docker container name
- Return type:
str
- classmethod from_external_config_file(path, environment='prod', system_folders=True)#
Create a server context from an external configuration file. External means that the configuration file is not located in the default folders but its location is specified by the user.
- Parameters:
path (str) – Path of the configuration file
environment (str, optional) – DTAP environment to be loaded, by default S_ENV
system_folders (bool, optional) – System wide or user configuration, by default S_FOL
- Returns:
Server context object
- Return type:
- get_database_uri()#
Obtain the database uri from the environment or the configuration. The VANTAGE6_DB_URI environment variable is used by the Docker container, but can also be set by the user.
- Returns:
string representation of the database uri
- Return type:
str
7.3.4. vanatge6.cli.configuration_manager#
- class NodeConfiguration(*args, **kwargs)#
Bases:
Configuration
Stores the node’s configuration and defines a set of node-specific validators.
- class NodeConfigurationManager(name, *args, **kwargs)#
Bases:
ConfigurationManager
Maintains the node’s configuration.
- Parameters:
name (str) – Name of the configuration file.
- classmethod from_file(path)#
Create a new instance of the NodeConfigurationManager from a configuration file.
- Parameters:
path (str) – Path to the configuration file.
- Returns:
A new instance of the NodeConfigurationManager.
- Return type:
- class ServerConfiguration(*args, **kwargs)#
Bases:
Configuration
Stores the server’s configuration and defines a set of server-specific validators.
- class ServerConfigurationManager(name, *args, **kwargs)#
Bases:
ConfigurationManager
Maintains the server’s configuration.
- Parameters:
name (str) – Name of the configuration file.
- classmethod from_file(path)#
Create a new instance of the ServerConfigurationManager from a configuration file.
- Parameters:
path (str) – Path to the configuration file.
- Returns:
A new instance of the ServerConfigurationManager.
- Return type:
- class TestConfiguration(*args, **kwargs)#
Bases:
Configuration
- class TestingConfigurationManager(name, *args, **kwargs)#
Bases:
ConfigurationManager
- classmethod from_file(path)#
Load a configuration from a file.
- Parameters:
path (Path | str) – The path to the file to load the configuration from.
conf_class (Type[Configuration]) – The class to use for the configuration.
- Returns:
The configuration manager with the configuration.
- Return type:
- Raises:
AssertionError – If the name of the configuration could not be extracted from the file path.
7.3.5. vantage6.cli.configuration_wizard#
- configuration_wizard(type_, instance_name, environment, system_folders)#
Create a configuration file for a node or server instance.
- Parameters:
type (str) – Type of the instance. Either “node” or “server”
instance_name (str) – Name of the instance
environment (str) – Name of the environment
system_folders (bool) – Whether to use the system folders or not
- Returns:
Path to the configuration file
- Return type:
Path
- node_configuration_questionaire(dirs, instance_name)#
Questionary to generate a config file for the node instance.
- Parameters:
dirs (dict) – Dictionary with the directories of the node instance.
instance_name (str) – Name of the node instance.
- Returns:
Dictionary with the new node configuration
- Return type:
dict
- select_configuration_questionaire(type_, system_folders)#
Ask which configuration the user wants to use. It shows only configurations that are in the default folder.
- Parameters:
type (str) – Type of the instance. Either “node” or “server”
system_folders (bool) – Whether to use the system folders or not
- Returns:
Name of the configuration and the environment
- Return type:
tuple[str, str]
- server_configuration_questionaire(instance_name)#
Questionary to generate a config file for the node instance.
- Parameters:
instance_name (str) – Name of the node instance.
- Returns:
Dictionary with the new server configuration
- Return type:
dict
7.3.6. vanatge6.cli.rabbitmq.queue_manager#
7.3.7. vanatge6.cli.rabbitmq#
RabbitMQ utilities.
- is_local_address(rabbit_uri)#
Test if the host of a RabbitMQ uri is an external IP address or not
- Parameters:
rabbit_uri (str) – The connection URI to the RabbitMQ service from the configuration
- Returns:
Whether or not the rabbit_uri points to a service to be set up locally
- Return type:
bool
- split_rabbitmq_uri(rabbit_uri)#
Get details (user, pass, host, vhost, port) from a RabbitMQ uri.
- Parameters:
rabbit_uri (str) – URI of RabbitMQ service (‘amqp://$user:$pass@$host:$port/$vhost’)
- Returns:
The vhost defined in the RabbitMQ URI
- Return type:
dict[str]
7.3.8. vantage6.cli.utils#
Utility functions for the CLI
- check_config_name_allowed(name)#
Check if configuration name is allowed
- Parameters:
name (str) – Name to be checked
- Return type:
None
- check_if_docker_daemon_is_running(docker_client)#
Check if Docker daemon is running
- Parameters:
docker_client (docker.DockerClient) – The docker client
- Return type:
None