Skip to content

Conversation

@DominicOram
Copy link
Contributor

Fixes #1193

@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.35%. Comparing base (3988d8d) to head (65c47b4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1194      +/-   ##
==========================================
- Coverage   94.54%   94.35%   -0.19%     
==========================================
  Files          41       41              
  Lines        2566     2569       +3     
==========================================
- Hits         2426     2424       -2     
- Misses        140      145       +5     

☔ View full report in Codecov by Sentry.
📢 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.

@tpoliaw
Copy link
Contributor

tpoliaw commented Sep 5, 2025

Having a different message for the device not existing and the device being the wrong type makes a lot of sense but I'm not sure about listing the available devices in the error. The list will include a whole load of devices that are also not valid while not including some that are, eg it would only list stage and not stage.x and stage.y (unless this has changed recently, there was some discussion about it a while back).

Possibly out of scope of this PR but would it also make sense to change the message for the invalid type case to include the type it actually is? At the moment it is only <name> is not of type <type>.

@tpoliaw tpoliaw changed the title fix: Give better error message on non-existant device fix: Give better error message on non-existent device Sep 5, 2025
@DominicOram
Copy link
Contributor Author

I'm not sure about listing the available devices in the error

Fair enough but I do think that given this is the external API it's close to user facing so would like to be as helpful as possible. How about we list all known devices with the correct type and give the caveat that the list may not be exhaustive?

Possibly out of scope of this PR but would it also make sense to change the message for the invalid type case to include the type it actually is?

Yh, happy to do this

@tpoliaw
Copy link
Contributor

tpoliaw commented Sep 5, 2025

How about we list all known devices with the correct type and give the caveat that the list may not be exhaustive?

Sure, that works. I think #1129 was the change for including all devices and would get rid of the caveat.

device_names = list(self.devices.keys())
raise ValueError(
f"Device {value} cannot be found, "
f"available devices are: {device_names}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since devices are a tree and blueapi supports resolving them recursively (foo.bar.baz etc.), devices.keys() is not the complete set of available devices. So you might just get [sample_stage] instead of [sample_stage.x, sample_stage.y], for example. Not sure if it really matters here but worth knowing.

Relates to #1129

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, @tpoliaw beat me to it

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.

Give better error on inject non-existant device

4 participants