Skip to content

Add experimental TOML config generator from marshmallow schemas#120

Open
Marenz wants to merge 2 commits intofrequenz-floss:v1.x.xfrom
Marenz:config-generator
Open

Add experimental TOML config generator from marshmallow schemas#120
Marenz wants to merge 2 commits intofrequenz-floss:v1.x.xfrom
Marenz:config-generator

Conversation

@Marenz
Copy link
Contributor

@Marenz Marenz commented Mar 3, 2026

Add frequenz.quantities.experimental.toml_generator module that walks marshmallow schemas and emits TOML text with default values and field descriptions as comments.

This extends the existing experimental marshmallow integration (experimental.marshmallow) with a TOML output layer, useful for generating documented default configuration files from dataclass-based config schemas.

Features:

  • generate_toml_from_schema(schema, section) entry point
  • CommentStyle enum (AUTO, ABOVE, INLINE, SHORT) for controlling comment placement
  • Nested dataclass fields become [section.subsection] headers
  • Quantity fields (Power, Percentage, etc.) rendered as string leaf values
  • Optional nested sections (default=None) emitted fully commented out
  • Handles enums, timedeltas, booleans, infinity defaults

Walk marshmallow schemas (typically from marshmallow_dataclass) and emit
TOML text with default values and field descriptions as comments. Handles
nested sections, quantity fields as string leaves, optional sections
(commented out), enums, timedeltas, and infinity defaults.

Extends the existing experimental marshmallow integration with a
generate_toml_from_schema() entry point and a CommentStyle enum.

Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
@Marenz Marenz requested a review from a team as a code owner March 3, 2026 10:33
@Marenz Marenz requested review from daniel-zullo-frequenz and removed request for a team March 3, 2026 10:33
@github-actions github-actions bot added part:tests Affects the unit, integration and performance (benchmarks) tests part:code Affects the code in general labels Mar 3, 2026
Signed-off-by: Mathias L. Baumann <mathias.baumann@frequenz.com>
@github-actions github-actions bot added the part:docs Affects the documentation label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:code Affects the code in general part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant