0

The following code

@schema
class A(dj.Manual):
    definition = """
    a: varchar(1)
    """
    
a = A()
a.insert1(["a"], skip_duplicates=True)
    
@schema
class B(dj.Manual):
    definition = """
    b: varchar(1)
    """    
    
@schema
class C(dj.Computed):
    definition = """
    -> A
    -> B
    """
    
    def _make_tuples(self, key):
        self.insert1(key)

raises DataJointError: Foreign key reference A could not be resolved. On my machine just this toy example reproduces this error -- what could possibly be going on, it is defined right there!

zagaroo
  • 31
  • 4
  • This works for me if I bump `a.insert` to the end. I also changed `_make_tuples` to `make` – Chris Broz Aug 15 '22 at 13:59
  • The code you provided looks correct and worked fine after testing. Perhaps more information and context are needed to learn why this error occurs in your code. – Dimitri Yatsenko Aug 15 '22 at 15:29
  • @DimitriYatsenko thanks. I've since had this error a few more times in unrelated contexts (Foreign key reference could not be resolved, where the foreign key exists in the database) but am unsure to go about debugging something like this. Even stripping my code down to the bare minimum (2-3 tables) it seems to happen in some cases and not others, seemingly randomly. What would be a good starting point? – zagaroo Aug 25 '22 at 18:36
  • Hm... I have not see this error. It would be great to have enough information to be able to reproduce it. If you provide the error stack, it would be helpful too. – Dimitri Yatsenko Aug 26 '22 at 21:08
  • 1
    @DimitriYatsenko after about 4 months I realized the issue was to do with the `locals()` in the schema definition – zagaroo Dec 07 '22 at 07:58

0 Answers0