Configuration

The Descartes Labs Python Client can be configured to operate against different platforms and environments.

Environments

The client supports multiple configuration “environments”. The primary environment and the default for using the AWS based Enterprise Accelerator is aws-production, a.k.a. AWS_ENVIRONMENT. The environment selects not only the client mode (what packages are available in the client) but also the appropriate URLs used by the client to access the Descartes Labs backend services.

There are two mechanisms by which the selection of the environment described above can be overridden.

If the DESCARTESLABS_ENV environment variable is defined when the descarteslabs module (or any submodule) is imported, it will be used to determine the target environment. It should be set to an environment name such as aws-production as appropriate. This is typically how one would configure the client when invoked from an execution environment set up by the user (for example, AWS Lambda or a Kubernetes workload or other container).

Alternatively, the configuration can be selected at runtime as long as this is done before importing any of the client modules. For this purpose, only three submodules are made available to use prior to and for the purpose of configuring the client: descarteslabs.auth, descarteslabs.config and descarteslabs.exceptions. Importing any other submodule of descarteslabs will trigger automatical configuration, and it will then no longer be possible to configure the client explicitly.

Here is an example of how to configure the client explicitly:

import descarteslabs as dl
dl.select_env(dl.AWS_ENVIRONMENT)

print(f"Using Descartes Labs environment {dl.get_settings().env}")

# now you can import or access anything else from descarteslabs
dl.catalog.Product.search(...)

Settings

The Settings class provides the API for configuration. The current configuration settings are accessible via the get_settings() accesor method. Among other properties, the following may be most useful to the user:

# the currently configured environment
dl.get_settings().env

# True if in AWS mode:
dl.get_settings().aws_client

Please consult the Configuration API documentation for futher information.