Skip to content

ControllerFiller — declarative/procedural split #394

Description

@coretl

Scope

  • ControllerFiller mirroring ophyd_async DeviceFiller (core/_device_filler.py — follow its structure; match names only where FastCS vocab fits). Scans class hints for AttrR/W/RW[T], Command[...], sub-Controller/ControllerVector[T]; creates children unfilled; check_filled(source) reports promised-but-missing.
  • Rule: at the end of __init__, any Attribute referenced in code (i.e. type-hinted) MUST exist; initialise() may then run in parallel (only __init__ is serial). (0013 L150)
  • Support: no-hints-at-all (0013 L139); Optional[X] hints (0013 L153); adding attributes onto a bare Controller from outside — which is what fillers do (0013 L144).
  • yields (child, extras) so third-party extras vocabularies work (decision 3); core defines none. Delete HintedAttribute + _validate_type_hints; remove the deepcopy half of _bind_attrs (keep @command/@scan binding). Trailing-underscore name convention.
  • Migrate Example 5 (cut-down Eiger, Example 5 — cut-down Eiger: introspectable controller + REST sim #391) to the filler.

⚠️ Investigate

fastcs-catio builds Controller classes at runtime via type(...) from YAML before any instance exists — decide: does the filler support class-level dynamic construction, or must catio move to instance-level dynamic attrs? Record the decision in the PR / an ADR update.

Key files (§9)

controllers/base_controller.py (_bind_attrs, _find_type_hints), + new filler module.

Acceptance

uv run --locked tox -e pre-commit,type-checking,tests green; Example 5 updated + green.

ADR: 0013
Parent: #388
Blocked by: #392, #413

Filler metadata validation — folded in from review

  • Hinted children are created unfilled in __init__ (so they exist after __init__, per the ADR 13 rule); initialise() only fills them (+ may add unhinted dynamic attrs).
  • When filling from an Annotated[Attr[T], extras] hint, runtime-validate the metadata the extras carries (FloatMeta, or a protocol object's .meta e.g. SCPIParam(...).meta) against datatype Tprecision on a str raises. Runtime counterpart to the static Unpack[FloatMeta] check (getter/setter IO rework; remove AttributeIORef and AttributeIO #392).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions