fumitoh / spyder-modelx

Spyder plugin for modelx
https://docs.modelx.io
GNU Lesser General Public License v3.0
7 stars 6 forks source link

CommError raised while reading model #15

Open vineetgupta086 opened 7 months ago

vineetgupta086 commented 7 months ago

Description of your problem

While reading an existing model on my laptop, a CommError is raised with the message "Cannot block on a disconnected comm". If I ignore the error and close the prompt, nothing happens. I can try to read the model again and it would run fine.

What steps will reproduce the problem?

  1. Open MxExplorer in Spyder.
  2. Right-click and select read model.
  3. In the prompt to read model, select the model directory, give it a name and click OK.

An error prompt sometimes appears with the following error message:

Traceback (most recent call last):
  File "C:\Spyder\Python\lib\site-packages\spyder_modelx\widgets\mxexplorer.py", line 371, in contextMenuEvent
    else:
  File "C:\Spyder\Python\lib\site-packages\spyder_modelx\widgets\mxshell.py", line 522, in read_model
    self.call_kernel(
  File "C:\Spyder\pkgs\spyder_kernels\comms\commbase.py", line 557, in __call__
    return self._comms_wrapper._get_call_return_value(
  File "C:\Spyder\pkgs\spyder\plugins\ipythonconsole\comms\kernelcomm.py", line 220, in _get_call_return_value
    raise CommError("Cannot block on a disconnected comm")
spyder_kernels.comms.commbase.CommError: Cannot block on a disconnected comm

What is the expected output? What do you see instead? It is expected that the model is read and I see the model userspaces in MxExplorer.

Please provide any additional information below This seems like a bug to me as I am not able to reproduce the error every time. Basically, this error is raised only once in a while. If I ignore the error and close the prompt, nothing happens. I can try to read the model again and it would then run fine.

Versions and main components

Just for information, I am not using the lifelib version of Spyder. I installed Spyder from the official website and then installed all of the libraries explicitly to get the Modelx plugins.

fumitoh commented 7 months ago

Did you download the standalone version of Spyder from https://www.spyder-ide.org/ ? This page says

The built-in interpreter of the standalone version doesn't currently support installing packages beyond the common scientific libraries bundled with it, so most users will want to have an external Python environment to run their own code, like with any other IDE. Also, the standalone installers don't yet work with third-party plugins, so users needing them should use Spyder through a Conda-based distribution instead.

How did you manage to install modelx?

What are the versions of your spyder-modelx and spymx-kernels packages?

spyder-modelx v0.13.5 and spymx-kernels v0.1.5 are the latest releases. Updating to them may solve the issue.

vineetgupta086 commented 7 months ago

Yes, I did install the standalone version of Spyder, but I thought they were aware that third-party plugins can be installed.

I did initially use the lifelib version of Spyder, but I faced some issues in it, so I decided to move to the standalone version. Bottom line is that I followed the steps mentioned in https://docs.modelx.io/en/latest/installation.html

However, I was not able to install modelx plugins in just one go. I did mess up a few times and due to that, Spyder wouldn't even run. So, I had to be really careful about the folder structure in which the libraries are installed and things like that.

I'm attaching a text file with detailed steps that I followed. Hopefully, this would be useful for other people also. README FOR SPYDER_PLUGIN.txt

Back to the CommError problem My versions currently are: spyder-modelx: v0.13.4 spymx-kernels: v0.1.5

I'll try to install the latest spyder-modelx version v0.13.5. Thanks!

fumitoh commented 7 months ago

The relevant packages in your installation seem recent enough. Since I haven't had the same problem, and the problem seems to occur sporadically, it's hard to reproduce the same situation and identify the cause. Maybe because the issue is specific to your installation. To use Spyder on Windows, WinPython or Anaconda are recommended. These are the Python distributions that have been tested on Windows.

vineetgupta086 commented 7 months ago

Yes, the problem occurs sporadically. I will close the issue, but I thought it would be worth sharing the issue in case anyone faces the same in future. I can try other Python distributions. Thanks!

fumitoh commented 5 months ago
Traceback (most recent call last):
  File "c:\users\…\spyder-modelx\spyder_modelx\widgets\mxexplorer.py", line 344, in contextMenuEvent
    self.shell.read_model(modelpath, name, define_var, varname)
  File "c:\users\…\spyder-modelx\spyder_modelx\widgets\mxshell.py", line 525, in read_model
    timeout=CALL_KERNEL_TIMEOUT).mx_read_model(
                                 ^^^^^^^^^^^^^^
  File "C:\Users\a_user\anaconda3\envs\spycompat\Lib\site-packages\spyder_kernels\comms\commbase.py", line 557, in __call__
    return self._comms_wrapper._get_call_return_value(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\a_user\anaconda3\envs\spycompat\Lib\site-packages\spyder\plugins\ipythonconsole\comms\kernelcomm.py", line 220, in _get_call_return_value
    raise CommError("Cannot block on a disconnected comm")
spyder_kernels.comms.commbase.CommError: Cannot block on a disconnected comm