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

Improve error handling when validating constraints #1210

Closed
npatki opened this issue Jan 27, 2023 · 0 comments
Closed

Improve error handling when validating constraints #1210

npatki opened this issue Jan 27, 2023 · 0 comments
Assignees
Labels
feature:constraints Related to inputting rules or business logic feature request Request for a new feature
Milestone

Comments

@npatki
Copy link
Contributor

npatki commented Jan 27, 2023

Problem Description

In the new version of SDV 1.0, I will be able to provide constraints using a dictionary format such as:

{
  'constraint_class': 'Inequality',
  'table_name': 'hotel_logs', # required for multi table
  'constraint_parameters': {
    'low_column_name': 'start_date'
    'high_column_name': 'end_date'
  }
}

Currently, there is a confusing errors if I don't provide the constraint_parameters key:

InvalidConstraintsError: The provided constraint is invalid:
Missing required values {'column_names'} in a CustomConstraint constraint.
'NoneType' object is not iterable

Expected behavior

We should explicitly check for the following:

  • In a multi table case, the top-level dictionary keys should be 'constraint_class', 'constraint_parameters' and 'table_name'
  • In single table, the top-level dictionary keys should be 'constraint_class' and 'constraint_parameters'

If the required top-level keys are not found, throw the following error:

SynthesizerInputError: A constraint is missing required parameters (<missing values>). Please add these parameters to your constraint definition.

Example:
SynthesizerInputError: A constraint is missing required parameters ('constraint_class'). Please add these parameters to your constraint definition.
SynthesizerInputError: A constraint is missing required parameters ('constraint_parameters', 'table_name'). Please add these parameters to your constraint definition.

If there are extra keys that are found, throw the following error:

SynthesizerInputError: Unrecognized constraint parameter (<example>). Please remove this parameter from your constraint definition.

Example
SynthesizerInputError: Unrecognized constraint parameter ('column_name'). Please remove this parameter from your constraint definition.
@npatki npatki added feature request Request for a new feature feature:constraints Related to inputting rules or business logic labels Jan 27, 2023
@npatki npatki added this to the 1.0.0 milestone Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:constraints Related to inputting rules or business logic feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants