Skip to content
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

Pickling error for Graph, Node, Edge #274

Open
shadiakiki1986 opened this issue Sep 23, 2021 · 3 comments
Open

Pickling error for Graph, Node, Edge #274

shadiakiki1986 opened this issue Sep 23, 2021 · 3 comments

Comments

@shadiakiki1986
Copy link

Bug report

Bug summary

Cannot pickle ipycytoscape graph

Code for reproduction

ex_json = {
    "nodes": [
        {"data": {"id": 0, "name": "A"}},
        {"data": {"id": 1, "name": "B"}},
        {"data": {"id": 2, "name": "C"}}
    ],
    "edges": [
        {"data": {"id": 3, "source": 0, "target": 1}},
        {"data": {"id": 4, "source": 0, "target": 2}},
    ]
}

import ipycytoscape
cyto = ipycytoscape.CytoscapeWidget()
cyto.graph.add_graph_from_json(ex_json)

# pickling code in "actual outcome" section below

Actual outcome

# import pickle
# pickle.dumps(cyto) # PicklingError: Can't pickle <function <lambda> at 0x7fb6da6009d0>: attribute lookup <lambda> on jupyter_client.session failed
# pickle.dumps(cyto.graph) # AttributeError: Can't pickle local object 'Mutable.instance_init.<locals>.callback'
# pickle.dumps(cyto.graph.nodes[0]) # PicklingError: Can't pickle <function <lambda> at 0x7fb6da6009d0>: attribute lookup <lambda> on jupyter_client.session failed
#pickle.dumps(cyto.graph.edges[0]) # PicklingError: Can't pickle <function <lambda> at 0x7fb6da6009d0>: attribute lookup <lambda> on jupyter_client.session failed

#import dill
#dill.dumps(cyto.graph.nodes[0]) # TypeError: cannot pickle '_hashlib.HASH' object

#import cloudpickle
#cloudpickle.dumps(cyto.graph.nodes[0]) # TypeError: cannot pickle '_hashlib.HASH' object

Expected outcome

Result of pickle

Version Info

  • ipycytoscape version (import ipycytoscape; print(ipycytoscape.__version__)) : 1.2.2
  • Python version: 3.8.10
  • Jupyter(Lab) version:
!jupyter --version

Selected Jupyter core packages...
IPython          : 7.27.0
ipykernel        : 6.4.1
ipywidgets       : 7.6.5
jupyter_client   : 6.1.12
jupyter_core     : 4.8.1
jupyter_server   : 1.11.0
jupyterlab       : not installed
nbclient         : 0.5.4
nbconvert        : 6.1.0
nbformat         : 5.1.3
notebook         : 6.4.4
qtconsole        : not installed
traitlets        : 5.1.0
@MridulS
Copy link
Contributor

MridulS commented Sep 23, 2021

It's not possible to pickle a widget object, this probably needs to be solved upstream.

@shadiakiki1986
Copy link
Author

Ok, linking here for reference: jupyter-widgets/ipywidgets#2879

@marimeireles
Copy link
Collaborator

Thanks for pointing it to the right direction peeps. I personally didn't know that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants