roboto.config
Module Contents
DEFAULT_ROBOTO_CONFIG_DIR
DEFAULT_ROBOTO_DIR
DEFAULT_ROBOTO_PROFILE_NAME
ROBOTO_API_ENDPOINT
RobotoConfig
Bases: pydantic.BaseModel
RobotoConfig captures an api_key and endpoint required to programmatically interact with Roboto. Multiple profiles can be configured if desired.
Parameters
data AnyAttributes
RobotoConfig.api_key
RobotoConfig.cache_dir
RobotoConfig.default_http_timeout
RobotoConfig.endpoint
RobotoConfig.from_env()
Build a config from the access token in the environment, or else from a profile in the Roboto config file.
A token in ROBOTO_API_KEY or ROBOTO_BEARER_TOKEN takes precedence, and is sent to the endpoint in ROBOTO_SERVICE_ENDPOINT, or to https://api.roboto.ai when that is unset. Without a token, the config comes from the file at ROBOTO_CONFIG_FILE, or ~/.roboto/config.json when that is unset. Either way, ROBOTO_CACHE_DIR and ROBOTO_DEFAULT_HTTP_TIMEOUT, when set, override the profile’s cache_dir and default_http_timeout.
Parameters
profile_override Optional[str]Config file profile to read, ahead of ROBOTO_PROFILE and the file’s default profile.
env Optional[roboto.Roboto environment variables to read. Defaults to the process’s own, through RobotoEnv.default().
Raises
FileNotFoundErrorNo access token is set and the config file doesn’t exist.
OSErrorThe config file exists but can’t be read.
ValueErrorThe config file isn’t a JSON object, or has no usable profile by the chosen name.
Return type
RobotoConfig.get_cache_dir()
Return type
Attributes
RobotoConfig.org_id
Organization to act in when the caller names none and ROBOTO_ORG_ID is unset. The CLI and from_env() read it. Only a member of several organizations needs it. roboto setup saves it to the config file profile; a config built from ROBOTO_API_KEY or ROBOTO_BEARER_TOKEN has none.
RobotoConfigFileProfileV0
Bases: pydantic.BaseModel
V0 Roboto configuration file
Parameters
data AnyAttributes
RobotoConfigFileProfileV0.default_endpoint
RobotoConfigFileProfileV0.to_config()
Return type
Attributes
RobotoConfigFileProfileV0.token
RobotoConfigFileV1
Bases: pydantic.BaseModel
V1 Roboto configuration file
Parameters
data AnyAttributes
RobotoConfigFileV1.default_profile
RobotoConfigFileV1.profiles
RobotoConfigFileV1.validate()
Attributes
RobotoConfigFileV1.version
logger
requested_profile_name()
Return the config file profile named by the caller or by ROBOTO_PROFILE.
RobotoConfig.from_env() reads that profile when one is named.
Parameters
profile_override Optional[str]Profile the caller names, ahead of ROBOTO_PROFILE. An empty value counts as none.
Roboto environment variables, whose ROBOTO_PROFILE applies when profile_override names none.
Returns
The profile’s name, or None when neither names one, which selects the config file’s default profile. ROBOTO_PROFILE set to an empty value names the default profile.
resolve_cache_dir()
Resolve the base directory under which the SDK caches files it fetches from Roboto.
Prefers ROBOTO_CACHE_DIR from env; absent that, the platform-conventional per-user cache directory. ensure_exists applies only to the platform default: when true, resolving it also creates the directory on disk. A directory supplied through ROBOTO_CACHE_DIR is returned as-is and never created here.
Parameters
ensure_exists boolReturn type
resolve_config_file()
Resolve the path of the Roboto config file: ROBOTO_CONFIG_FILE from env, else ~/.roboto/config.json.
The file at the returned path may not exist.
Parameters
Return type
resolved_profile_name()
Return the profile requested names, else the file’s default_profile, else default.
RobotoConfig.from_env() reads this profile, and roboto auth login and roboto setup save a new token to it.
Parameters
requested Optional[str]Profile the caller or ROBOTO_PROFILE names, from requested_profile_name().
default_profile Optional[str]The config file’s default_profile, or None when it names none.
Return type