Skip to content

feat(schema): add containers to the schema models and formatter - #1480

Draft
pa-lem wants to merge 3 commits into
infrahub-developfrom
ple-field-sections-ifc-2729
Draft

pa-lem wants to merge 3 commits into
infrahub-developfrom
ple-field-sections-ifc-2729

Conversation

@pa-lem

@pa-lem pa-lem commented Nov 5, 2026 •

Copy link
Copy Markdown

Why

Infrahub adds field sections to the schema (IFC-2729): schema designers declare containers on nodes and generics and set container on attributes and relationships, and the web interface groups fields into one card or panel per section. The Infrahub schema API builds its responses from the SDK's generated models, so the SDK must carry the new properties before the Infrahub change can merge.

Non-goals: no change to how the SDK queries or mutates data.

What changed

  • The generated read, write and contract models carry containers on nodes, generics, profiles and templates, and container on attributes and relationships. Each container item has name, label, description, order_weight, collapsed and state.
  • ContainerSchemaRead also carries inherited, which Infrahub sets to true on a container that a node takes from a generic. ContainerSchemaWrite does not have it: the field is read-only.
  • validate_schema accepts both properties.
  • infrahubctl schema format places containers after uniqueness_constraints on a node and container last before the trailing order_weight on an attribute or relationship. Container item keys are ordered name, label, description, order_weight, collapsed, state.
  • infrahubctl schema export writes only the containers whose inherited is false, without inherited and state. A node with no container of its own has no containers key in the export.
  • infrahub_sdk.schema.main exports ContainerSchemaRead and ContainerSchemaWrite.

How to review

The diff against infrahub-develop is 10 files, +199 −3:

  • Hand-written, 7 files, +108 −3:
    • infrahub_sdk/ctl/schema_format.py: the key order.
    • infrahub_sdk/schema/export.py: export skips inherited containers.
    • infrahub_sdk/schema/main.py: the two exports.
    • Tests: tests/unit/ctl/test_schema_format.py, tests/unit/test_schema_offline_validation.py, tests/unit/sdk/test_schema_export.py.
    • Changelog: changelog/+schema-containers.added.md.
  • Generated by the Infrahub generator (uv run invoke backend.generate), not edited by hand, 3 files, +91: infrahub_sdk/schema/generated/read.py, write.py, contract.py.

How to test

uv run pytest tests/unit/ctl/test_schema_format.py tests/unit/test_schema_offline_validation.py tests/unit/sdk/test_schema_export.py

Local result on f6791e9: 119 passed.

Impact & rollout

  • Backward compatibility: additive. Schemas without containers load, format and export as before.
  • Deployment notes: the Infrahub PR that adds field sections depends on this PR. Its python_sdk submodule points at 356c5bf9 (this branch merged with the latest infrahub-develop) and is re-pointed at the merged commit on infrahub-develop once this PR merges.

Checklist

  • Tests added/updated
  • Changelog entry added
  • External docs updated (done in the Infrahub pull request)
  • Internal .md docs updated

The Infrahub pull request that depends on this one: opsmill/infrahub#11503

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 356c5bf
Status: ✅  Deploy successful!
Preview URL: https://26684320.infrahub-sdk-python.pages.dev
Branch Preview URL: https://ple-field-sections-ifc-2729.infrahub-sdk-python.pages.dev

View logs

@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                 Coverage Diff                  @@
##           infrahub-develop    #1480      +/-   ##
====================================================
+ Coverage             87.84%   87.87%   +0.02%     
====================================================
  Files                   157      157              
  Lines                 15653    15685      +32     
  Branches               2114     2117       +3     
====================================================
+ Hits                  13751    13783      +32     
  Misses                 1341     1341              
  Partials                561      561              
Flag Coverage Δ
integration-tests 42.86% <3.12%> (-0.09%) ⬇️
python-3.10 62.84% <28.12%> (-0.08%) ⬇️
python-3.11 62.83% <28.12%> (-0.09%) ⬇️
python-3.12 62.84% <28.12%> (-0.08%) ⬇️
python-3.13 62.84% <28.12%> (-0.06%) ⬇️
python-3.14 62.84% <28.12%> (-0.06%) ⬇️
python-3.15 62.83% <28.12%> (-0.09%) ⬇️
python-filler-3.12 23.13% <71.87%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/ctl/schema_format.py 97.61% <100.00%> (+0.07%) ⬆️
infrahub_sdk/schema/export.py 84.21% <100.00%> (+1.85%) ⬆️
infrahub_sdk/schema/generated/contract.py 100.00% <ø> (ø)
infrahub_sdk/schema/generated/read.py 100.00% <100.00%> (ø)
infrahub_sdk/schema/generated/write.py 99.43% <100.00%> (+0.03%) ⬆️
infrahub_sdk/schema/main.py 87.42% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pa-lem and others added 2 commits November 5, 2026 16:13
…ema export

ContainerSchemaRead carries the read-only `inherited` flag, and
`infrahubctl schema export` writes only the containers a node or generic
declares itself, so an exported node no longer redeclares the containers
of its generics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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