Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError raised when adding columns to a new Metadata instance #2252

Closed
pvk-developer opened this issue Oct 3, 2024 · 1 comment · Fixed by #2255
Closed

ValueError raised when adding columns to a new Metadata instance #2252

pvk-developer opened this issue Oct 3, 2024 · 1 comment · Fixed by #2255
Assignees
Labels
internal The issue doesn't change the API or functionality
Milestone

Comments

@pvk-developer
Copy link
Member

pvk-developer commented Oct 3, 2024

Environment Details

Please indicate the following details about the environment in which you found the bug:

  • SDV version: 1.17.0
  • Python version: any
  • Operating System: any

Error Description

When creating a new Metadata instance and trying to add new columns, a ValueError is raised indicating that it has more than one table.

Steps to reproduce

from sdv.metadata import Metadata

metadata = Metadata()
metadata.add_column(column_name='a', sdtype='numerical')

ValueError: Metadata contains more than one table, please specify the `table_name`.

Notice that the metadata is an empty Metadata object:

In [7]: metadata
Out[7]: 
{
    "tables": {},
    "relationships": [],
    "METADATA_SPEC_VERSION": "V1"
}

Expected Behavior

We should raise a proper error message:

The metadata object is empty, please use `Metadata.detect_from_dataframe` to populate the metadata.
@srinify
Copy link
Contributor

srinify commented Oct 8, 2024

Hmm IMO I'm not sure the error message is necessarily what we want to convey @pvk-developer because this implies people are only using the standard synthesizers. cc @npatki

With DayZ, you wouldn't be able to use detect_from_dataframe() or if you read in metadata from the BigQuery connector -- so this feels like too specific of an error message?

So I'm wondering if we should instead try to either nudge the user to create a table in the metadata (using the Metadata.create_table() method):

metadata = Metadata()
metadata.add_table('step_counts')

@pvk-developer pvk-developer added this to the 1.17.1 milestone Oct 8, 2024
@pvk-developer pvk-developer added internal The issue doesn't change the API or functionality and removed bug Something isn't working labels Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal The issue doesn't change the API or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants