Python Config SDK Quick Start

Install

poetry add autoblocksai

Create a config class

You can create a config class by extending AutoblocksConfig and specifying the value type.

import pydantic
from autoblocks.configs.config import AutoblocksConfig

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

Create a remote config

Go to the configs page and click Create Config to create your first config. The config must be valid JSON.

The code samples below are using this example config:

Activate the remote config

Create a single instance of the config class for the lifetime of your application. The only required argument when initializing a config is the default value.

class MyConfigValue(pydantic.BaseModel):
    my_val: str

class MyConfig(AutoblocksConfig[MyConfigValue]):
    pass

config = MyConfig(
    value=MyConfigValue(my_val="initial-val"),
)
config.activate_from_remote(
    config=RemoteConfig(
        id="my-remote-config",
        major_version="1",
        minor_version="latest"
    ),
    parser=MyConfigValue.model_validate
)

# Usage
config.value.my_val

Develop locally against a remote config revision that hasn't been deployed

As you create new revisions in the UI, your private revisions (or revisions that have been shared by your teammates) can be pulled down using dangerously_use_undeployed_revision:

import pydantic
from autoblocks.configs.config import AutoblocksConfig
from autoblocks.configs.models import RemoteConfig

class MyConfigValue(pydantic.BaseModel):
    my_val: str

class MyConfig(AutoblocksConfig[MyConfigValue]):
    pass

config = MyConfig(
    value=MyConfigValue(my_val="initial-val"),
)
config.activate_from_remote(
    config=RemoteConfig(
      id="my-remote-config",
      dangerously_use_undeployed_revision="latest",
    ),
    parser=MyConfigValue.model_validate
)