Repository navigation
dj.ERD(schema) runs into TypeError #1072
Copy link
Copy link
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior
Description
Bug Report
schema = dj.schema('MY_DATABASE')
dj.ERD(schema) runs into
File ~\miniconda3\envs\detectron\lib\site-packages\datajoint\diagram.py:428, in Diagram.make_svg(self)
425 def make_svg(self):
426 from IPython.display import SVG
--> 428 return SVG(self.make_dot().create_svg())
File ~\miniconda3\envs\detectron\lib\site-packages\datajoint\diagram.py:306, in Diagram.make_dot(self)
304 def make_dot(self):
--> 306 graph = self._make_graph()
307 graph.nodes()
309 scale = 1.2 # scaling factor for fonts and boxes
File ~\miniconda3\envs\detectron\lib\site-packages\datajoint\diagram.py:292, in Diagram._make_graph(self)
288 nx.set_node_attributes(
289 graph, name="node_type", values={n: _get_tier(n) for n in graph}
290 )
291 # relabel nodes to class names
--> 292 mapping = {
293 node: lookup_class_name(node, self.context) or node
294 for node in graph.nodes()
295 }
296 new_names = [mapping.values()]
297 if len(new_names) > len(set(new_names)):
File ~\miniconda3\envs\detectron\lib\site-packages\datajoint\diagram.py:293, in <dictcomp>(.0)
288 nx.set_node_attributes(
289 graph, name="node_type", values={n: _get_tier(n) for n in graph}
290 )
291 # relabel nodes to class names
292 mapping = {
--> 293 node: lookup_class_name(node, self.context) or node
294 for node in graph.nodes()
295 }
296 new_names = [mapping.values()]
297 if len(new_names) > len(set(new_names)):
File ~\miniconda3\envs\detectron\lib\site-packages\datajoint\table.py:980, in lookup_class_name(name, context, depth)
972 elif (
973 node["depth"] > 0
974 and inspect.ismodule(member)
975 and member.__name__ != "datajoint"
976 ):
977 try:
978 nodes.append(
979 dict(
--> 980 context=dict(inspect.getmembers(member)),
981 context_name=node["context_name"] + "." + member_name,
982 depth=node["depth"] - 1,
983 )
984 )
985 except ImportError:
986 pass # could not import, so do not attempt
File ~\miniconda3\envs\detectron\lib\inspect.py:458, in getmembers(object, predicate)
454 # :dd any DynamicClassAttributes to the list of names if object is a class;
455 # this may result in duplicate entries if, for example, a virtual
456 # attribute with the same name as a DynamicClassAttribute exists
457 try:
--> 458 for base in object.__bases__:
459 for k, v in base.__dict__.items():
460 if isinstance(v, types.DynamicClassAttribute):
TypeError: '_ClassNamespace' object is not iterable
Description
Sometimes (and I don't know exactly when), the generation of dj Diagrams does not work. See error above.
Reproducibility
Include:
- OS: Windows 11 Pro
- Python 3.10.6
- DataJoint Version
0.13.8
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behavior
Activity
kabilar commentedon Jun 29, 2023
Hi @horsto, is this still an issue for you? If so, could you please send me a copy of your module so that I can replicate this error?
dimitri-yatsenko commentedon Sep 12, 2024
@horsto If you can reproduce this, please let us know. Otherwise, we will close this.
dimitri-yatsenko commentedon Sep 13, 2024
This may be already fixed and we cannot reproduce it. This may have been fixed by #1177
fix: handle TypeError in lookup_class_name for Diagram (#1072)
fix: handle TypeError in lookup_class_name for Diagram (#1072) (#1317)
dimitri-yatsenko commentedon Jan 9, 2026
Fixed in #1317