Skip to content

feat(config)!: drop legacy layouts and support marshmallow 3 - #132

Merged
cwasicki merged 4 commits into
frequenz-floss:v0.x.xfrom
cwasicki:drop
Sep 1, 2026
Merged

cwasicki merged 4 commits into
frequenz-floss:v0.x.xfrom
cwasicki:drop

Conversation

@cwasicki

@cwasicki cwasicki commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Dropping the legacy microgrid config layouts (breaking) and fixing config loading under marshmallow 3.

Breaking change

The top-level microgrid-ID and meta-nested layouts are no longer migrated on load. A file with no assets table now loads as empty and contributes nothing to a merge, instead of having its top-level keys read as microgrid IDs. This lets a mixed list of files (some carrying an [app] table for their own config, some an assets table) be passed to AssetsConfig.load_from_files / load_configs, which reads only the assets-bearing ones. Rebuild any legacy-layout files with generate-config. _STEPS is now empty; assets.version validation and stamping remain.

Bug fix

tomllib parses TOML datetimes to native datetime objects, which marshmallow 3's DateTime field rejected (marshmallow 4 accepts them). A TomlAwareDateTime field passes an already-parsed datetime through and otherwise defers to the parent for ISO strings, applied to every bare datetime config field sourced from TOML.

Build

Now declares marshmallow as a direct dependency. It was already used transitively via marshmallow-dataclass but never declared, so the minimum-version job left it free to resolve to marshmallow 4. Declaring it pins the lower bound so the marshmallow-3 path is tested.

@cwasicki
cwasicki requested review from a team as code owners September 1, 2026 06:38
@cwasicki
cwasicki requested review from Linus404 and shsms and removed request for a team September 1, 2026 06:38
@github-actions github-actions Bot added part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.) labels Sep 1, 2026
It is already used transitively via marshmallow-dataclass, but was never
declared, so the pytest_min job left it free to resolve to marshmallow 4.
Declaring it pins the lower bound there, so the minimum-version path is
tested.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
tomllib parses TOML datetimes to native datetime objects, which
marshmallow 3's DateTime field rejects; marshmallow 4 accepts them. A
TomlAwareDateTime field passes an already-parsed datetime through and
otherwise defers to the parent for ISO strings, applied to every bare
datetime config field sourced from TOML.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
The top-level microgrid-ID and `meta`-nested layouts are no longer
migrated on load. A file with no `assets` table now loads as empty and
contributes nothing to a merge, so a mixed list of files (some with an
`[app]` table, some with `assets`) can be passed to the loaders and only
the `assets`-bearing ones are read. `_STEPS` is now empty; the version
validation and stamping remain.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
@cwasicki
cwasicki added this pull request to the merge queue Sep 1, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 1, 2026
Dump and patch flattened the config via `Schema.dump`, whose field
order is not stable across marshmallow versions: marshmallow 3 does not
preserve declaration order, so the generated dotted keys came out
reordered under the pinned minimum. Use `dataclasses.asdict`, which
always yields declaration order, dropping marshmallow from this path.

Signed-off-by: cwasicki <126617870+cwasicki@users.noreply.github.com>
@cwasicki

cwasicki commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

Added another fix to pass the minimum pytest.

@cwasicki
cwasicki added this pull request to the merge queue Sep 1, 2026
Merged via the queue into frequenz-floss:v0.x.x with commit 54f9a31 Sep 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:docs Affects the documentation part:tests Affects the unit, integration and performance (benchmarks) tests part:tooling Affects the development tooling (CI, deployment, dependency management, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants