11"""Infrastructure specification configuration and loading."""
22
33from pathlib import Path
4- from typing import Any , Optional
4+ from typing import TYPE_CHECKING , Any , Optional
55
66from omegaconf import OmegaConf
77
88from netengine .config .loader import ConfigLoader
99
10+ if TYPE_CHECKING :
11+ from netengine .spec .models import NetEngineSpec
12+
1013
1114class SpecConfig :
1215 """Load and manage infrastructure specifications with composition support."""
1316
1417 @staticmethod
15- def load (
18+ def load_raw (
1619 spec_path : Path | str ,
1720 base_path : Optional [Path | str ] = None ,
1821 overrides : Optional [dict [str , Any ]] = None ,
@@ -25,7 +28,7 @@ def load(
2528 overrides: Optional overrides dictionary
2629
2730 Returns:
28- Loaded and merged specification as dictionary
31+ Loaded and merged raw specification as dictionary
2932 """
3033 spec_path = Path (spec_path )
3134
@@ -42,7 +45,34 @@ def load(
4245 return spec_dict
4346
4447 @staticmethod
45- def load_environment_variants (
48+ def load (
49+ spec_path : Path | str ,
50+ base_path : Optional [Path | str ] = None ,
51+ overrides : Optional [dict [str , Any ]] = None ,
52+ ) -> dict [str , Any ]:
53+ """Load spec as a raw dictionary.
54+
55+ This backwards-compatible alias preserves the historical ``SpecConfig.load``
56+ behavior. Prefer ``load_raw`` for new raw merge callers or
57+ ``load_validated`` when a validated ``NetEngineSpec`` is required.
58+ """
59+ return SpecConfig .load_raw (spec_path , base_path = base_path , overrides = overrides )
60+
61+ @staticmethod
62+ def load_validated (
63+ spec_path : Path | str ,
64+ base_path : Optional [Path | str ] = None ,
65+ overrides : Optional [dict [str , Any ]] = None ,
66+ validate_feature_states : bool = True ,
67+ ) -> "NetEngineSpec" :
68+ """Load, compose, and validate a spec into a ``NetEngineSpec``."""
69+ from netengine .spec .loader import validate_spec_data
70+
71+ spec_dict = SpecConfig .load_raw (spec_path , base_path = base_path , overrides = overrides )
72+ return validate_spec_data (spec_dict , validate_feature_states = validate_feature_states )
73+
74+ @staticmethod
75+ def load_environment_variants_raw (
4676 base_spec : Path | str ,
4777 environment : str = "dev" ,
4878 overrides : Optional [dict [str , Any ]] = None ,
@@ -59,7 +89,7 @@ def load_environment_variants(
5989 overrides: Optional additional overrides
6090
6191 Returns:
62- Merged specification
92+ Merged raw specification dictionary
6393 """
6494 base_path = Path (base_spec )
6595 base_dir = base_path .parent
@@ -78,6 +108,39 @@ def load_environment_variants(
78108
79109 return spec_dict
80110
111+ @staticmethod
112+ def load_environment_variants (
113+ base_spec : Path | str ,
114+ environment : str = "dev" ,
115+ overrides : Optional [dict [str , Any ]] = None ,
116+ ) -> dict [str , Any ]:
117+ """Load environment variants as a raw dictionary.
118+
119+ This backwards-compatible alias preserves the historical
120+ ``SpecConfig.load_environment_variants`` behavior. Prefer
121+ ``load_environment_variants_raw`` for new raw merge callers or
122+ ``load_environment_variant_validated`` when a validated ``NetEngineSpec``
123+ is required.
124+ """
125+ return SpecConfig .load_environment_variants_raw (
126+ base_spec , environment = environment , overrides = overrides
127+ )
128+
129+ @staticmethod
130+ def load_environment_variant_validated (
131+ base_spec : Path | str ,
132+ environment : str = "dev" ,
133+ overrides : Optional [dict [str , Any ]] = None ,
134+ validate_feature_states : bool = True ,
135+ ) -> "NetEngineSpec" :
136+ """Load an environment variant and validate it into a ``NetEngineSpec``."""
137+ from netengine .spec .loader import validate_spec_data
138+
139+ spec_dict = SpecConfig .load_environment_variants_raw (
140+ base_spec , environment = environment , overrides = overrides
141+ )
142+ return validate_spec_data (spec_dict , validate_feature_states = validate_feature_states )
143+
81144 @staticmethod
82145 def to_dict (spec_obj : Any ) -> dict [str , Any ]:
83146 """Convert OmegaConf spec object to dictionary.
0 commit comments