Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

EarthScope SDK Settings consist of configuration & tokens.

This document details the settings available, and a specification for settings fields, loading, and persistence on the user’s machine.

Note: if you don’t need to make any configuration changes (the most common use case!) then you don’t need to do anything and this page can be ignored.

Settings Fields

Configuration

FieldEnvironment VariableDescription
profile_nameES_PROFILEa named configuration profile
dropoff.*ES_DROPOFF__*Data dropoff configuration
http.*ES_HTTP__*HTTP client configuration
oauth2.*ES_OAUTH2__*oauth2 flow configuration
query_plan.*ES_QUERY_PLAN__*query plan configuration
resources.*ES_RESOURCES__*EarthScope resource references

Oauth2 Settings

FieldEnvironment VariableDescription
oauth2.audienceES_OAUTH2__AUDIENCEoauth2 audience targeted
oauth2.client_idES_OAUTH2__CLIENT_IDoauth2 Client ID used when requesting tokens
oauth2.client_secretES_OAUTH2__CLIENT_SECREToauth2 Client Secret used for machine-to-machine auth
oauth2.domainES_OAUTH2__DOMAINoauth2 domain for Identity Provider
oauth2.scopeES_OAUTH2__SCOPEoauth2 scope requested during token retrieval
oauth2.access_tokenES_OAUTH2__ACCESS_TOKENoauth2 access token to use to authenticate with the API
oauth2.refresh_tokenES_OAUTH2__REFRESH_TOKENoauth2 refresh token used to retrieve new access tokens
oauth2.id_tokenES_OAUTH2__ID_TOKENOIDC token
oauth2.allowed_hostsES_OAUTH2__ALLOWED_HOSTSYour access token is automatically sent when requests are made to these hosts. Supports glob-style strings with ? and * characters.
oauth2.retry.*ES_OAUTH2__RETRY__*oauth2 retry configuration

Dropoff Settings

The EarthScope SDK’s S3 upload behavior can be modified to better suit your upload bandwidth.

FieldEnvironment VariableDefaultDescription
dropoff.bucketES_DROPOFF__BUCKETThe S3 bucket to upload to.
dropoff.categoryES_DROPOFF__CATEGORYA Dropoff category may be configured via settings to avoid specifying the category on each call to put_object().
dropoff.part_sizeES_DROPOFF__PART_SIZE10 MBSize (in bytes) of each multipart upload part sent to S3. Larger parts mean fewer upload requests but higher memory use.
dropoff.part_concurrencyES_DROPOFF__PART_CONCURRENCY8Maximum number of parts that will be uploaded in parallel (across multiple objects).
dropoff.object_concurrencyES_DROPOFF__OBJECT_CONCURRENCY3Maximum number of objects that will be uploaded in parallel.
dropoff.retry.*ES_DROPOFF__RETRY__*S3 part upload retry configuration

HTTP Client Settings

Configuration for the HTTPx client & connection pool.

FieldEnvironment VariableDescription
http.extra_headersES_HTTP__EXTRA_HEADERSAdditional arbitrary headers to inject into requests
http.user_agentES_HTTP__USER_AGENTThe user agent injected into HTTP requests. This value supersedes a user-agent header passed via http.extra_headers.
http.timeout_connectES_HTTP__TIMEOUT_CONNECTHTTP connect timeout (seconds)
http.timeout_readES_HTTP__TIMEOUT_READHTTP read/write timeout (seconds)
http.keepalive_expiryES_HTTP__KEEPALIVE_EXPIRYTime limit on idle keep-alive connections (seconds)
http.max_connectionsES_HTTP__MAX_CONNECTIONSThe maximum number of concurrent connections that may be established
http.max_keepalive_connectionsES_HTTP__MAX_KEEPALIVE_CONNECTIONSAllow the connection pool to maintain keep-alive connections below this point. Should be less than or equal to max_connections.
http.rate_limit.*ES_HTTP__RATE_LIMIT__*HTTP request rate limit configuration.
http.retry.*ES_HTTP__RETRY__*HTTP request retry configuration.

Query Plan Settings

FieldEnvironment VariableDescription
query_plan.memory_limit_bytesES_QUERY_PLAN__MEMORY_LIMIT_BYTESMemory limit for query plan execution in bytes. If not set, no limit is enforced. Can be overridden per query.
query_plan.timeout_secondsES_QUERY_PLAN__TIMEOUT_SECONDSTimeout for query plan execution in seconds. If not set, no timeout is enforced. Can be overridden per query.

