Skip to content

DataJoint Diagram does not work with the latest version of pydot/networkx across Python 3.10-3.12; encapsulating double quotes needed #1175

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

Closed
tabedzki opened this issue Sep 5, 2024 · 1 comment · Fixed by #1177
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@tabedzki
Copy link
Contributor

tabedzki commented Sep 5, 2024

Bug Report

Description

DataJoint's Diagram feature does not work properly with recent versions of pydot and networkx packages because node_ids containing . are not encapsulated in double quotes " an required by DOT language specification for graphviz. This is seen when examining the dot string representation generated by networkx.drawing.nx_pydot.to_pydot

# Generate the diagram
diagram = dj.Diagram(ephys_element)
pydot_graph = diagram.make_dot()
dot_str = pydot_graph.to_string()
print(dot_str)

Trunctaed dot_str below. This fails when run through dot -Tsvg but passes if wrapped in ".

strict digraph  {
ephys_element.AcquisitionSoftware;
}

Testing of networkx

Here is a working example using networkx directly:

import networkx as nx
from networkx.drawing.nx_pydot import to_pydot

# Create a new graph
G = nx.DiGraph()

# Add two nodes
node_1 = '"a.a"'
G.add_node(node_1)
# Convert the graph to a pydot object
pydot_graph = to_pydot(G)

and excluding the double quotes results in the same error as calling Diagram()

import networkx as nx
from networkx.drawing.nx_pydot import to_pydot

# Create a new graph
G = nx.DiGraph()

# Add two nodes
node_1 = 'a.a'
G.add_node(node_1)
# Convert the graph to a pydot object
pydot_graph = to_pydot(G)
"dot" with args ['-Tsvg', '/var/folders/98/ncnp2y1n00qc_4y4ndc9mw240000gp/T/tmpj1xh62up'] returned code: 1

stdout, stderr:
 b''
b"Error: [/var/folders/98/ncnp2y1n00qc_4y4ndc9mw240000gp/T/tmpj1xh62up](https://file+.vscode-resource.vscode-cdn.net/var/folders/98/ncnp2y1n00qc_4y4ndc9mw240000gp/T/tmpj1xh62up): syntax error in line 2 near '.'\n"

Reproducibility

Include:

  • OS ( MACOS)
  • Python Version: 3.10-3.12
  • MySQL Version: N/A
  • MySQL Deployment Strategy (local-native | local-docker | remote): N/A
  • DataJoint Version: 0.14.2
  • Minimum number of steps to reliably reproduce the issue: 1
  • Complete error stack as a result of evaluating the above steps
@ethho
Copy link
Contributor

ethho commented Sep 6, 2024

Duplicates #1169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
2 participants