1
Fork 0

refactor: migrate configs from JSON to YAML

This commit is contained in:
Tibo De Peuter 2026-04-08 20:37:47 +02:00
parent ae483b306f
commit e9b52e9e8f
Signed by: tdpeuter
SSH key fingerprint: SHA256:u/h/LVoqKF1Iz02uOyxe6hcjmoZASCGV2HM0TG9ZMoU
5 changed files with 22 additions and 28 deletions

View file

@ -1,7 +1,6 @@
from __future__ import annotations
from dataclasses import dataclass, field
import json
from .env_types import Task
@ -51,14 +50,11 @@ class EnvConfig:
def from_file(path: str) -> tuple[MorphologyConfig, ArenaConfig, EnvConfig]:
"""Load configurations from a JSON or YAML file."""
with open(path, "r") as f:
if path.endswith(".yaml") or path.endswith(".yml"):
import yaml
"""Load configurations from a YAML file."""
import yaml
config_dict = yaml.safe_load(f)
else:
config_dict = json.load(f)
with open(path, "r") as f:
config_dict = yaml.safe_load(f)
morphology = MorphologyConfig(**config_dict.get("morphology", {}))
arena = ArenaConfig(**config_dict.get("arena", {}))