Skip to content

Config management

This class is accessed via the config property on a CamillaClient instance.

It provides methods for managing the configuration.

class: Config

Bases: _CommandGroup

Collection of methods for configuration management

Source code in camilladsp\config.py
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
class Config(_CommandGroup):
    """
    Collection of methods for configuration management
    """

    def file_path(self) -> Optional[str]:
        """
        Get path to current config file.

        Returns:
            str | None: Path to config file, or None.
        """
        name = self.client.query("GetConfigFilePath")
        return name

    def set_file_path(self, value: str):
        """
        Set path to config file, without loading it.
        Call `reload()` to apply the new config file.

        Args:
            value (str): Path to config file.
        """
        self.client.query("SetConfigFilePath", arg=value)

    def active_raw(self) -> Optional[str]:
        """
        Get the active configuration in raw yaml format (as a string).

        Returns:
            str | None: Current config as a raw yaml string, or None.
        """
        config_string = self.client.query("GetConfig")
        return config_string

    def set_active_raw(self, config_string: str):
        """
        Upload and apply a new configuration in raw yaml format (as a string).

        Args:
            config_string (str): Config as yaml string.
        """
        self.client.query("SetConfig", arg=config_string)

    def active_json(self) -> Optional[str]:
        """
        Get the active configuration in raw json format (as a string).

        Returns:
            str | None: Current config as a raw json string, or None.
        """
        config_string = self.client.query("GetConfigJson")
        return config_string

    def set_active_json(self, config_string: str):
        """
        Upload and apply a new configuration in raw json format (as a string).

        Args:
            config_string (str): Config as json string.
        """
        self.client.query("SetConfigJson", arg=config_string)

    def active(self) -> Optional[Dict]:
        """
        Get the active configuration as a Python object.

        Returns:
            Dict | None: Current config as a Python dict, or None.
        """
        config_string = self.active_raw()
        if config_string is None:
            return None
        config_object = yaml.safe_load(config_string)
        return config_object

    def previous(self) -> Optional[Dict]:
        """
        Get the previously active configuration as a Python object.

        Returns:
            Dict | None: Previous config as a Python dict, or None.
        """
        config_string = self.client.query("GetPreviousConfig")
        config_object = yaml.safe_load(config_string)
        return config_object

    def parse_yaml(self, config_string: str) -> Dict:
        """
        Parse a config from yaml string and return the contents
        as a Python object, with defaults filled out with their default values.

        Args:
            config_string (str): A config as raw yaml string.

        Returns:
            Dict | None: Parsed config as a Python dict.
        """
        config_raw = self.client.query("ReadConfig", arg=config_string)
        config_object = yaml.safe_load(config_raw)
        return config_object

    def read_and_parse_file(self, filename: str) -> Dict:
        """
        Read and parse a config file from disk and return the contents as a Python object.

        Args:
            filename (str): Path to a config file.

        Returns:
            Dict | None: Parsed config as a Python dict.
        """
        config_raw = self.client.query("ReadConfigFile", arg=filename)
        config = yaml.safe_load(config_raw)
        return config

    def set_active(self, config_object: Dict):
        """
        Upload and apply a new configuration from a Python object.

        Args:
            config_object (Dict): A configuration as a Python dict.
        """
        config_raw = yaml.dump(config_object)
        self.set_active_raw(config_raw)

    def validate(self, config_object: Dict) -> Dict:
        """
        Validate a configuration object.
        Returns the validated config with all optional fields filled with defaults.
        Raises a CamillaError on errors.

        Args:
            config_object (Dict): A configuration as a Python dict.

        Returns:
            Dict | None: Validated config as a Python dict.
        """
        config_string = yaml.dump(config_object)
        validated_string = self.client.query("ValidateConfig", arg=config_string)
        validated_object = yaml.safe_load(validated_string)
        return validated_object

    def title(self) -> Optional[str]:
        """
        Get the title of the active configuration.

        Returns:
            str | None: Config title if defined, else None.
        """
        title = self.client.query("GetConfigTitle")
        return title

    def description(self) -> Optional[str]:
        """
        Get the title of the active configuration.

        Returns:
            str | None: Config description if defined, else None.
        """
        desc = self.client.query("GetConfigDescription")
        return desc

