Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add children property to a device #1138

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Add children property to a device #1138

wants to merge 5 commits into from

Conversation

rosesyrett
Copy link
Contributor

It was recently discovered that get_device_children() doesn't work for devices that are device_vectors.

To fix this issue, this PR removes get_device_children, connect_children and name_children and instead defines a children property on a device which effectively does what get_device_children did.

This simplifies the code for DeviceVector somewhat, which only needs to define a children property and no longer needs to redefine connect and name class methods that it inherits from Device.

@rosesyrett
Copy link
Contributor Author

@olliesilvester could you mention your use case for this here?

@olliesilvester
Copy link

olliesilvester commented Jul 24, 2023

For adding a load/save to devices (bluesky/ophyd-epics-devices#28 (comment)), we need to walk through the device and find all of its SignalRW's, including those within sub-devices. It makes sense to use get_device_children() for this, however the Panda device has its SignalRW's within device_vectors so this currently doesn't work

@rosesyrett
Copy link
Contributor Author

Ok, sure. This change will mean that instead of using get_device_children, each Device has a children property that you can iterate through instead. DeviceVector now has this property also.

Have a look at the changes in this PR and the tests. Please let me know if this will fix your problem or if you think there's anything missing. Thanks!

Copy link
Collaborator

@coretl coretl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, looks very neat. One minor comment on typing, we can discuss on Tuesday what level of compat we need with v1, which should answer the naming question

ophyd/v2/core.py Outdated Show resolved Hide resolved
ophyd/v2/core.py Outdated Show resolved Hide resolved
@olliesilvester
Copy link

Ok, sure. This change will mean that instead of using get_device_children, each Device has a children property that you can iterate through instead. DeviceVector now has this property also.

Have a look at the changes in this PR and the tests. Please let me know if this will fix your problem or if you think there's anything missing. Thanks!

Fixes my problem very well, thanks!

@untzag
Copy link
Member

untzag commented Jul 26, 2023

consider adding a HasChildren property to bluesky protocols, analogy to existing HasParent

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.

5 participants