-
Notifications
You must be signed in to change notification settings - Fork 111
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
Strict checks on device initialization state breaks Hardware Configuration Wizard #384
Comments
Starting the HCW with the DemoConfig logs errors on State devices log
Actions on the Labels page do not appear to trigger an error. Adding a new State device (e.g. DemoCamera's DWheel) logs the same error. log
It also appears that every time a pre-init property of a State device is edited, the error is logged. Need to confirm what is being called in this case. Canceling the HCW after configuring a serial device (successfully or unsuccessfully) logs the error. This comes from waiting for COM devices as part of a call to
log
There appears to be a case where the error is triggered via I also encountered multiple issues with HCW behavior that may or may not be related to this issue (it's hard to tell because this issue potentially causes the HCW's data model to go out of sync with CMMCore's). Given the complexity, I think the best course of action is to disable throwing exceptions for now and replace it with logging the error. That way, we can test the HCW without affecting its behavior until we are reasonably confident that it no longer violates the rules. Then we can re-enable the exceptions. I will create (and merge) a PR to that effect later today. |
Thanks Mark! Happy to help testing on this end. |
The throwing of exceptions has been removed in #385 (in favor of logging a message when continuing with an unsafe operation). Leaving this issue open until I create individual issues for things that need fixing before re-enabling the exceptions. |
Path forward:
|
I think I might be seeing a related issue here in pymmcore_plus's microscope model (also used for the hardware config wizard there). And it has to do with directly getting/setting `core.getProperty('Core', 'Initialize'). Here's a minimal reproducer. I recognize that I'm directly accessing some very low level stuff here, but there appears to be an inconsistency in the reporting of the core initialization state in any case: In [1]: core = CMMCorePlus()
# in a new instance, we can get/set Initialize
In [2]: core.getProperty('Core', 'Initialize')
Out[2]: '0'
In [3]: core.setProperty('Core', 'Initialize', '1')
In [4]: core.getProperty('Core', 'Initialize')
Out[4]: '1'
In [5]: core.setProperty('Core', 'Initialize', '0')
In [6]: core.loadDevice('Camera', 'DemoCamera', 'DCam')
# but after we initialize a single (non-core) device ...
In [7]: core.initializeDevice('Camera')
# getProperty says core is uninitialized ...
In [8]: core.getProperty('Core', 'Initialize')
Out[8]: '0'
# but setting it manually to '1' causes already initialized error
In [9]: core.setProperty('Core', 'Initialize', '1')
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[9], line 1
----> 1 core.setProperty('Core', 'Initialize', '1')
File ~/mambaforge/envs/pymmcore-plus/lib/python3.11/site-packages/wrapt/decorators.py:470, in synchronized.<locals>._synchronized(wrapped, instance, args, kwargs)
464 @decorator
465 def _synchronized(wrapped, instance, args, kwargs):
466 # Execute the wrapped function while the original supplied
467 # lock is held.
469 with lock:
--> 470 return wrapped(*args, **kwargs)
File ~/dev/self/pymmcore-plus/src/pymmcore_plus/core/_mmcore_plus.py:254, in CMMCorePlus.setProperty(self, label, propName, propValue)
245 """Set property named `propName` on device `label` to `propValue`.
246
247 **Why Override?** In `MMCore`, the calling of the `onPropertyChanged`
(...)
251 and the property Value has actually changed.
252 """
253 with self._property_change_emission_ensured(label, (propName,)):
--> 254 super().setProperty(label, propName, propValue)
RuntimeError: Device already initialized (or initialization already attempted) It's also (understandably) not possible to query the core's device initialization state: In [10]: core.getDeviceInitializationState('Core')
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[10], line 1
----> 1 core.getDeviceInitializationState('Core')
RuntimeError: No device with label "Core" @marktsuchida, is this related to the issues seen in MMStudio? Or unrelated? I'll also note that this is easy for me to workaround in pymmcore-plus, so no urgency on my part |
also worth noting... that call to In [1]: core = CMMCorePlus()
In [2]: core.getProperty('Core', 'Initialize')
Out[2]: '0'
In [3]: core.loadDevice('Camera', 'DemoCamera', 'DCam')
In [4]: core.initializeDevice('Camera')
In [5]: core.getProperty('Core', 'Initialize')
Out[5]: '0'
In [6]: core.setProperty('Core', 'Initialize', '1')
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[6], line 1
----> 1 core.setProperty('Core', 'Initialize', '1')
RuntimeError: Device already initialized (or initialization already attempted)
In [7]: core.getProperty('Core', 'Initialize')
Out[7]: '1' # value has been changed |
Yeah, Some day I'll get |
In addition, it turns out that serial devices need to be able to set serial port settings, at least in the case of implementing |
#376 causes errors in the Hardware Configuration Wizard: usually in the form of errors in the log but possibly causing a crash for some devices.
It is quite possible that part of this is due to newly exposed bugs in the HCW (made harder to track due to swallowing of exceptions by the HCW), but I'm creating this issue here to collect information, since the near-term workaround might be to disable the checks.
As far as I am aware, the issue is only with the HCW and does not occur when loading or reloading the configuration outside of the HCW (confirmed with Demo config).
The text was updated successfully, but these errors were encountered: