Skip to content

Configuration Store

Description

Handles the functionality for the loading a configuration file for the python portion of the tool chain. The configuration is stored as a YAML file with the following structure:

  • faktory-connection-info: Information for connecting to a Faktory instance.
    • port: The port the Faktory instance can be found on.
    • domain: The domain the Faktory instance can be found at.
  • db-connection-info: Information for connecting to a MongoDB instance.
    • domain: The domain the MongoDB instance can be found at.
    • port: The port the MongoDB instance can be found on.
    • user: The user to authenticate with against the MongoDB instance.
    • password: The password for the user.
    • database: The database to connect to in the MongoDB instance.
  • tangle-collections: The collection information in the MongoDB database for the tangles.
    • stencil_col_name: The name of the collection of stencils.
    • col_name: The name of the collection of tangles
    • page_size: The number of tangles in a page.

Implementation

runner.config_store

Holds and loads the configuration for the server.

cfg_dict module-attribute

cfg_dict

load

load(path)

Load configuration from file.

Parameters:

Name Type Description Default
path Path

Path to the configuration file.

required

Raises:

Type Description
NameError

Configuration file failed to load.

Source code in runner/config_store.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def load(path: Path):
    """Load configuration from file.

    Args:
        path: Path to the configuration file.

    Raises:
        NameError: Configuration file failed to load.
    """
    global cfg_dict
    path = Path.cwd() / path
    cfg_dict = dict()
    try:
        with open(path) as f:
            cfg_dict.update(yaml.load(f, Loader=yaml.FullLoader))
    except Exception:
        raise NameError(
            'config load error'
        ) from None  # @@@IMPROVEMENT: needs to be updated to exception object