Skip to content

Commit 55b7199

Browse files
committed
Merge branch 'master' into dj-top-1084-continued
2 parents e4fa467 + b9d8488 commit 55b7199

File tree

6 files changed

+46
-6
lines changed

6 files changed

+46
-6
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM mcr.microsoft.com/devcontainers/python:${PY_VER}-${DISTRO}
44
RUN \
55
apt update && \
66
apt-get install bash-completion graphviz default-mysql-client -y && \
7-
pip install flake8 black faker ipykernel pytest pytest-cov nose nose-cov datajoint && \
7+
pip install flake8 black faker ipykernel pytest pytest-cov nose nose-cov datajoint jupyterlab && \
88
pip uninstall datajoint -y
99

1010
USER root

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"features": {
3333
"ghcr.io/devcontainers/features/git:1": {},
3434
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
35+
"ghcr.io/devcontainers/features/github-cli:1": {},
3536
},
3637
// Configure tool-specific properties.
3738
"customizations": {

.github/workflows/development.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ jobs:
108108
- name: Run style tests
109109
run: |
110110
flake8 --ignore=E203,E722,W503 datajoint \
111-
--count --max-complexity=62 --max-line-length=127 --statistics
111+
--count --max-complexity=62 --max-line-length=127 --statistics \
112+
--per-file-ignores='datajoint/diagram.py:C901'
112113
black --required-version '24.2.0' --check -v datajoint tests tests_old
113114
codespell:
114115
name: Check for spelling errors
@@ -189,7 +190,7 @@ jobs:
189190
prerelease: false
190191
draft: false
191192
- name: Fetch pip artifacts
192-
uses: actions/download-artifact@v3
193+
uses: actions/download-artifact@v4.1.7
193194
with:
194195
name: pip-datajoint-${{env.DJ_VERSION}}
195196
path: dist

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### 0.14.3 -- TBD
44
- Added - `dj.Top` restriction ([#1024](https://github.com/datajoint/datajoint-python/issues/1024)) PR [#1084](https://github.com/datajoint/datajoint-python/pull/1084)
5+
- Fixed - Added encapsulating double quotes to comply with [DOT language](https://graphviz.org/doc/info/lang.html) - PR [#1177](https://github.com/datajoint/datajoint-python/pull/1177)
56

67
### 0.14.2 -- Aug 19, 2024
78
- Added - Migrate nosetests to pytest - PR [#1142](https://github.com/datajoint/datajoint-python/pull/1142)

datajoint/diagram.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,36 @@ def _make_graph(self):
300300
nx.relabel_nodes(graph, mapping, copy=False)
301301
return graph
302302

303+
@staticmethod
304+
def _encapsulate_edge_attributes(graph):
305+
"""
306+
Modifies the `nx.Graph`'s edge attribute `attr_map` to be a string representation
307+
of the attribute map, and encapsulates the string in double quotes.
308+
Changes the graph in place.
309+
310+
Implements workaround described in
311+
https://github.com/pydot/pydot/issues/258#issuecomment-795798099
312+
"""
313+
for u, v, *_, edgedata in graph.edges(data=True):
314+
if "attr_map" in edgedata:
315+
graph.edges[u, v]["attr_map"] = '"{0}"'.format(edgedata["attr_map"])
316+
317+
@staticmethod
318+
def _encapsulate_node_names(graph):
319+
"""
320+
Modifies the `nx.Graph`'s node names string representations encapsulated in
321+
double quotes.
322+
Changes the graph in place.
323+
324+
Implements workaround described in
325+
https://github.com/datajoint/datajoint-python/pull/1176
326+
"""
327+
nx.relabel_nodes(
328+
graph,
329+
{node: '"{0}"'.format(node) for node in graph.nodes()},
330+
copy=False,
331+
)
332+
303333
def make_dot(self):
304334
graph = self._make_graph()
305335
graph.nodes()
@@ -368,6 +398,8 @@ def make_dot(self):
368398
for node, d in dict(graph.nodes(data=True)).items()
369399
}
370400

401+
self._encapsulate_node_names(graph)
402+
self._encapsulate_edge_attributes(graph)
371403
dot = nx.drawing.nx_pydot.to_pydot(graph)
372404
for node in dot.get_nodes():
373405
node.set_shape("circle")
@@ -408,9 +440,14 @@ def make_dot(self):
408440

409441
for edge in dot.get_edges():
410442
# see https://graphviz.org/doc/info/attrs.html
411-
src = edge.get_source().strip('"')
412-
dest = edge.get_destination().strip('"')
443+
src = edge.get_source()
444+
dest = edge.get_destination()
413445
props = graph.get_edge_data(src, dest)
446+
if props is None:
447+
raise DataJointError(
448+
"Could not find edge with source "
449+
"'{}' and destination '{}'".format(src, dest)
450+
)
414451
edge.set_color("#00000040")
415452
edge.set_style("solid" if props["primary"] else "dashed")
416453
master_part = graph.nodes[dest][

datajoint/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = "0.14.2"
1+
__version__ = "0.14.3"
22

33
assert len(__version__) <= 10 # The log table limits version to the 10 characters

0 commit comments

Comments
 (0)