sqlmesh
sqlmesh copied to clipboard
SQLMESH__AIRFLOW__DISABLE_STATE_MIGRATION var is considered as an input for Config
Got this error when I disabled sqlmesh state migration using this env var SQLMESH__AIRFLOW__DISABLE_STATE_MIGRATION
pydantic_core._pydantic_core.ValidationError: 1 validation error for Config
Extra inputs are not permitted [type=extra_forbidden, input_value={'disable_state_migration': '1'}, input_type=dict]
I guess we should either rename the SQLMESH__AIRFLOW__DISABLE_STATE_MIGRATION env var or tweak the load_config_from_env function to ignore this variable.
Also I think its good to provide an option to set load_from_env as False when we create sqlmesh context object.
@tobymao, is it okay if I create a PR to ignore SQLMESH__AIRFLOW__DISABLE_STATE_MIGRATION when we load configs from env using load_config_from_env function? or please let me know if you've anything else in your mind. Thanks :)
def load_config_from_env() -> t.Dict[str, t.Any]:
config_dict: t.Dict[str, t.Any] = {}
for key, value in os.environ.items():
key = key.lower()
# TODO DISABLE_STATE_MIGRATION_KEY will be stored in constants
DISABLE_STATE_MIGRATION_KEY = "sqlmesh__airflow__disable_state_migration"
if key.startswith(f"{c.SQLMESH}__") and key != DISABLE_STATE_MIGRATION_KEY:
segments = key.split("__")[1:]
if not segments or not segments[-1]:
raise ConfigError(f"Invalid SQLMesh configuration variable '{key}'.")
target_dict = config_dict
for config_key in segments[:-1]:
if config_key not in target_dict:
target_dict[config_key] = {}
target_dict = target_dict[config_key]
target_dict[segments[-1]] = value
return config_dict
@izeigerman