Skip to content

Commit 3d94ec2

Browse files
deployment: support include directive in common yaml loader
1 parent 9155cef commit 3d94ec2

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

deployments/sequencer/src/config/merger.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from copy import deepcopy
22
from pathlib import Path
33

4-
import yaml
54
from rich.markup import escape as escape_markup
65
from src.config.loaders import DeploymentConfigLoader
76
from src.config.overlay import (
@@ -29,14 +28,19 @@ def _flatten_dict_to_paths(d: dict, prefix: str = "") -> set[str]:
2928
return out
3029

3130

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:."""
3433
p = Path(path)
3534
if not p.is_file():
3635
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)
4044
return validated.model_dump(mode="python", exclude_unset=True, exclude_none=True)
4145

4246

@@ -150,7 +154,9 @@ def merge_configs(
150154

151155
# --- Load layout configs ---
152156
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
154160
)
155161
layout_loader = DeploymentConfigLoader(
156162
configs_dir_path=layout_services_config_dir_path,
@@ -182,7 +188,7 @@ def merge_configs(
182188
service_path_to_overlays[key].append(overlay_name)
183189
merged_services = apply_services_overlay_strict(merged_services, overlay_services)
184190
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)
186192
if overlay_common is not None:
187193
for key_path in _flatten_dict_to_paths(overlay_common):
188194
if key_path not in common_path_to_overlays:

0 commit comments

Comments
 (0)