active()

Get the active configuration as a Python object.

Returns:

Type Description
Optional[Dict]

Dict | None: Current config as a Python dict, or None.

Source code in camilladsp\config.py
77
78
79
80
81
82
83
84
85
86
87
88
def active(self) -> Optional[Dict]:
    """
    Get the active configuration as a Python object.

    Returns:
        Dict | None: Current config as a Python dict, or None.
    """
    config_string = self.active_raw()
    if config_string is None:
        return None
    config_object = yaml.safe_load(config_string)
    return config_object

active_json()

Get the active configuration in raw json format (as a string).

Returns:

Type Description
Optional[str]

str | None: Current config as a raw json string, or None.

Source code in camilladsp\config.py
58
59
60
61
62
63
64
65
66
def active_json(self) -> Optional[str]:
    """
    Get the active configuration in raw json format (as a string).

    Returns:
        str | None: Current config as a raw json string, or None.
    """
    config_string = self.client.query("GetConfigJson")
    return config_string

active_raw()

Get the active configuration in raw yaml format (as a string).

Returns:

Type Description
Optional[str]

str | None: Current config as a raw yaml string, or None.

Source code in camilladsp\config.py
39
40
41
42
43
44
45
46
47
def active_raw(self) -> Optional[str]:
    """
    Get the active configuration in raw yaml format (as a string).

    Returns:
        str | None: Current config as a raw yaml string, or None.
    """
    config_string = self.client.query("GetConfig")
    return config_string

description()

Get the title of the active configuration.

Returns:

Type Description
Optional[str]

str | None: Config description if defined, else None.

Source code in camilladsp\config.py
167
168
169
170
171
172
173
174
175
def description(self) -> Optional[str]:
    """
    Get the title of the active configuration.

    Returns:
        str | None: Config description if defined, else None.
    """
    desc = self.client.query("GetConfigDescription")
    return desc

file_path()

Get path to current config file.

Returns:

Type Description
Optional[str]

str | None: Path to config file, or None.

Source code in camilladsp\config.py
19
20
21
22
23
24
25
26
27
def file_path(self) -> Optional[str]:
    """
    Get path to current config file.

    Returns:
        str | None: Path to config file, or None.
    """
    name = self.client.query("GetConfigFilePath")
    return name

parse_yaml(config_string)

Parse a config from yaml string and return the contents as a Python object, with defaults filled out with their default values.

Parameters:

Name Type Description Default
config_string str

A config as raw yaml string.

required

Returns:

Type Description
Dict

Dict | None: Parsed config as a Python dict.

Source code in camilladsp\config.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def parse_yaml(self, config_string: str) -> Dict:
    """
    Parse a config from yaml string and return the contents
    as a Python object, with defaults filled out with their default values.

    Args:
        config_string (str): A config as raw yaml string.

    Returns:
        Dict | None: Parsed config as a Python dict.
    """
    config_raw = self.client.query("ReadConfig", arg=config_string)
    config_object = yaml.safe_load(config_raw)
    return config_object

previous()

Get the previously active configuration as a Python object.

Returns:

Type Description
Optional[Dict]

Dict | None: Previous config as a Python dict, or None.

Source code in camilladsp\config.py
90
91
92
93
94
95
96
97
98
99
def previous(self) -> Optional[Dict]:
    """
    Get the previously active configuration as a Python object.

    Returns:
        Dict | None: Previous config as a Python dict, or None.
    """
    config_string = self.client.query("GetPreviousConfig")
    config_object = yaml.safe_load(config_string)
    return config_object

