orangeqs.juice.settings._loading#

Utilities for loading configuration files in OrangeQS Juice.

Module Contents#

Classes#

BaseConfigurable

Base class for a sub schema of a Configurable.

Configurable

Base class for configurations that can be loaded from disk.

Data#

SYSTEM_CONFIG_PATH

Path to the system configuration directory for OrangeQS Juice.

LookupLocations

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.BaseModel

Base class for a sub schema of a Configurable.

Should be used for as a base class for fields of a Configurable class.

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.BaseConfigurable

Base 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 filename class variable defines which files to load, which should be unique across all configurations in an OrangeQS Juice installation.

Examples#

Create a subclass of Configurable to 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/*.toml files 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.