Client Config
- class gretel_client.config.ClientConfig(endpoint: str | None = None, artifact_endpoint: str | None = None, api_key: str | None = None, default_project_name: str | None = None, default_runner: str | RunnerMode = 'cloud', preview_features: str = 'disabled')
Holds Gretel client configuration details. This can be instantiated from a file or environment.
- api_key: str | None = None
Gretel API key.
- artifact_endpoint: str
Artifact endpoint.
- default_project_name: str | None = None
Default Gretel project name.
- default_runner: str = 'cloud'
Default runner
- endpoint: str
Gretel API endpoint.
- get_api(api_interface: Type[T], max_retry_attempts: int = 5, backoff_factor: float = 1) T
Instantiates and configures an api client for a given component interface.
- Parameters:
api_interface – The api interface to instantiate
max_retry_attempts – The number of times to retry a failed api request.
backoff_factor – A back factor to apply between retry attempts. A base factor of 2 will applied to this value to determine the time between attempts.
- property masked: dict
Returns a masked representation of the config object.
- preview_features: str = 'disabled'
Preview features enabled
- update_default_project(project_id: str)
Updates the default project.
- Parameters:
project_name – The name or id of the project to set.
- gretel_client.config.DEFAULT_GRETEL_ARTIFACT_ENDPOINT = 'cloud'
Default artifact endpoint
- gretel_client.config.DEFAULT_GRETEL_ENDPOINT = 'https://api.gretel.cloud'
Default gretel endpoint
- gretel_client.config.GRETEL = 'gretel'
Gretel application name
- gretel_client.config.GRETEL_API_KEY = 'GRETEL_API_KEY'
Env variable to configure Gretel api key.
- gretel_client.config.GRETEL_ARTIFACT_ENDPOINT = 'GRETEL_ARTIFACT_ENDPOINT'
Env variable name to configure artifact endpoint. Defaults to DEFAULT_GRETEL_ARTIFACT_ENDPOINT.
- gretel_client.config.GRETEL_CONFIG_FILE = 'GRETEL_CONFIG_FILE'
Env variable name to override default configuration file location
- gretel_client.config.GRETEL_ENDPOINT = 'GRETEL_ENDPOINT'
Env variable name to configure default Gretel endpoint. Defaults to DEFAULT_GRETEL_ENDPOINT.
- gretel_client.config.GRETEL_PREVIEW_FEATURES = 'GRETEL_PREVIEW_FEATURES'
Env variable to manage preview features
- gretel_client.config.GRETEL_PROJECT = 'GRETEL_PROJECT'
Env variable name to select default project
- gretel_client.config.GRETEL_RUNNER_MODE = 'GRETEL_RUNNER_MODE'
Env variable name to set the default runner mode
- class gretel_client.config.GretelApiRetry(*args, **kwargs)
Custom retry logic for calling Gretel Cloud APIs.
- increment(method=None, url=None, response=None, error=None, _pool=None, _stacktrace=None)
Return a new Retry object with incremented retry counters.
- Parameters:
response (
HTTPResponse
) – A response object, or None, if the server did not return a response.error (Exception) – An error encountered during the request, or None if the response was received successfully.
- Returns:
A new
Retry
object.
- exception gretel_client.config.GretelClientConfigurationError
- class gretel_client.config.PreviewFeatures(value)
Manage preview feature configurations
- class gretel_client.config.RunnerMode(value)
An enumeration.
- gretel_client.config.clear_gretel_config()
Removes any Gretel configuration files from the host file system.
If any Gretel related environment variables exist, this will also remove them from the current processes.
- gretel_client.config.configure_session(config: str | ClientConfig | None = None, *, api_key: str | None = None, default_runner: str | RunnerMode | None = None, endpoint: str | None = None, artifact_endpoint: str | None = None, cache: str = 'no', validate: bool = False, clear: bool = False)
Updates client config for the session
- Parameters:
config – The config to update. This config takes precedence over other parameters such as
api_key
orendpoint
.api_key – Configures your Gretel API key. If
api_key
is set to “prompt” and no Api Key is found on the system,getpass
will be used to prompt for the key.default_runner – Specifies the runner mode. Must be one of “cloud”, “local”, “manual”, or “hybrid”.
endpoint – Specifies the Gretel API endpoint. This must be a fully qualified URL.
artifact_endpoint – Specifies the endpoint for project and model artifacts.
cache – Valid options include “yes” and “no”. If cache is “no” the session configuration will not be written to disk. If cache is “yes”, session configuration will be written to disk only if a configuration doesn’t exist.
validate – If set to
True
this will check that login credentials are valid.clear – If set to
True
any existing Gretel credentials will be removed from the host.
- Raises:
GretelClientConfigurationError` if validate=True and credential – are invalid.
- gretel_client.config.get_session_config() ClientConfig
Return the session’s client config
- gretel_client.config.write_config(config: ClientConfig, config_path: str | Path | None = None) Path
Writes a Gretel client config to disk.
- Parameters:
config – The client config to write
config_path – Path to write the config to. If not path is provided, the default
$HOME/.gretel/config.json
path is used.