Python Config SDK Reference
AutoblocksConfig
This is the base class your config will inherit from.
name | required | default | description |
---|---|---|---|
value | true | The initial value for the config |
class MyConfigValue(pydantic.BaseModel):
my_val: str
class MyConfig(AutoblocksConfig[MyConfigValue]):
pass
config = MyConfig(
value=MyConfigValue(my_val="initial-val"),
)
# Usage
config.value.my_val
You are not required to use Pydantic, but it is recommended for type safety and validation.
activate_from_remote
Retrieves the value of a remote config and overrides the initial value of the config class.
name | required | default | description |
---|---|---|---|
config | true | The remote config to activate. See RemoteConfig below. | |
parser | true | The function to use when parsing the remote config and setting the value of the config class. | |
api_key | false | AUTOBLOCKS_API_KEY environment variable | Your Autoblocks API key. |
refresh_interval | false | timedelta(seconds=10) | How often to refresh the latest config. Only relevant if the version is set to LATEST . |
refresh_timeout | false | timedelta(seconds=30) | How long to wait for the latest config to refresh before timing out. A refresh timeout will not raise an uncaught exception. An error will be logged and the background refresh process will continue to run at its configured interval. |
activate_timeout | false | timedelta(seconds=30) | How long to wait for the remote config to activate before timing out. |
config.activate_from_remote(
config=RemoteConfig(id="my-remote-config", version="latest"),
parser=MyConfigValue.model_validate
)
RemoteConfig
Used when activating a remote config. Either major and minor version or dangerously_use_undeployed_revision is required.
name | required | default | description |
---|---|---|---|
id | true | The id of the config in Autoblocks. | |
major_version | false | None | A specific config major version such as "1" |
minor_version | false | None | A specific config minor version such as "1" or "latest" |
dangerously_use_undeployed_revision | false | None | Either "latest" or a specific revision such as "cljzx8zhd00077w3sqredd0fz" |
config.activate_from_remote(
config=RemoteConfig(
id="my-remote-config",
major_version="1",
minor_version="latest"
),
parser=MyConfigValue.model_validate
)