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

Add constraint methods to MultiTableSynthesizers #1171

Closed
amontanez24 opened this issue Jan 10, 2023 · 0 comments · Fixed by #1178
Closed

Add constraint methods to MultiTableSynthesizers #1171

amontanez24 opened this issue Jan 10, 2023 · 0 comments · Fixed by #1178
Assignees
Labels
feature request Request for a new feature
Milestone

Comments

@amontanez24
Copy link
Contributor

amontanez24 commented Jan 10, 2023

Problem Description

As a user, it would be convenient to be able to add constraints to individual table synthesizers in my multi-table dataset.

Acceptance Criteria

  • Add wrapper methods to the BaseMultiTableSynthesizer for add_constraints and get_constraints.

Expected behavior

age_is_positive = {
  'constraint_class': 'Positive',
  'table_name': 'users',
  'constraint_parameters': {
    'column': 'age',
    'strict_boundaries': True
  }
}

my_custom_constraint = {
  'constraint_class': 'MyConstraintClass',
  'table_name': 'sessions',
  'constraint_parameters': {
    'custom_param_1': 34,
    'custom_param_2': True
  }
}

synthesizer.add_constraints(constraints=[age_is_positive, my_custom_constraint])
synthesizer.get_constraints()
[{
  'constraint_class': 'Positive',
  'table_name': 'users'
  'constraint_parameters': {
    'column': 'age',
    'strict_boundaries': True
  }
},
{
  'constraint_class': 'MyConstraintClass',
  'table_name': 'sessions',
  'constraint_parameters': {
    'custom_param_1': 34,
    'custom_param_2': True
  }
}]

Additional context

  • Notice that the constraint dict in the multi-table case is slightly different than in the single table case because it contains table_name. The reason for not nesting the dictionaries under the table name is that future constraints might be between multiple tables.
  • Test to make sure constraints other than Unique work

Error Case

MultiTableSynthesizers will not initially support the Unique constraint. If the user passes in any Unique constraint classes, throw an error.

unique_username = {
  'constraint_class': 'Unique',
  'table_name': 'users',
  'constraint_parameters': {
    'column': 'username',
  }
}

synthesizer.add_constraints(constraints=[unique_username])

SynthesizerInputError: Unsupported constraint class ('Unique'). Please remove the constraint for this synthesizer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants