Configuration System
Configuration is the center of HABIT. It explains how a YAML file or Python dictionary becomes an executable workflow. This page covers loading, path resolution, schema layers, parameter registries, and domain configurators.
Overview
flowchart TD
Y["YAML or Python dict"] --> L["load_config / validation"]
L --> P["PathResolver"]
P --> W["Workflow schema"]
W --> V["validate_step_params"]
V --> R["ParamSchemaRegistry"]
R --> S["Step parameter schema"]
W --> C["Domain Configurator"]
C --> O["Runtime object"]
The system has three responsibilities:
Loading in
habit/core/common/configsreads files, resolves paths, and creates Pydantic models.Schemas in
habit/core/schemasdefine structure, constraints, parameter registration, and reflection metadata.Configurators assemble validated objects into executable workflows.
Loading and path resolution
Important symbols under habit/core/common/configs/ include:
Symbol |
Responsibility |
|---|---|
|
Reads YAML or JSON and resolves relative paths by default. |
|
Resolves paths relative to the configuration file, including Windows/WSL conversion. |
|
Pydantic base model for root configurations. Strict models reject
unknown fields with |
|
Convenience factory combining loading, path resolution, and validation. |
|
Validation exception containing the configuration path and Pydantic error details. |
The public API also accepts an in-memory dictionary. It uses the same schema
validation path as from_file:
from habit import run_preprocess
result = run_preprocess({
"data_dir": "data/raw",
"out_dir": "results/preprocessed",
"preprocessing": {},
})
Schema layers
habit/core/schemas/ separates configuration into three layers:
Layer |
Location |
Responsibility |
|---|---|---|
Workflows |
|
Root models such as |
Steps |
|
Type definitions for individual |
Registry |
|
Maps |
Workflow models describe the outer structure, step models describe individual parameter blocks, and the registry connects the two.
Parameter registry and validation
from habit.core.schemas.registry import ParamSchemaRegistry
ParamSchemaRegistry.register("preprocessing", "my_step", MyStepParams)
model = ParamSchemaRegistry.get("preprocessing", "my_step")
ParamSchemaRegistry.ensure_initialized()
While parsing a workflow, validate_step_params() resolves each method name,
validates its parameters, and raises ConfigValidationError before
execution when the input is invalid.
The same metadata can drive GUI forms, keeping CLI YAML and GUI fields aligned.
Domain configurators
After validation, each subsystem configurator assembles the runtime object:
Configurator |
Location |
Runtime object |
|---|---|---|
|
|
|
|
|
|
|
|
|
Summary
workflow schema root structure and cross-field validation
step schema individual parameter types
ParamSchemaRegistry method name -> parameter model
validate_step_params validate each step
BaseConfig / loader load, resolve paths, and validate
Domain Configurator validated config -> executable object
Runtime Registry method name -> algorithm instance
Schema definitions live under schemas/. Compatibility modules such as
preprocessing/config_schemas.py may re-export them, but new fields should
be added to the canonical schema files.