Implementation:AIScientists Dev WorldSeed load config
| Knowledge Sources | |
|---|---|
| Domains | Configuration |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
Concrete tool for loading and validating a scene config YAML file with preset resolution provided by the WorldSeed library.
Description
The load_config function is the entry point for scene configuration loading. It reads a YAML file, resolves any preset imports declared in `scene.use`, and validates the result through the Pydantic `SceneConfig` schema.
Preset resolution is a deep-merge process: imported YAML fragments are loaded from `presets/` directories and merged before validation. Dicts merge recursively, lists append (entities dedupe by id), and `dm_knowledge` concatenates. Circular preset references are detected and rejected.
Usage
Import this function when you need to load a scene config from a YAML file path. Used by `WorldEngine.__init__()` and the `worldseed validate` CLI.
Code Reference
Source Location
- Repository: WorldSeed
- File: src/worldseed/scene/config.py
Signature
def load_config(path: str | Path) -> SceneConfig:
"""Load and validate a scene config YAML file.
If scene.use lists preset names, the corresponding YAML fragments
are loaded from a presets/ directory and deep-merged before validation.
"""
Import
from worldseed.scene.config import load_config
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| path | Path | Yes | Path to scene YAML file |
Outputs
| Name | Type | Description |
|---|---|---|
| return | SceneConfig | Validated Pydantic scene config model |
Usage Examples
Basic Loading
from worldseed.scene.config import load_config
config = load_config("configs/teahouse.yaml")
print(f"Scene: {config.scene.description}")
print(f"Entities: {len(config.entities)}")
print(f"Actions: {len(config.actions)}")
With Presets
# Scene YAML with presets:
# scene:
# use: [base_items, social_actions]
# description: "A teahouse scene"
config = load_config("configs/my_scene.yaml")
# Presets are deep-merged: base_items entities + social_actions
# are combined with the scene's own definitions