sailor.utils.config

Provides configuration management for Sailor.

class sailor.utils.config.SailorConfig(asset_central=None, sap_iot=None, predictive_asset_insights=None)[source]

Bases: SailorConfig

Stores the config of Sailor.

count(value, /)

Return number of occurrences of value.

classmethod from_env()[source]

Load config from environment.

Uses SAILOR_CONFIG_JSON in environment. Value needs to be JSON encoded.

classmethod from_yaml(path)[source]

Load config from YAML file.

static get(*keys)[source]

Return a value from the config.

Supports deep lookup if values are dicts.

Example

SailorConfig.get(‘asset_central’, ‘client_id’)

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

static load()[source]

Load config of Sailor from environment or YAML file.

Tries environment first, then YAML file. If there is an error during one attempt the load will fail (no further methods will be tried).

Returns

The loaded config. If load() was called before, returns cached config.

Return type

SailorConfig

asset_central

Alias for field number 0

predictive_asset_insights

Alias for field number 2

sap_iot

Alias for field number 1

sailor.utils.config.try_log(exception, msg)[source]

Run code in try-except clause, logs message when exception is called and re-raises exception.