datajoint-python icon indicating copy to clipboard operation
datajoint-python copied to clipboard

`.parts` not always returning parts

Open christoph-blessing opened this issue 1 year ago • 2 comments

Bug Report

Description

Sometimes the .parts property on tables returns an empty list even if the table has parts.

    @schema
    class MyTable(dj.Manual):
        definition = """
        a: int
        ---
        b: int
        """

        class MyFirstPart(dj.Part):
            definition = """
            -> master       
            ---
            c: int
            """

        class MySecondPart(dj.Part):
            definition = """
            -> master       
            ---
            d: int
            """

    # MyTable().connection.dependencies.load()  # Uncommenting this fixes the problem
    assert MyTable().parts(as_objects=True) is []  # Should error but doesn't

Reproducibility

  • LINUX
  • Python 3.8
  • DataJoint Version 0.12.9

christoph-blessing avatar Jul 24 '23 14:07 christoph-blessing

Thanks for the report @cblessing24. I was able to replicate this issue in DataJoint Python version 0.14.1.

@dimitri-yatsenko Would you suggest that I add the following line to the parts method? Or is there a different issue going on? Thanks.

self.connection.dependencies.load() 

kabilar avatar Jul 24 '23 16:07 kabilar

looking into this. Yes it appears that the function assumes that the dependencies have been loaded.

dimitri-yatsenko avatar Jul 24 '23 16:07 dimitri-yatsenko