Skip to content

Fork test: union schema export on the unreleased pywr-v1-schema - #1

Draft
Mearman wants to merge 11 commits into
mainfrom
nexsys/schema-union-fork
Draft

Mearman wants to merge 11 commits into
mainfrom
nexsys/schema-union-fork

Conversation

@Mearman

@Mearman Mearman commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Runs the CI of pywr#900 and pywr#901 on this fork, built against the pywr-v1-schema fork branch that carries pywr/pywr-v1-schema#300, so the union export can be tested before either upstream change is released. Not for upstream.

Mearman added 10 commits October 8, 2026 16:53
export-schema --union combines the Pywr v1 schema, generated by pywr-v1-schema, with the v2
model and multi-network schemas. Each version's definitions are namespaced and the document kind
is selected by its identifying property: nodes, models, network or networks.
Every v2 model, including the multi-network ones, and every v1 conversion input must validate,
and a document that mixes the v1 and v2 identifying properties, or has none, must be rejected.
A new workflow exports the v2 schema and the combined v1 and v2 schema with pywr-cli and uploads
them to the release that was published, so that each version has its schemas at a stable URL.
pywr_model_schema returns a Result with a JsonSchemaError instead of panicking when a schema
generator produces an unexpected shape, and the CLI reports it with context.

Both v2 document types are generated by one SchemaGenerator, so they share a single definition
namespace and cannot number a clashing definition name differently. Root definitions are named
from JsonSchema::schema_name rather than from the schema's title, which a doc comment heading or
a schemars attribute can change.

The help text of --union now says what the default export covers and how v1 custom types are
treated.
…hema

The union selected its document kind with a oneOf over four alternatives, so any invalid document
failed with a bare "not valid under any of the given schemas" and the whole document echoed back.
The kind is now chosen by an `if`/`then` on its identifying property, with a oneOf of bare
`required` clauses enforcing that exactly one of them is present. The set of accepted documents is
unchanged, and a document with a missing or mistyped field reports that field.

The tests now reject invalid documents: none or two identifying properties, a missing `time` or
`timestepper`, mistyped fields, an unknown v2 node type and a bad v1 edge. Each of the schema's
parts is needed by one of them. A further test compares the v2 half of the union with the
standalone v2 schema.
gh release upload fails on an asset that already exists, so re-running the job on a release
failed. With --clobber the assets are replaced.
CI builds with --locked, which fails when the lock file lacks the entries for a dependency the
manifest declares.
…_schema

Fork-only: pywr/pywr-v1-schema#300 adds the json_schema module this branch uses, so the published crate cannot build it yet. Drop this commit once that release exists.
@Mearman
Mearman force-pushed the nexsys/schema-union-fork branch from 8b35503 to 5375bc8 Compare October 9, 2026 09:35
Fork-only, with the previous commit.
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.

1 participant