Skip to content

Commit

Permalink
Disable disjoin table check
Browse files Browse the repository at this point in the history
  • Loading branch information
lajohn4747 committed May 2, 2024
1 parent 39f3187 commit b563422
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions sdv/metadata/multi_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,19 +475,19 @@ def _validate_all_tables_connected(self, parent_map, child_map):
if not connected[child] and child not in queue:
queue.append(child)

# if not all(connected.values()):
# disconnected_tables = [table for table, value in connected.items() if not value]
# if len(disconnected_tables) > 1:
# table_msg = (
# f'Tables {disconnected_tables} are not connected to any of the other tables.'
# )
# else:
# table_msg = (
# f'Table {disconnected_tables} is not connected to any of the other tables.'
# )

# raise InvalidMetadataError(
# f'The relationships in the dataset are disjointed. {table_msg}')
if not all(connected.values()):
disconnected_tables = [table for table, value in connected.items() if not value]
if len(disconnected_tables) > 1:
table_msg = (
f'Tables {disconnected_tables} are not connected to any of the other tables.'
)
else:
table_msg = (
f'Table {disconnected_tables} is not connected to any of the other tables.'
)

raise InvalidMetadataError(
f'The relationships in the dataset are disjointed. {table_msg}')

def _detect_relationships(self):
"""Automatically detect relationships between tables."""
Expand All @@ -513,14 +513,6 @@ def _detect_relationships(self):
sdtype=original_foreign_key_sdtype)
continue

try:
self._validate_all_tables_connected(self._get_parent_map(), self._get_child_map())
except InvalidMetadataError as invalid_error:
warning_msg = (
f'Could not automatically add relationships for all tables. {str(invalid_error)}'
)
warnings.warn(warning_msg)

def detect_table_from_dataframe(self, table_name, data):
"""Detect the metadata for a table from a dataframe.
Expand Down Expand Up @@ -733,14 +725,10 @@ def validate(self):
for relation in self.relationships:
self._append_relationships_errors(errors, self._validate_relationship, **relation)

parent_map = self._get_parent_map()
child_map = self._get_child_map()

self._append_relationships_errors(
errors, self._validate_child_map_circular_relationship, child_map)
self._append_relationships_errors(
errors, self._validate_all_tables_connected, parent_map, child_map)

if errors:
raise InvalidMetadataError(
'The metadata is not valid' + '\n'.join(str(e) for e in errors)
Expand Down

0 comments on commit b563422

Please sign in to comment.