-
Notifications
You must be signed in to change notification settings - Fork 8
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
Handling assertion errors in MMCore #84
Comments
In general C++ I would say that in this specific case, calling We could (and probably should), however, change the Core to throw a nice exception when an attempt is made to use an uninitialized device in ways that are not supported. If I were redesigning I would use a separate object for device-configurator vs active-device, but in practice this would have to be done by adding conditional checks on pretty much every device method (in the MMCore DeviceInstance classes). In the past we often just recommended using a configuration file and not mess with uninitialized devices, but I realize that that is probably too limiting when building more elaborate systems on top of MMCore. BTW did you hit any of the |
thanks for your help!
yep, that makes sense.
agree. a related question i've been wondering about recently (perhaps I've missed something obvious), is whether there is a way to know (from core) whether a device has been initialized. I see that most of the device adapters maintain some internal state to know whether they've been initialized or not, but it's hard to know from core. is that correct? or did i miss it? if so, it's of course harder to avoid attempting to use an uninitialized device (if the initialization state of every device needs to be saved outside of core)
yeah, definitely understand that. I came across this while building a python config wizard. I do understand that it's a fringe case. more generally, I think it is a good goal for pymmcore to never (ever) crash out to the terminal with an abort trap. That's just not what a python user expects to happen in the case of an exception. Happy to help get there! With your helpful info, I'll take a closer look and see if I can come up with more useful examples and perhaps a proposal |
Not currently. We need to add a boolean flag to
Yes, but in practice I would not count on any sequence other than load-init-unload or load-unload (
Couldn't agree more! I would categorize this as unfinished work. At least this one should be relatively easy to fix without affecting existing code. |
ok, all makes sense. thanks for the background! |
Fixed in micro-manager/mmCoreAndDevices#376 (MMCore 10.5.0) but keeping this open until pymmcore is updated. |
It turns out that throwing an exception on these checks was too ambitious and caused issues with MMStudio's Hardware Configuration Wizard, so we had to partially revert this. See micro-manager/mmCoreAndDevices#385 (MMCore 10.6.0) for details. The hope is to re-enable the exceptions once the HCW (and parts of MMCore) have been updated to work correctly. |
@tlambert03 One thing we could easily do is to add a (C++) method to |
i like that idea. it's kinda like strict mode for javascript :) |
Function to query init state has been added in micro-manager/mmCoreAndDevices#395. |
There are a few places where
assert
statements are used in MMCore and DeviceBase.h, such as here.If these lines fail, the python runtime will crash out back to terminal.
Example:
@marktsuchida, curious to hear your thoughts. Is a full crash something we could prevent here? would it be at the level of mmCoreAndDevices (by swapping those asserts for something else), at the level of SWIG (by catching them somehow and re-reraising), or all the way at the level of pymmcore-plus or something, by (laboriously) trying to make sure you don't do something like call
getState
on an uninitialized stateDevice?The text was updated successfully, but these errors were encountered: