EarthScope SDK Settings#
EarthScope SDK Settings consist of configuration & tokens.
Configuration is used to control behavior of the SDK.
Tokens are used to authenticate and authorize requests made by this SDK.
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#
Field |
Environment Variable |
Description |
|---|---|---|
|
|
a named configuration profile |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Oauth2 Settings#
Field |
Environment Variable |
Description |
|---|---|---|
|
|
oauth2 audience targeted |
|
|
oauth2 Client ID used when requesting tokens |
|
|
oauth2 Client Secret used for machine-to-machine auth |
|
|
oauth2 domain for Identity Provider |
|
|
oauth2 scope requested during token retrieval |
|
|
oauth2 access token to use to authenticate with the API |
|
|
oauth2 refresh token used to retrieve new access tokens |
|
|
OIDC token |
|
|
Your access token is automatically sent when requests are made to these hosts. Supports glob-style strings with |
|
|
oauth2 retry configuration |
Dropoff Settings#
The EarthScope SDK’s S3 upload behavior can be modified to better suit your upload bandwidth.
Field |
Environment Variable |
Default |
Description |
|---|---|---|---|
|
|
The S3 bucket to upload to. |
|
|
|
A Dropoff category may be configured via settings to avoid specifying the category on each call to |
|
|
|
10 MB |
Size (in bytes) of each multipart upload part sent to S3. Larger parts mean fewer upload requests but higher memory use. |
|
|
8 |
Maximum number of parts that will be uploaded in parallel (across multiple objects). |
|
|
3 |
Maximum number of objects that will be uploaded in parallel. |
|
|
S3 part upload retry configuration |
HTTP Client Settings#
Configuration for the HTTPx client & connection pool.
Field |
Environment Variable |
Description |
|---|---|---|
|
|
Additional arbitrary headers to inject into requests |
|
|
The user agent injected into HTTP requests. This value supersedes a |
|
|
HTTP connect timeout (seconds) |
|
|
HTTP read/write timeout (seconds) |
|
|
Time limit on idle keep-alive connections (seconds) |
|
|
The maximum number of concurrent connections that may be established |
|
|
Allow the connection pool to maintain keep-alive connections below this point. Should be less than or equal to |
|
|
HTTP request rate limit configuration. |
|
|
HTTP request retry configuration. |
Query Plan Settings#
Field |
Environment Variable |
Description |
|---|---|---|
|
|
Memory limit for query plan execution in bytes. If not set, no limit is enforced. Can be overridden per query. |
|
|
Timeout for query plan execution in seconds. If not set, no timeout is enforced. Can be overridden per query. |
Warning
See Safety Limits: Memory & Timeout for details on when and why to configure limits.
Rate Limit Settings#
Field |
Environment Variable |
Description |
|---|---|---|
|
|
Maximum number of concurrent requests |
|
|
Maximum number of requests per second |
Retry Settings#
Field |
Environment Variable |
Description |
|---|---|---|
|
|
Maximum total number of attempts to perform when retryable errors occur. |
|
|
Maximum total time for all retries when retryable errors occur. |
|
|
Minimum backoff before the first retry. |
|
|
Maximum backoff time between retries at any time. |
|
|
Maximum jitter that is added to retry back-off delays (the actual jitter added is a random number between 0 and wait_jitter) |
|
|
The exponential base used to compute the retry backoff. |
Resource References#
References to EarthScope resources.
Field |
Environment Variable |
Description |
|---|---|---|
|
|
the URL for EarthScope’s API |
Settings Loading#
SDK Settings are provided via the following methods (in order of precedence):
initialization arguments (e.g. via class constructors)
environment variables
dotenv file (.env) variables
user’s home directory settings files
~/.earthscope/config.toml(for configuration)~/.earthscope/<profile-name>/tokens.json(for tokens)
legacy EarthScope CLI v0 credentials
bootstrapping environment: the environment variable
ES_BOOTSTRAP_SETTINGSmay contain a JSON string with any settings in the structure detailed abovedefault 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.
Mac OS:
~/.earthscope/Unix:
~/.earthscope/Windows:
C:\Users\<user>\.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.