Skip to content

Stack optional JSON-schema settings for the next beta - #271

Draft
cboulay wants to merge 11 commits into
cboulay/resolve-generic-stream-metadatafrom
cboulay/json-schema-settings-stack
Draft

cboulay wants to merge 11 commits into
cboulay/resolve-generic-stream-metadatafrom
cboulay/json-schema-settings-stack

Conversation

@cboulay

@cboulay cboulay commented Sep 24, 2026

Copy link
Copy Markdown
Member

Integrate feature/json-schema-settings on top of #270 so a single release branch includes the enum serialization fix, resolved generic stream metadata, and optional JSON-schema settings support.

This merge preserves Konrad’s commits and includes ezmsg[schema], JSON Schema in settings metadata, validation/coercion of dynamic field updates, and ezmsg inspect. Pydantic remains optional and is loaded on first use. The feature branch’s test-isolation and multiprocess-attach prerequisites are retained. No merge conflicts required manual resolution.

PR stack: #258 → #265 → #267 → #270 → this PR. Merge/review in that order; this branch’s tip already contains the combined history and can be used for a beta tag after bumping the version. The version remains 3.10.0b3; no tag or release is created by this PR.

Validation (Python 3.12, macOS):

  • Full core suite: 477 passed, 39 skipped (pytest tests --benchmark-disable).
  • Separate core-only installation without Pydantic: import, settings metadata, and legacy field-update behavior pass.
  • git diff --check passes.

The existing CI workflow only auto-runs for PRs targeting main or dev, so these stacked PRs require a manual workflow dispatch or retargeting for the platform/Python matrix.

KonradPilch and others added 8 commits September 1, 2026 00:09
Start a fresh GraphServer on an OS-assigned loopback port for every test, then point in-process defaults and child environments at it. This prevents tests from attaching to unrelated servers while preserving explicit address overrides. Keep implicit auto-start coverage with a dedicated isolated test and re-enable test_attach for multiprocess attachment.
Wait for both child processes with a bounded timeout and assert successful exit codes. Ensure failed or hung children are terminated and make the test module importable to Windows spawn workers.
Pass the resolved GraphServer address to backend processes so Python 3.14 forkserver workers do not reuse a stale environment value.
The optional `schema` extra (pydantic, soft-imported) adds three behaviors,
all degrading to exactly the previous behavior when absent:

- SettingsSchemaMetadata gains a pydantic-generated json_schema, attached at
the one choke point every producer already flows through
(settings_schema_from_type), so graph component metadata, settings
snapshots, and settings events all carry a standard schema consumers can
validate against without parsing the field_type strings.

- Dynamic settings field updates are validated and coerced in the owning
backend process, where everything needed is importable, before the patch
is applied and broadcast. A refused value fails the process control
request with the reason. It no longer publishes a value the settings type
cannot hold.

- Structured settings snapshot values prefer pydantic's JSON-mode dump,
which round-trips exactly what the type's schema describes.
Reorder and split imports in `settingsmeta` to match project style.
Emits one JSON doc per module for component types, streams, settings,
and collection children without instantiating them.

Everything is read from class-level state the component metaclasses
already maintain (__streams__, __settings_type__, __components__), so
nothing is instantiated, no settings values are required, and no graph
server is involved.

This is the generic core of what downstream inspector CLIs hand-roll to
drive settings UIs from a separate venv; they can shrink onto this command
and keep only their app-specific conventions.
settingsmeta is reached by a plain `import ezmsg.core`, so importing
pydantic at module level charged every ezmsg process roughly 200 ms and
5 MB, including every spawned backend process, which re-imports from
scratch on spawn platforms regardless of whether or not it ever
described or coerced a setting. Deferring the import behind a cached
accessor means only the process that builds graph metadata, and
processes that actually handle settings updates, pay for it.

This branch was successfully deployed

1 active deployment
github-pages — 0ae39940 Deployed Sep 26, 2026 by cboulay via deploy #124
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