@@ -82,14 +82,17 @@ def _set_temp_numpy_seed(self):
8282
8383 def _initialize_models (self ):
8484 with disable_single_table_logger ():
85- for table_name , table_metadata in self .metadata .tables .items ():
85+ for table_name , table_metadata in self ._modified_multi_table_metadata .tables .items ():
8686 synthesizer_parameters = {'locales' : self .locales }
8787 synthesizer_parameters .update (self ._table_parameters .get (table_name , {}))
8888 metadata_dict = {'tables' : {table_name : table_metadata .to_dict ()}}
8989 metadata = Metadata .load_from_dict (metadata_dict )
9090 self ._table_synthesizers [table_name ] = self ._synthesizer (
9191 metadata = metadata , ** synthesizer_parameters
9292 )
93+ # Mark synthesizer as embedded in a multi-table setting
94+ # so it can suppres datetime_format warnings that are aggregated here
95+ self ._table_synthesizers [table_name ]._suppress_datetime_format_warning = True
9396 self ._table_synthesizers [table_name ]._data_processor .table_name = table_name
9497
9598 def _get_pbar_args (self , ** kwargs ):
@@ -129,7 +132,7 @@ def __init__(self, metadata, locales=['en_US'], synthesizer_kwargs=None):
129132 self ._original_metadata = deepcopy (self .metadata )
130133 self ._modified_multi_table_metadata = deepcopy (self .metadata )
131134 self .constraints = []
132- self ._has_seen_single_table_constraint = False
135+ self ._single_table_constraints = []
133136 if synthesizer_kwargs is not None :
134137 warn_message = (
135138 'The `synthesizer_kwargs` parameter is deprecated as of SDV 1.2.0 and does not '
@@ -177,9 +180,10 @@ def _detect_single_table_constraints(self, constraints):
177180 constraints (list):
178181 A list of constraints to filter.
179182 """
180- idx_single_table_constraint = 0 if self ._has_seen_single_table_constraint else None
183+ has_seen_single_table_constraint = len (self ._single_table_constraints ) > 0
184+ idx_single_table_constraint = 0 if has_seen_single_table_constraint else None
181185 for idx , constraint in enumerate (constraints ):
182- if self . _has_seen_single_table_constraint and constraint ._is_single_table is False :
186+ if has_seen_single_table_constraint and constraint ._is_single_table is False :
183187 raise SynthesizerInputError (
184188 'Cannot apply multi-table constraint after single-table constraint has '
185189 'been applied.'
@@ -188,8 +192,8 @@ def _detect_single_table_constraints(self, constraints):
188192 if not constraint ._is_single_table :
189193 continue
190194
191- if not self . _has_seen_single_table_constraint :
192- self . _has_seen_single_table_constraint = True
195+ if not has_seen_single_table_constraint :
196+ has_seen_single_table_constraint = True
193197 idx_single_table_constraint = idx
194198
195199 return idx_single_table_constraint
@@ -231,20 +235,21 @@ def add_constraints(self, constraints):
231235 self .constraints += multi_table_constraints
232236 self ._constraints_fitted = False
233237 self ._initialize_models ()
234- if single_table_constraints :
235- for constraint in single_table_constraints :
238+ if self . _single_table_constraints or single_table_constraints :
239+ for constraint in [ * self . _single_table_constraints , * single_table_constraints ] :
236240 table_name = constraint .table_name
237241 self ._table_synthesizers [table_name ].add_constraints ([constraint ])
238242 try :
239243 self .metadata = constraint .get_updated_metadata (self .metadata )
240244 except ConstraintNotMetError :
241245 constraint .get_updated_metadata (self ._modified_multi_table_metadata )
242246
247+ self ._single_table_constraints += single_table_constraints
248+
243249 def get_constraints (self ):
244250 """Get a copy of the list of constraints applied to the synthesizer."""
245251 if not hasattr (self , 'constraints' ):
246252 return []
247-
248253 constraints = []
249254 for constraint in self .constraints :
250255 if isinstance (constraint , ProgrammableConstraintHarness ):
@@ -404,6 +409,8 @@ def set_table_parameters(self, table_name, table_parameters):
404409 self ._table_synthesizers [table_name ] = self ._synthesizer (
405410 metadata = table_metadata , ** table_parameters
406411 )
412+ # Mark synthesizer as embedded in a multi-table setting to avoid duplicate datetime warnings
413+ self ._table_synthesizers [table_name ]._suppress_datetime_format_warning = True
407414 self ._table_synthesizers [table_name ]._data_processor .table_name = table_name
408415 self ._table_parameters [table_name ].update (deepcopy (table_parameters ))
409416
0 commit comments