@@ -492,14 +492,18 @@ class Derived(dj.Computed):
492492
493493 def make (self , key ):
494494 captured .append (self ) # the actual populate instance
495- assert self ._upstream is not None # set for the duration of make()
495+ # Lazy: the trace is NOT built here because this make() never reads
496+ # self.upstream — but we ARE inside make() (the key is recorded).
497+ assert self ._upstream is None
498+ assert self ._upstream_key is not None
496499 self .insert1 ({** key , "val" : 0 })
497500
498501 Derived .populate ()
499502 assert captured , "make() did not run"
500503 inst = captured [0 ]
501- # The finally block must have cleared _upstream on this very instance.
502- assert inst ._upstream is None
504+ # The finally block must have cleared the make() key on this very instance —
505+ # that is what makes self.upstream raise afterward.
506+ assert inst ._upstream_key is None
503507 with pytest .raises (DataJointError , match = "only available inside make" ):
504508 inst .upstream
505509
@@ -529,15 +533,15 @@ class Boom(dj.Computed):
529533
530534 def make (self , key ):
531535 captured .append (self )
532- assert self ._upstream is not None
536+ assert self ._upstream_key is not None # inside make()
533537 raise RuntimeError ("make failed on purpose" )
534538
535539 with pytest .raises (RuntimeError , match = "make failed on purpose" ):
536540 Boom .populate (suppress_errors = False )
537541 assert captured , "make() did not run"
538542 inst = captured [0 ]
539543 # Cleared by the finally block even though make() raised.
540- assert inst ._upstream is None
544+ assert inst ._upstream_key is None
541545 with pytest .raises (DataJointError , match = "only available inside make" ):
542546 inst .upstream
543547
@@ -557,7 +561,7 @@ class Source(dj.Lookup):
557561 """
558562 contents = [(1 , 100 ), (2 , 200 )]
559563
560- seen = [] # (source_id, phase, id(self._upstream ))
564+ seen = [] # (source_id, phase, id(self.upstream ))
561565
562566 @schema
563567 class TriComputed (dj .Computed ):
@@ -568,15 +572,15 @@ class TriComputed(dj.Computed):
568572 """
569573
570574 def make_fetch (self , key ):
571- seen .append ((key ["source_id" ], "fetch" , id (self ._upstream )))
575+ seen .append ((key ["source_id" ], "fetch" , id (self .upstream )))
572576 return (self .upstream [Source ].fetch1 ("value" ),)
573577
574578 def make_compute (self , key , value ):
575- seen .append ((key ["source_id" ], "compute" , id (self ._upstream )))
579+ seen .append ((key ["source_id" ], "compute" , id (self .upstream )))
576580 return (value * 2 ,)
577581
578582 def make_insert (self , key , doubled ):
579- seen .append ((key ["source_id" ], "insert" , id (self ._upstream )))
583+ seen .append ((key ["source_id" ], "insert" , id (self .upstream )))
580584 self .insert1 ({** key , "result" : doubled })
581585
582586 TriComputed .populate ()
0 commit comments