Rate Limit Settings

FieldEnvironment VariableDescription
max_concurrent*__MAX_CONCURRENTMaximum number of concurrent requests
max_per_second*__MAX_PER_SECONDMaximum number of requests per second

Retry Settings

FieldEnvironment VariableDescription
attempts*__ATTEMPTSMaximum total number of attempts to perform when retryable errors occur.
timeout*__TIMEOUTMaximum total time for all retries when retryable errors occur.
wait_initial*__WAIT_INITIALMinimum backoff before the first retry.
wait_max*__WAIT_MAXMaximum backoff time between retries at any time.
wait_jitter*__WAIT_JITTERMaximum jitter that is added to retry back-off delays (the actual jitter added is a random number between 0 and wait_jitter)
wait_exp_base*__WAIT_EXP_BASEThe exponential base used to compute the retry backoff.

Resource References

References to EarthScope resources.

FieldEnvironment VariableDescription
resources.api_urlES_RESOURCES__API_URLthe URL for EarthScope’s API

Settings Loading

SDK Settings are provided via the following methods (in order of precedence):

  1. initialization arguments (e.g. via class constructors)

  2. environment variables

  3. dotenv file (.env) variables

  4. user’s home directory settings files

    1. ~/.earthscope/config.toml (for configuration)

    2. ~/.earthscope/<profile-name>/tokens.json (for tokens)

  5. legacy EarthScope CLI v0 credentials

  6. bootstrapping environment: the environment variable ES_BOOTSTRAP_SETTINGS may contain a JSON string with any settings in the structure detailed above

  7. default settings

SDK configuration is managed by the SdkSettings class, and calling the constructor performs this settings loading chain.

from earthscope_sdk.config.settings import SdkSettings

settings = SdkSettings()  # loads settings via loading chain

Initialization Arguments

Arguments to the SdkSettings class constructor take the highest precedence.

For example, the following will configure a custom oauth2 scope to request from the Identity Provider.

from earthscope_sdk.config.settings import SdkSettings

settings = SdkSettings(
  oauth2={"scope": "custom-scope"}
)

Environment Variables

Environment variables are a convenient way of configuring the SDK. The various settings are available with an ES_ prefix, as detailed in the tables above.

For example, the following will configure a custom oauth2 scope to request from the Identity Provider.

export ES_OAUTH2__SCOPE="custom-scope"

Settings Files

EarthScope SDK settings files live in the user’s home directory in a “hidden” directory called .earthscope.

Configuration File

This file is completely optional.

Location: ~/.earthscope/config.toml

The EarthScope SDK can manage tokens for multiple named “profiles”. Profiles are used to manage multiple sets of tokens for interacting with different APIs, or the same API with different tokens.

You use config.toml to enumerate different profiles, and (optionally) unique configuration for each profile.

# ~/.earthscope/config.toml

# (optional) the `default` block contains fallback configuration for _all_ profiles
[default]
oauth2.scope = "default-custom-scope"
# ...etc (all configuration fields are available)

# (optional) `profile.<name>` block(s) define named configuration profile(s)
[profile.foo]
oauth2.scope = "profile-specific-custom-scope"
# ...etc (all configuration fields are available)

Tokens File(s)

Tokens for individual profiles are stored in their own JSON files:

Location: ~/.earthscope/<profile_name>/tokens.json

The SDK automatically manages these tokens.json files for you. You never need to manually create or edit these files.

{
  "access_token": "<access-token>", // oauth2 Access Token
  "id_token": "<id-token>", // (optional) oauth2 ID Token
  "refresh_token": "<refresh-token>" // (optional) oauth2 Refresh Token
}

Legacy EarthScope CLI v0 Credentials

The first version of the EarthScope CLI (v0) persisted tokens in a different location and with a different structure. To make upgrading from v0 to v1+ easier, the SDK will look for tokens in the legacy location.

Bootstrapping Environment Settings

Compute environments such as GeoLab may inject bootstrapping settings via the special ES_BOOTSTRAP_SETTINGS environment variable.

export ES_BOOTSTRAP_SETTINGS='{"oauth2": {"scope": "bootstrap-scope"}}'

Settings provided in this manner are superseded by all settings providers detailed above. This allows the compute environment (e.g. GeoLab) to inject configuration that may be overridden by users.

Default Settings

The SDK itself provides default values for all configuration fields. These default values are used as a last resort for any field that does not receive a higher-precedence value through the settings loading chain.

These defaults work out of the box for the primary use case of interacting with https://api.earthscope.org.