@@ -63,7 +63,8 @@ def _rename_attributes(table, props):
6363 if props ['aliased' ] else table .proj ())
6464
6565 if self ._key_source is None :
66- parents = self .target .parents (primary = True , as_objects = True , foreign_key_info = True )
66+ parents = self .target .parents (
67+ primary = True , as_objects = True , foreign_key_info = True )
6768 if not parents :
6869 raise DataJointError ('A table must have dependencies '
6970 'from its primary key for auto-populate to work' )
@@ -74,17 +75,19 @@ def _rename_attributes(table, props):
7475
7576 def make (self , key ):
7677 """
77- Derived classes must implement method `make` that fetches data from tables that are
78- above them in the dependency hierarchy, restricting by the given key, computes dependent
79- attributes, and inserts the new tuples into self.
78+ Derived classes must implement method `make` that fetches data from tables
79+ above them in the dependency hierarchy, restricting by the given key,
80+ computes secondary attributes, and inserts the new tuples into self.
8081 """
81- raise NotImplementedError ('Subclasses of AutoPopulate must implement the method `make`' )
82+ raise NotImplementedError (
83+ 'Subclasses of AutoPopulate must implement the method `make`' )
8284
8385 @property
8486 def target (self ):
8587 """
8688 :return: table to be populated.
87- In the typical case, dj.AutoPopulate is mixed into a dj.Table class by inheritance and the target is self.
89+ In the typical case, dj.AutoPopulate is mixed into a dj.Table class by
90+ inheritance and the target is self.
8891 """
8992 return self
9093
@@ -111,11 +114,14 @@ def _jobs_to_do(self, restrictions):
111114
112115 if not isinstance (todo , QueryExpression ):
113116 raise DataJointError ('Invalid key_source value' )
114- # check if target lacks any attributes from the primary key of key_source
117+
115118 try :
119+ # check if target lacks any attributes from the primary key of key_source
116120 raise DataJointError (
117- 'The populate target lacks attribute %s from the primary key of key_source' % next (
118- name for name in todo .heading .primary_key if name not in self .target .heading ))
121+ 'The populate target lacks attribute %s '
122+ 'from the primary key of key_source' % next (
123+ name for name in todo .heading .primary_key
124+ if name not in self .target .heading ))
119125 except StopIteration :
120126 pass
121127 return (todo & AndList (restrictions )).proj ()
@@ -126,7 +132,8 @@ def populate(self, *restrictions, suppress_errors=False, return_exception_object
126132 """
127133 table.populate() calls table.make(key) for every primary key in self.key_source
128134 for which there is not already a tuple in table.
129- :param restrictions: a list of restrictions each restrict (table.key_source - target.proj())
135+ :param restrictions: a list of restrictions each restrict
136+ (table.key_source - target.proj())
130137 :param suppress_errors: if True, do not terminate execution.
131138 :param return_exception_objects: return error objects instead of just error messages
132139 :param reserve_jobs: if True, reserve jobs to populate in asynchronous fashion
@@ -259,5 +266,6 @@ def progress(self, *restrictions, display=True):
259266 print ('%-20s' % self .__class__ .__name__ ,
260267 'Completed %d of %d (%2.1f%%) %s' % (
261268 total - remaining , total , 100 - 100 * remaining / (total + 1e-12 ),
262- datetime .datetime .strftime (datetime .datetime .now (), '%Y-%m-%d %H:%M:%S' )), flush = True )
269+ datetime .datetime .strftime (datetime .datetime .now (),
270+ '%Y-%m-%d %H:%M:%S' )), flush = True )
263271 return remaining , total
0 commit comments