Configuration

Classes:

Settings([wrapped])

Configuration settings for the Descartes Labs client.

Functions:

get_settings()

An alias for Settings.get_settings()

peek_settings([env, settings_file, ...])

An alias for Settings.peek_settings()

select_env([env, settings_file, envvar_prefix])

An alias for Settings.select_env()

Data:

AWS_ENVIRONMENT

Standard AWS environment

GCP_ENVIRONMENT

Standard GCP environment

class Settings(wrapped=None, **kwargs)[source]

Configuration settings for the Descartes Labs client.

Based on the Dynaconf package. This settings class supports configuration from named “environments” in a settings.toml file as well as environment variables with names that are prefixed with DESCARTESLABS_ (or the prefix specified in the envvar_prefix).

For the full capabilities of Dynaconf please consult https://www.dynaconf.com/.

Note that normally Settings functions entirely automatically within the client. However, it is possible to perform custom initialization programmatically. In order to do this, the beginning of the client program must execute code like this:

from descarteslabs.config import Settings
Settings.select_env(...)

Before importing or otherwise accessing anything else within the descarteslabs package.

handle initialization for the customization cases

Parameters:
  • wrapped – a deepcopy of this object will be wrapped (issue #596)

  • kwargs – values that overrides default_settings

Methods:

get_settings()

Configure and retrieve the current or default settings for the client.

peek_settings([env, settings_file, ...])

Retrieve the settings without configuring the client.

select_env([env, settings_file, envvar_prefix])

Configure the Descartes Labs client.

Attributes:

env

The current client configuration name or None of no environment was selected.

classmethod get_settings()[source]

Configure and retrieve the current or default settings for the client.

Returns:

Returns a Settings instance, a dict-like object containing the configured settings for the client.

Return type:

Settings

Raises:

ConfigError – If no client configuration could be established, or if an invalid configuration name was specified, or if you try to change the client configuration after the client is already configured.

classmethod peek_settings(env=None, settings_file=None, envvar_prefix='DESCARTESLABS')[source]

Retrieve the settings without configuring the client.

Unlike get_settings() and select_env() which both will configure the client, the peek_settings() will not configure the client and Settings.env will not be set.

See select_env() for an explanation of the parameters, return value, and exceptions that can be raised.

classmethod select_env(env=None, settings_file=None, envvar_prefix='DESCARTESLABS')[source]

Configure the Descartes Labs client.

Parameters:
  • env (str, optional) – Name of the environment to configure. Must appear in descarteslabs/config/settings.toml If not supplied will be determined from the DESCARTESLABS_ENV environment variable (or use the prefix specified in the envvar_prefix`_ENV), if set. Otherwise defaults to `aws-production.

  • settings_file (str, optional) – If supplied, will be consulted for additional configuration overrides. These are applied over those in the descarteslabs/config/settings.toml file, but are themselves overwritten by any environment variable settings matching the envvar_prefix.

  • envvar_prefix (str, optional) – Prefix for environment variable names to consult for configuration overrides. Environment variables with a leading prefix of "<envvar_prefix>_" will override the settings in the resulting configuration after the settings file(s) have been consulted.

Returns:

Returns a Settings instance, a dict-like object containing the configured settings for the client.

Return type:

Settings

Raises:

ConfigError – If no client configuration could be established, or if an invalid configuration name was specified, or if you try to change the client configuration after the client is already configured.

env = 'aws-production'

The current client configuration name or None of no environment was selected.

Type:

str

get_settings()

An alias for Settings.get_settings()

peek_settings(env=None, settings_file=None, envvar_prefix='DESCARTESLABS')

An alias for Settings.peek_settings()

select_env(env=None, settings_file=None, envvar_prefix='DESCARTESLABS')

An alias for Settings.select_env()

AWS_ENVIRONMENT = 'aws-production'

Standard AWS environment

GCP_ENVIRONMENT = 'gcp-production'

Standard GCP environment