orangeqs.juice.settings._loading#
Utilities for loading configuration files in OrangeQS Juice.
Module Contents#
Classes#
Base class for a sub schema of a |
|
Base class for configurations that can be loaded from disk. |
Data#
Path to the system configuration directory for OrangeQS Juice. |
|
API#
- orangeqs.juice.settings._loading.SYSTEM_CONFIG_PATH#
‘/etc/juice/config’
Path to the system configuration directory for OrangeQS Juice.
- orangeqs.juice.settings._loading.LookupLocations#
None
- class orangeqs.juice.settings._loading.BaseConfigurable(/, **data: Any)#
Bases:
pydantic.BaseModelBase class for a sub schema of a
Configurable.Should be used for as a base class for fields of a
Configurableclass.Examples#
class SubConfig(BaseConfigurable): some_setting: str = "default" class MyConfig(Configurable): filename = "my_config" another_setting: int = 42 sub_config: SubConfig
- model_config#
‘ConfigDict(…)’
- class orangeqs.juice.settings._loading.Configurable(/, **data: Any)#
Bases:
orangeqs.juice.settings._loading.BaseConfigurableBase class for configurations that can be loaded from disk.
This method should be subclassed by any model that needs to load its configuration from disk. The
filenameclass variable defines which files to load, which should be unique across all configurations in an OrangeQS Juice installation.Examples#
Create a subclass of
Configurableto define your configuration model:class ExampleConfig(Configurable): filename = "example" some_setting: str = "default_value" another_setting: int = 42 config = ExampleConfig.load() assert config.some_setting == "default_value"
- filename: ClassVar[str]#
None
The unique filename key for this configuration class.
This name is used to look up the configuration files for this model, and will load any file that matches the pattern
<priority>-<filename>.toml. It should be unique across all models in the OrangeQS Juice system.
- classmethod load() Self#
Load the configuration from disk using the specified config key for this model.
This loads configuration files from the two types of sources:
The
/etc/juice/config/folder, which contains configurations by the system administrator.All folders specified in the
"juice.config"entry points of installed OrangeQS Juice extension, which contains configurations by the extension developers. Note that the lab package is also an extension, which is the way for users to configure the OrangeQS Juice installation.
From the above folders it loads all
<filename>.toml,<filename>.d/*.tomlfiles and merges them into a single configuration dictionary. It will merge dictionaries recursively, but will not merge lists. See How configurations are stored and loaded in the Reference guide for details, for example on how to use priority in configuration files.Returns#
(Self): An instance of the model with the loaded configuration.