gselzer / pymmcore-plus-sandbox

Other
0 stars 0 forks source link

Switching Configuration Files can cause crashes #21

Open gselzer opened 1 month ago

gselzer commented 1 month ago

I've unfortunately been unable to come up with an MCVE, however I've noticed that some widget remembers existing Devices such that, when a new configuration group is loaded, something triggers it to ask micro-manager about a device that no longer exists. We then receive an error like the following, and the UI crashes.

2024-07-17 08:31:51,179 ERROR - 28684 Unable to get icon for location (The operation completed successfully.): C:\Users\gjselzer\code\pymmcore-plus\pymmcore-plus-sandbox\MMConfig_demo2.cfg
WARNING: Traceback (most recent call last):
  File "c:\Users\gjselzer\micromamba\envs\pymmcore-plus\Lib\site-packages\pymmcore_widgets\_property_widget.py", line 160, in _refresh_choices
    allowed = list(self._get_allowed())
                   ^^^^^^^^^^^^^^^^^^^
  File "c:\Users\gjselzer\micromamba\envs\pymmcore-plus\Lib\site-packages\pymmcore_widgets\_property_widget.py", line 168, in _get_allowed
    if allowed := self._mmc.getAllowedPropertyValues(self._dev, self._prop):
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: No device with label "TCamera-0"

It's possible that solving #19 could yield more information.

gselzer commented 1 month ago

Additionally, it's worth noting that errors seem to be avoided when an empty configuration file is loaded between switching configuration files.

marktsuchida commented 1 month ago

FWIW, the particular case I that remember was when we went from the Demo config (which has Channel group with Cy5 among other presets) to another config that also has a Channel group but with no Cy5 config (and all different underlying properties). The error contained something about the Cy5 preset. It was not immediately clear if the error arose from loading the new config or unloading the old one.