|
1 | 1 | from copy import deepcopy |
2 | 2 | from pathlib import Path |
3 | 3 |
|
4 | | -import yaml |
5 | 4 | from rich.markup import escape as escape_markup |
6 | 5 | from src.config.loaders import DeploymentConfigLoader |
7 | 6 | from src.config.overlay import ( |
@@ -29,14 +28,19 @@ def _flatten_dict_to_paths(d: dict, prefix: str = "") -> set[str]: |
29 | 28 | return out |
30 | 29 |
|
31 | 30 |
|
32 | | -def _load_common_yaml(path: str) -> dict | None: |
33 | | - """Load and validate common.yaml; return dict or None if file missing/invalid.""" |
| 31 | +def _load_common_yaml(path: str, config_base_dir: str | None = None) -> dict | None: |
| 32 | + """Load and validate common.yaml; return dict or None if file missing/invalid. Supports include:.""" |
34 | 33 | p = Path(path) |
35 | 34 | if not p.is_file(): |
36 | 35 | return None |
37 | | - with open(p, "r", encoding="utf-8") as f: |
38 | | - raw = yaml.safe_load(f) or {} |
39 | | - validated = CommonConfig.model_validate(raw) |
| 36 | + loader = DeploymentConfigLoader( |
| 37 | + configs_dir_path=str(p.parent), |
| 38 | + config_base_dir=config_base_dir or str(p.parent), |
| 39 | + ) |
| 40 | + merged = loader._load_one_file_with_includes(p) |
| 41 | + if not merged: |
| 42 | + return None |
| 43 | + validated = CommonConfig.model_validate(merged) |
40 | 44 | return validated.model_dump(mode="python", exclude_unset=True, exclude_none=True) |
41 | 45 |
|
42 | 46 |
|
@@ -150,7 +154,9 @@ def merge_configs( |
150 | 154 |
|
151 | 155 | # --- Load layout configs --- |
152 | 156 | layout_common = ( |
153 | | - _load_common_yaml(layout_common_config_path) if layout_common_config_path else None |
| 157 | + _load_common_yaml(layout_common_config_path, config_base_dir) |
| 158 | + if layout_common_config_path |
| 159 | + else None |
154 | 160 | ) |
155 | 161 | layout_loader = DeploymentConfigLoader( |
156 | 162 | configs_dir_path=layout_services_config_dir_path, |
@@ -182,7 +188,7 @@ def merge_configs( |
182 | 188 | service_path_to_overlays[key].append(overlay_name) |
183 | 189 | merged_services = apply_services_overlay_strict(merged_services, overlay_services) |
184 | 190 | if overlay_common_path: |
185 | | - overlay_common = _load_common_yaml(overlay_common_path) |
| 191 | + overlay_common = _load_common_yaml(overlay_common_path, config_base_dir) |
186 | 192 | if overlay_common is not None: |
187 | 193 | for key_path in _flatten_dict_to_paths(overlay_common): |
188 | 194 | if key_path not in common_path_to_overlays: |
|
0 commit comments