read_and_parse_file(filename)

Read and parse a config file from disk and return the contents as a Python object.

Parameters:

Name Type Description Default
filename str

Path to a config file.

required

Returns:

Type Description
Dict

Dict | None: Parsed config as a Python dict.

Source code in camilladsp\config.py
116
117
118
119
120
121
122
123
124
125
126
127
128
def read_and_parse_file(self, filename: str) -> Dict:
    """
    Read and parse a config file from disk and return the contents as a Python object.

    Args:
        filename (str): Path to a config file.

    Returns:
        Dict | None: Parsed config as a Python dict.
    """
    config_raw = self.client.query("ReadConfigFile", arg=filename)
    config = yaml.safe_load(config_raw)
    return config

set_active(config_object)

Upload and apply a new configuration from a Python object.

Parameters:

Name Type Description Default
config_object Dict

A configuration as a Python dict.

required
Source code in camilladsp\config.py
130
131
132
133
134
135
136
137
138
def set_active(self, config_object: Dict):
    """
    Upload and apply a new configuration from a Python object.

    Args:
        config_object (Dict): A configuration as a Python dict.
    """
    config_raw = yaml.dump(config_object)
    self.set_active_raw(config_raw)

set_active_json(config_string)

Upload and apply a new configuration in raw json format (as a string).

Parameters:

Name Type Description Default
config_string str

Config as json string.

required
Source code in camilladsp\config.py
68
69
70
71
72
73
74
75
def set_active_json(self, config_string: str):
    """
    Upload and apply a new configuration in raw json format (as a string).

    Args:
        config_string (str): Config as json string.
    """
    self.client.query("SetConfigJson", arg=config_string)

set_active_raw(config_string)

Upload and apply a new configuration in raw yaml format (as a string).

Parameters:

Name Type Description Default
config_string str

Config as yaml string.

required
Source code in camilladsp\config.py
49
50
51
52
53
54
55
56
def set_active_raw(self, config_string: str):
    """
    Upload and apply a new configuration in raw yaml format (as a string).

    Args:
        config_string (str): Config as yaml string.
    """
    self.client.query("SetConfig", arg=config_string)

set_file_path(value)

Set path to config file, without loading it. Call reload() to apply the new config file.

Parameters:

Name Type Description Default
value str

Path to config file.

required
Source code in camilladsp\config.py
29
30
31
32
33
34
35
36
37
def set_file_path(self, value: str):
    """
    Set path to config file, without loading it.
    Call `reload()` to apply the new config file.

    Args:
        value (str): Path to config file.
    """
    self.client.query("SetConfigFilePath", arg=value)

title()

Get the title of the active configuration.

Returns:

Type Description
Optional[str]

str | None: Config title if defined, else None.

Source code in camilladsp\config.py
157
158
159
160
161
162
163
164
165
def title(self) -> Optional[str]:
    """
    Get the title of the active configuration.

    Returns:
        str | None: Config title if defined, else None.
    """
    title = self.client.query("GetConfigTitle")
    return title

validate(config_object)

Validate a configuration object. Returns the validated config with all optional fields filled with defaults. Raises a CamillaError on errors.

Parameters:

Name Type Description Default
config_object Dict

A configuration as a Python dict.

required

Returns:

Type Description
Dict

Dict | None: Validated config as a Python dict.

Source code in camilladsp\config.py
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
def validate(self, config_object: Dict) -> Dict:
    """
    Validate a configuration object.
    Returns the validated config with all optional fields filled with defaults.
    Raises a CamillaError on errors.

    Args:
        config_object (Dict): A configuration as a Python dict.

    Returns:
        Dict | None: Validated config as a Python dict.
    """
    config_string = yaml.dump(config_object)
    validated_string = self.client.query("ValidateConfig", arg=config_string)
    validated_object = yaml.safe_load(validated_string)
    return validated_object