@@ -74,7 +74,7 @@ def _rename_attributes(table, props):
7474 )
7575
7676 if self ._key_source is None :
77- parents = self .target . parents (primary = True , as_objects = True , foreign_key_info = True )
77+ parents = self .parents (primary = True , as_objects = True , foreign_key_info = True )
7878 if not parents :
7979 raise DataJointError ("A table must have dependencies from its primary key for auto-populate to work" )
8080 self ._key_source = _rename_attributes (* parents [0 ])
@@ -151,15 +151,6 @@ def make(self, key):
151151 self .make_insert (key , * computed_result )
152152 yield
153153
154- @property
155- def target (self ):
156- """
157- :return: table to be populated.
158- In the typical case, dj.AutoPopulate is mixed into a dj.Table class by
159- inheritance and the target is self.
160- """
161- return self
162-
163154 @property
164155 def jobs (self ):
165156 """
@@ -173,7 +164,7 @@ def jobs(self):
173164 if self ._jobs_table is None :
174165 from .jobs import JobsTable
175166
176- self ._jobs_table = JobsTable (self . target )
167+ self ._jobs_table = JobsTable (self )
177168 return self ._jobs_table
178169
179170 def _jobs_to_do (self , restrictions ):
@@ -198,7 +189,7 @@ def _jobs_to_do(self, restrictions):
198189 raise DataJointError (
199190 "The populate target lacks attribute %s "
200191 "from the primary key of key_source"
201- % next (name for name in todo .heading .primary_key if name not in self .target . heading )
192+ % next (name for name in todo .heading .primary_key if name not in self .heading )
202193 )
203194 except StopIteration :
204195 pass
@@ -281,7 +272,7 @@ def handler(signum, frame):
281272 else :
282273 # Legacy behavior: get keys from key_source
283274 if keys is None :
284- keys = (self ._jobs_to_do (restrictions ) - self . target ).fetch ("KEY" , limit = limit )
275+ keys = (self ._jobs_to_do (restrictions ) - self ).fetch ("KEY" , limit = limit )
285276
286277 if order == "reverse" :
287278 keys .reverse ()
@@ -390,15 +381,15 @@ def _populate1(self, key, jobs, suppress_errors, return_exception_objects, make_
390381 if not is_generator :
391382 self .connection .start_transaction ()
392383
393- if key in self . target : # already populated
384+ if key in self : # already populated
394385 if not is_generator :
395386 self .connection .cancel_transaction ()
396387 if jobs is not None :
397388 # Job already done - mark complete or delete
398389 jobs .complete (key , duration = 0 )
399390 return False
400391
401- logger .debug (f"Making { key } -> { self .target . full_table_name } " )
392+ logger .debug (f"Making { key } -> { self .full_table_name } " )
402393 self .__class__ ._allow_insert = True
403394
404395 try :
@@ -429,7 +420,7 @@ def _populate1(self, key, jobs, suppress_errors, return_exception_objects, make_
429420 exception = error .__class__ .__name__ ,
430421 msg = ": " + str (error ) if str (error ) else "" ,
431422 )
432- logger .debug (f"Error making { key } -> { self .target . full_table_name } - { error_message } " )
423+ logger .debug (f"Error making { key } -> { self .full_table_name } - { error_message } " )
433424
434425 # Only log errors from inside make() - not collision errors
435426 if jobs is not None :
@@ -456,7 +447,7 @@ def _populate1(self, key, jobs, suppress_errors, return_exception_objects, make_
456447 else :
457448 self .connection .commit_transaction ()
458449 duration = time .time () - start_time
459- logger .debug (f"Success making { key } -> { self .target . full_table_name } " )
450+ logger .debug (f"Success making { key } -> { self .full_table_name } " )
460451 if jobs is not None :
461452 jobs .complete (key , duration = duration )
462453 return True
@@ -470,7 +461,7 @@ def progress(self, *restrictions, display=False):
470461 """
471462 todo = self ._jobs_to_do (restrictions )
472463 total = len (todo )
473- remaining = len (todo - self . target )
464+ remaining = len (todo - self )
474465 if display :
475466 logger .info (
476467 "%-20s" % self .__class__ .__name__
0 commit comments