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

dj.ERD(schema) runs into TypeError #1072

Open
horsto opened this issue Feb 8, 2023 · 3 comments
Open

dj.ERD(schema) runs into TypeError #1072

horsto opened this issue Feb 8, 2023 · 3 comments
Assignees
Labels

Comments

@horsto
Copy link
Contributor

horsto commented Feb 8, 2023

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
@horsto horsto added the bug label Feb 8, 2023
@kabilar
Copy link
Contributor

kabilar commented 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 dimitri-yatsenko self-assigned this Sep 12, 2024
@dimitri-yatsenko
Copy link
Member

@horsto If you can reproduce this, please let us know. Otherwise, we will close this.

@dimitri-yatsenko
Copy link
Member

This may be already fixed and we cannot reproduce it. This may have been fixed by #1177

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

Successfully merging a pull request may close this issue.

3 participants