Skip to content

feat: add the sectioned config schema - #69

Open
Hendrik-code wants to merge 1 commit into
hm/register-transformsfrom
hm/config-schema
Open

feat: add the sectioned config schema#69
Hendrik-code wants to merge 1 commit into
hm/register-transformsfrom
hm/config-schema

Conversation

@Hendrik-code

Copy link
Copy Markdown
Collaborator

Stacked on #68. smauglab/config.py, with no consumers yet — nothing reads it until the builder lands, and the shipped configs are untouched by this PR.

A config becomes a sectioned document — GPU, CPU, pipeline, and _-prefixed comments — where a key is a class name exactly and a parameter is a constructor argument exactly, both checked against the registry.

{
  "_comment": "ignored",
  "pipeline": { "mode": "sequential", "order": "registry" },
  "GPU": { "RandomFlipTransformGPU": { "flip_axis": [0], "p": 0.5 } },
  "CPU": { ... }
}

A flat config is rejected, not migrated

It used to be read as "GPU or CPU, whichever the keys look like". The two namespaces overlap enough that GaussianBlurTransform meant a different transform depending on which builder read it. That guess is gone.

Every problem at once

The old behaviour surfaced one problem per run — for a 30-key config, 30 edit-run cycles. Now:

config.json: 3 problem(s)
  - GPU.unknown GPU augmentation 'NotATransform'. Did you mean: ...
  - GPU.RandomFlipTransformGPU: unknown parameter 'nonsense'. Accepted: flip_axis, keepdim, p, p_batch, same_on_batch
  - GPU.RandomScharrGPU: unknown parameter 'probability'.
        'probability' -> p

That last one matters: probabilityp is the commonest migration mistake and difflib cannot bridge it (the two strings score ~0.17), so it comes from an explicit hint table that a test keeps diagnostic-only.

pipeline.order — the opt-in you asked for

"pipeline": { "order": "config" }     // default: "registry"

registry is registry.PIPELINE_ORDER: fixed, and the same for every config. config takes the order the keys appear in the file instead.

It is not the default because it makes a pipeline sensitive to something people reasonably treat as cosmetic — reordering or reformatting a config would silently change what it does. Opting in makes that intent explicit and greppable. It's independent of pipeline.mode.

A layering change from the original PR

PipelineMode, OrderSource and validate_section live here rather than in the builder, where #56 put them. They describe a config document, so config.py depends only on the registry and the builder will import them from here. That's also what lets this PR land on its own rather than being welded to the builder.

pipeline.mode replaces encoding the arrangement in the trainer class — which baked the choice into the name of every run directory and could not be varied without a new class.

Testing

unit_tests/test_config_schema.py — 22 tests: sections, the flat-config rejection, cumulative problem reporting, the suggestion machinery, and pipeline.order in both directions.

Full suite: 163 passed, 5 skipped, 479 subtests. ruff and mypy clean.

smauglab/config.py, with no consumers yet: nothing reads it until the builder
lands, and the shipped configs are untouched by this commit.

A config becomes a sectioned document -- GPU, CPU, pipeline, and '_'-prefixed
comments -- where a key is a class name exactly and a parameter is a constructor
argument exactly, both checked against the registry.

A flat, section-less document is rejected rather than migrated. It used to be read
as "GPU or CPU, whichever the keys look like", and the two namespaces overlap
enough that GaussianBlurTransform meant a different transform depending on which
builder read it.

Every problem in a file is reported at once, with "did you mean" suggestions. The
old behaviour surfaced one per run, which for a 30-key config is 30 edit-run
cycles.

pipeline.order is the opt-in discussed on the registry commit. The default,
`registry`, is registry.PIPELINE_ORDER: fixed, and the same for every config.
`config` takes the order the keys appear in the file instead. It is not the
default because it makes a pipeline sensitive to something people reasonably
treat as cosmetic -- reordering or reformatting a config would silently change
what it does -- so opting in makes that intent explicit and greppable. It is
independent of pipeline.mode.

PipelineMode, OrderSource and validate_section live here rather than in the
builder that pr56 put them in. They describe a config document, so config.py
depends only on the registry and the builder will import them from here. That is
also what lets this land on its own.

pipeline.mode replaces encoding the arrangement in the trainer *class*, which
baked the choice into the name of every run directory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 21, 2026 06:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants