Skip to content

Commit

Permalink
Enhance: Improve the error message when the Metadata is empty. (#2257)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvk-developer authored Oct 8, 2024
1 parent 6ae4840 commit 241acf4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions sdv/metadata/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ def _convert_to_single_table(self):

def _handle_table_name(self, table_name):
if len(self.tables) == 0:
raise ValueError(
'The metadata object is currently empty. To populate it, please use either '
"'detect_from_dataframe' or 'detect_from_dataframes'."
)
raise ValueError('Metadata does not contain any tables. No columns can be added.')
if table_name is None:
if len(self.tables) == 1:
table_name = next(iter(self.tables))
Expand Down
5 changes: 1 addition & 4 deletions tests/unit/metadata/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,6 @@ def test__handle_table_name_with_empty_tables(self):
instance = Metadata()

# Run and Assert
error_msg = (
'The metadata object is currently empty. To populate it, please use either '
"'detect_from_dataframe' or 'detect_from_dataframes'."
)
error_msg = 'Metadata does not contain any tables. No columns can be added.'
with pytest.raises(ValueError, match=error_msg):
instance._handle_table_name(None)

0 comments on commit 241acf4

Please sign in to comment.