Source code for q2_sdk.hq.models.db_config.db_dynamic_config

from typing import Callable, TypeVar
from q2_sdk.hq.models.db_config.db_config import DbConfig


T = TypeVar("T")


[docs] class DbDynamicConfig(DbConfig[T]): """ Variant of DbConfig that allows passing in a function as the default value. This value will be resolved at install time. """ def __init__(self, name, default: Callable[[], T], description=None, required=True): """ :param name: Key written to the database :param default: A function that resolves to your desired default value at install time :param required: If True, will raise errors at runtime when unset. Consider using False when DbConfigs are added to an already deployed extension """ _default = default() super().__init__(name, _default, description, required)