|
47 | 47 | from sqlmesh.core import constants as c |
48 | 48 | from sqlmesh.core._typing import NotificationTarget |
49 | 49 | from sqlmesh.core.audit import Audit |
50 | | -from sqlmesh.core.config import Config, load_config_from_paths |
| 50 | +from sqlmesh.core.config import Config, load_config_from_paths, load_config_from_yaml |
51 | 51 | from sqlmesh.core.console import Console, get_console |
52 | 52 | from sqlmesh.core.context_diff import ContextDiff |
53 | 53 | from sqlmesh.core.dialect import ( |
|
75 | 75 | from sqlmesh.core.table_diff import TableDiff |
76 | 76 | from sqlmesh.core.test import get_all_model_tests, run_model_tests, run_tests |
77 | 77 | from sqlmesh.core.user import User |
78 | | -from sqlmesh.utils import UniqueKeyDict, sys_path |
| 78 | +from sqlmesh.utils import UniqueKeyDict, env_vars, sys_path |
79 | 79 | from sqlmesh.utils.dag import DAG |
80 | 80 | from sqlmesh.utils.date import TimeLike, yesterday_ds |
81 | 81 | from sqlmesh.utils.errors import ( |
@@ -1082,15 +1082,23 @@ def _load_configs( |
1082 | 1082 | if isinstance(config, Config): |
1083 | 1083 | return {path: config for path in paths} |
1084 | 1084 |
|
1085 | | - lookup_paths = [self.sqlmesh_path / "config.yml", self.sqlmesh_path / "config.yaml"] |
1086 | | - |
1087 | | - return { |
1088 | | - path: load_config_from_paths( |
1089 | | - *(lookup_paths + [path / "config.py", path / "config.yml", path / "config.yaml"]), |
1090 | | - config_name=config, |
1091 | | - ) |
1092 | | - for path in paths |
1093 | | - } |
| 1085 | + config_defaults = None |
| 1086 | + for path in (self.sqlmesh_path / "config.yml", self.sqlmesh_path / "config.yaml"): |
| 1087 | + if path.exists(): |
| 1088 | + config_defaults = load_config_from_yaml(path) |
| 1089 | + break |
| 1090 | + |
| 1091 | + with env_vars(config_defaults.env_vars if config_defaults else {}): |
| 1092 | + return { |
| 1093 | + path: load_config_from_paths( |
| 1094 | + path / "config.py", |
| 1095 | + path / "config.yml", |
| 1096 | + path / "config.yaml", |
| 1097 | + config_name=config, |
| 1098 | + config_defaults=config_defaults, |
| 1099 | + ) |
| 1100 | + for path in paths |
| 1101 | + } |
1094 | 1102 |
|
1095 | 1103 | def _run_janitor(self) -> None: |
1096 | 1104 | expired_environments = self.state_sync.delete_expired_environments() |
|
0 commit comments