Skip to content

feat: Register child devices as top level devices - #1739

Merged
Alexj9837 merged 13 commits into
mainfrom
register-child-devices-on-top
Nov 9, 2026
Merged

Alexj9837 merged 13 commits into
mainfrom
register-child-devices-on-top

Conversation

@Alexj9837

@Alexj9837 Alexj9837 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1724

Registering an ophyd-async device now also registers its children, including signals, under their own names at any depth (stage also gives stage-x, stage-x-velocity etc). Dotted access still works. Ophyd v1 devices are left alone.

Name clashes:

  • The first device registered under a name keeps it. Any later device with the same name, top level or child, is not registered and neither are its children. The first clash logs a single warning, and each clash is logged at debug
  • This includes a motor's user_readback, which ophyd-async gives the motor's name. It's still reachable as motor.user_readback
  • Top level devices used to replace an existing device with the same name, now the first one is kept
  • /devices reports each device under its registered name, so a motor registered with an override name doesn't appear twice alongside its readback

Things to note:

  • /devices and the plan schemas get a lot bigger (adsim goes from 2 to 117 devices), and low level signals like setpoints now show up as plan argument options.

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.47%. Comparing base (f0c530c) to head (f9762df).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1739      +/-   ##
==========================================
+ Coverage   96.46%   96.47%   +0.01%     
==========================================
  Files          49       49              
  Lines        3787     3804      +17     
==========================================
+ Hits         3653     3670      +17     
  Misses        134      134              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@Alexj9837
Alexj9837 force-pushed the register-child-devices-on-top branch from b4975f8 to e7797e3 Compare November 3, 2026 08:35
@Alexj9837
Alexj9837 force-pushed the register-child-devices-on-top branch from e7797e3 to 396a673 Compare November 3, 2026 08:36
@Alexj9837
Alexj9837 force-pushed the register-child-devices-on-top branch from 9fd0086 to 8ee7db7 Compare November 3, 2026 09:10
@Alexj9837
Alexj9837 marked this pull request as ready for review November 3, 2026 15:12
@Alexj9837
Alexj9837 requested a review from a team as a code owner November 3, 2026 15:12
@Alexj9837 Alexj9837 assigned Alexj9837 and unassigned Alexj9837 Nov 3, 2026

@tpoliaw tpoliaw 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.

Mostly looks ok, I'm mainly unsure of the required behaviour around handling duplicates.

Comment thread src/blueapi/core/context.py Resolved
Comment thread src/blueapi/core/context.py Resolved
Comment thread src/blueapi/core/context.py Resolved
Comment thread tests/unit_tests/core/test_context.py Resolved
Comment thread tests/unit_tests/core/test_context.py Resolved
Comment thread src/blueapi/core/context.py Resolved
Comment thread src/blueapi/service/interface.py Resolved
Comment thread src/blueapi/service/interface.py Resolved
@Alexj9837
Alexj9837 added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 5884bfd Nov 9, 2026
20 checks passed
@Alexj9837
Alexj9837 deleted the register-child-devices-on-top branch November 9, 2026 16:08
ZohebShaikh pushed a commit that referenced this pull request Nov 9, 2026
Closes #1724

Registering an ophyd-async device now also registers its children,
including signals, under their own names at any depth (`stage` also
gives `stage-x`, `stage-x-velocity` etc). Dotted access still works.
Ophyd v1 devices are left alone.

Name clashes:
- The first device registered under a name keeps it. Any later device
with the same name, top level or child, is not registered and neither
are its children. The first clash logs a single warning, and each clash
is logged at debug
- This includes a motor's `user_readback`, which ophyd-async gives the
motor's name. It's still reachable as `motor.user_readback`
- Top level devices used to replace an existing device with the same
name, now the first one is kept
- `/devices` reports each device under its registered name, so a motor
registered with an override name doesn't appear twice alongside its
readback

Things to note:
- `/devices` and the plan schemas get a lot bigger (adsim goes from 2 to
117 devices), and low level signals like setpoints now show up as plan
argument options.
ZohebShaikh pushed a commit to ZohebShaikh/blueapi that referenced this pull request Nov 11, 2026
This PR follows DiamondLightSource#1739. Devices in `BlueskyContext` are now wrapped in a
`BlueapiDevice` dataclass. This is similar to DiamondLightSource#1743.

Summary of changes:

- `BlueskyContext.devices` was `dict[str, Device]` where Device
represented bluesky protocols. Now `BlueskyContext.devices` is a
`dict[str, BlueapiDevice]`
- `DeviceModel` and the REST side are unchanged
- `ctx.devices` is a dictionary of `BlueapiDevice` wrappers
- `find_device` will look up the first part of the address (`stage` in
`stage.x`) in `ctx.devices` and returns a `Device`
- `find_component` is no longer a standalone function but has been moved
to `BlueapiDevice`. This functions follows from `find_device`, e.g.
finds the `x` on `stage` to give `stage.x`

---------

Co-authored-by: Peter Holloway <peter.holloway@diamond.ac.uk>
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.

Register child devices as top level devices

2 participants