spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.18k stars 1.58k forks source link

Copying a Gurobi multidict #17016

Open jaBote opened 2 years ago

jaBote commented 2 years ago

Description

What steps will reproduce the problem?

I just tried to copy a Gurobi multidict from the variable explorer and this just happened.

Traceback

Traceback (most recent call last):
  File "C:\anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\widgets\namespacebrowser.py", line 102, in get_value
    return self.call_kernel(
  File "C:\anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 554, in __call__
    return self._comms_wrapper._get_call_return_value(
  File "C:\anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\comms\kernelcomm.py", line 216, in _get_call_return_value
    return super(KernelComm, self)._get_call_return_value(
  File "C:\anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 437, in _get_call_return_value
    return self._sync_error(reply['value'])
  File "C:\anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 493, in _sync_error
    error_wrapper.raise_error()
  File "C:\anaconda3\lib\site-packages\spyder_kernels\comms\commbase.py", line 90, in raise_error
    raise self.etype(self)
AttributeError: 'tuplelist' object has no attribute '_tuplelist__scalar'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\main_widget.py", line 636, in copy
    self._current_editor.copy()
  File "C:\anaconda3\lib\site-packages\spyder\widgets\collectionseditor.py", line 1096, in copy
    obj = self.delegate.get_value(idx)
  File "C:\anaconda3\lib\site-packages\spyder\widgets\collectionseditor.py", line 1437, in get_value
    return self.parent().get_value(name)
  File "C:\anaconda3\lib\site-packages\spyder\widgets\collectionseditor.py", line 1495, in get_value
    value = self.shellwidget.get_value(name)
  File "C:\anaconda3\lib\site-packages\spyder\plugins\ipythonconsole\widgets\namespacebrowser.py", line 117, in get_value
    raise ValueError(msg % reason_other)
ValueError: An error occured, see the console..<br><br>Note: Please don't report this problem on Github, there's nothing to do about it.

Versions

Dependencies


# Mandatory:
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  2.0.0 (OK)
cookiecutter >=1.6.0          :  1.7.2 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.6.0               :  7.29.0 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.0 (OK)
jsonschema >=3.2.0            :  3.2.0 (OK)
keyring >=17.0.0              :  23.1.0 (OK)
nbconvert >=4.0               :  6.1.0 (OK)
numpydoc >=0.6.0              :  1.1.0 (OK)
paramiko >=2.4.0              :  2.7.2 (OK)
parso >=0.7.0;<0.9.0          :  0.8.2 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.8.0 (OK)
pygments >=2.0                :  2.10.0 (OK)
pylint >=2.5.0;<2.10.0        :  2.9.6 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.2.2;<1.3.0          :  1.2.4 (OK)
pylsp_black >=1.0.0           :  None (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=1.0.2             :  1.0.3 (OK)
qtconsole >=5.1.0             :  5.1.1 (OK)
qtpy >=1.5.0                  :  1.10.0 (OK)
rtree >=0.9.7                 :  0.9.7 (OK)
setuptools >=49.6.0           :  58.0.4 (OK)
sphinx >=0.6.6                :  4.2.0 (OK)
spyder_kernels >=2.1.1;<2.2.0 :  2.1.3 (OK)
textdistance >=4.2.0          :  4.2.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.3 (OK)
zmq >=17                      :  22.2.1 (OK)

# Optional:
cython >=0.21                 :  0.29.24 (OK)
matplotlib >=2.0.0            :  3.4.3 (OK)
numpy >=1.7                   :  1.20.3 (OK)
pandas >=1.1.1                :  1.3.4 (OK)
scipy >=0.17.0                :  1.7.1 (OK)
sympy >=0.7.3                 :  1.9 (OK)
dalthviz commented 2 years ago

Hi @jaBote thank you for the feedback! Could you post here some example code to reproduce this in our side? Also, just in case, could you update spyder to our latests release and check again?

Let us know!

jaBote commented 2 years ago

Hello dalthviz:

Spyder says it's up to date.

Small steps to reproduce that error are simple (also happens with Gurobi models, tupledict, tuplelist, multidict). For example:

import gurobipy as g

var = g.tupledict()
var.update({"test":1})

Gives an error when trying to copy var from the variable explorer. Won't happen if the variable is empty (we didn't add anything to the tupledict in this case)

dalthviz commented 2 years ago

Thanks for the new info @jaBote ! Checking again this after setting up Gurobi I was able to reproduce the issue (I got a dialog message after trying to see the variable):

imagen

My guess is that we are not properly supporting getting the value of the Gurobi variables (which is not a problem if they are empty since there is no value to get in those cases).

I think this will need to be checked over spyder-kernels . What do you think @ccordoba12 ?

ccordoba12 commented 2 years ago

It seems those objects can't be serialized, so that's why they can't copied nor browsed. So perhaps the best we can do in this case is catch the error and pass.