Handling Configuration#
There are three ways to configure the PrescientClient
:
Set the values inline using the
Settings
object directlyUse a DotEnv file located in the project directory
Set environment variables
1. Set the values inline using the Settings
object#
Note that configuration values set in this way will take precendence over all other methods.
from prescient_sdk.client import PrescientClient
from prescient_sdk.config import Settings
settings = Settings(
prescient_endpoint_url="https://example.server.prescient.earth",
prescient_aws_region="us-west-2",
prescient_aws_role="arn:aws:iam::some:role",
prescient_tenant_id="a-tenant-id",
prescient_client_id="a-client-id",
prescient_auth_url="https://auth-url.com",
prescient_auth_token_path="/path/to/oauth2/token",
)
client = PrescientClient(settings=settings)
2. Use a DotEnv file#
An alternative to the above method is to use a DotEnv file following this format:
PRESCIENT_ENDPOINT_URL="https://example.server.prescient.earth"
PRESCIENT_AWS_REGION="us-west-2"
PRESCIENT_AWS_ROLE="arn:aws:iam::some:role"
PRESCIENT_TENANT_ID="a-tenant-id"
PRESCIENT_CLIENT_ID="a-client-id"
PRESCIENT_AUTH_URL="https://auth-url.com"
PRESCIENT_AUTH_TOKEN_PATH="/path/to/oauth2/token"
Note that in this case, each configuration value is capitalized
# The path to where you store the env_file must be specified
client = PrescientClient(env_file="/path/to/env_file")
3. Use environment variables#
If you set environment variables and use a DotEnv file, each environment variable that is set will override the corresponding value in the DotEnv file.
Environment variables must be capitalized
As an example, if you are using a bash shell, you can set a single variable like so:
export PRESCIENT_ENDPOINT_URL="https://example.server.prescient.earth"
# Environment Variables are read in automatically, so you can just do this:
client = PrescientClient()