File indexing completed on 2026-04-27 07:28:14
0001 """Integration test loading the examples/basic full_example.yml via FullConfig."""
0002
0003 from pathlib import Path
0004 import shutil
0005 import yaml
0006
0007 from aid2e.utilities.configurations import FullConfig, load_config
0008
0009
0010 def test_full_example_yaml_loads_via_fullconfig(tmp_path):
0011 """Ensure the sample full_example.yml can be normalized and loaded as FullConfig."""
0012 example_dir = Path("examples/basic")
0013 source_config = example_dir / "full_example.yml"
0014 source_design = example_dir / "design.params"
0015
0016
0017 config_path = tmp_path / "full_example.yml"
0018 design_path = tmp_path / "design.params"
0019 shutil.copyfile(source_config, config_path)
0020 shutil.copyfile(source_design, design_path)
0021
0022 data = yaml.safe_load(config_path.read_text())
0023
0024 output_dir = tmp_path / "output"
0025 work_dir = tmp_path / "work"
0026 output_dir.mkdir()
0027 work_dir.mkdir()
0028
0029 data["problem"]["output_location"] = str(output_dir)
0030 data["problem"]["work_location"] = str(work_dir)
0031 data["problem"].setdefault("design_space", {})["path"] = str(design_path)
0032
0033 config_path.write_text(yaml.safe_dump(data))
0034
0035 cfg = load_config(str(config_path))
0036
0037 assert isinstance(cfg, FullConfig)
0038 assert cfg.problem.name == "DTLZ2 Multi-Objective Optimization"
0039 assert "DTLZ2_variables.x1" in cfg.problem.design_config.get_parameter_names()
0040 assert len(cfg.optimization.objectives) == len(data["problem"]["objectives"])
0041 assert cfg.optimization.optimizer.name == data.get("optimizer", {}).get("kind", "")