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 BaseMultiTableSynthesizer #1178

Merged
merged 4 commits into from
Jan 20, 2023

Conversation

fealho
Copy link
Member

@fealho fealho commented Jan 19, 2023

Resolve #1171.

@fealho fealho changed the base branch from master to V1.0.0.dev January 19, 2023 19:39
Raises when the ``Unique`` constraint is passed.
"""
if self._fitted:
warnings.warn(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the warning here so it only shows once. If I used the SingleTable's add_constraints warning, it would show for every constraint in the list.

I'll add a test for the warning after you thumbs up this.

for constraint in constraints:
if constraint['constraint_class'] == 'Unique':
raise SynthesizerInputError(
"The constraint class 'Unique' is not currently supported."
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the message a little from the issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add to the end of this sentence "for multi-table synthesizers" so users don't think it's not supported at all

@fealho fealho marked this pull request as ready for review January 19, 2023 20:04
@fealho fealho requested a review from a team as a code owner January 19, 2023 20:04
@fealho fealho requested review from katxiao, amontanez24 and pvk-developer and removed request for a team and katxiao January 19, 2023 20:04
Copy link
Member

@pvk-developer pvk-developer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Nice catch on the warning!
I just left some nit picks but other than that it looks good!

Comment on lines 384 to 388
if constraint['constraint_class'] == 'Unique':
raise SynthesizerInputError(
"The constraint class 'Unique' is not currently supported."
'Please remove the constraint for this synthesizer.'
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we pull this in a function before this loop, to ensure that no other constraint was added to the data processor. Currently we have no way to remove or reset the constraints, @amontanez24 maybe we can add something for it ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That may be something we add later

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree though that if we can't add this constraint, we should either add all of the other ones, or none of the other ones. We don't want to crash half way through

Comment on lines 690 to 693
positive_constraint.pop('table_name')
negative_constraint.pop('table_name')
assert instance._table_synthesizers['nesreca'].get_constraints() == [positive_constraint]
assert instance._table_synthesizers['oseba'].get_constraints() == [negative_constraint]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we re-write this as a dict. The reason why is that if positive_constraint is being modified down the line and it's not stored as expected we may not capture it.

constraints = [positive_constraint, negative_constraint]

# Run
instance.add_constraints(constraints)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the setup.

@fealho fealho requested a review from pvk-developer January 20, 2023 18:01
Copy link
Contributor

@amontanez24 amontanez24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of typos but after that :shipit:

instance.add_constraints([])

def test_add_constraints(self):
"""Test a list of constraits can be added to the synthesizer."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: constraints

assert instance.get_constraints() == [positive_constraint, negative_constraint]

def test_get_constraints(self):
"""Test a list of constraits is returned by the method."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: constraints

@fealho fealho merged commit 129d3ba into V1.0.0.dev Jan 20, 2023
@fealho fealho deleted the issue-1171-constraint-methods branch January 20, 2023 21:32
amontanez24 pushed a commit that referenced this pull request Feb 17, 2023
* Address warnings issue

* Add tests to single table + address feedback

* Update err msg

* Fix typo
amontanez24 pushed a commit that referenced this pull request Mar 23, 2023
* Address warnings issue

* Add tests to single table + address feedback

* Update err msg

* Fix typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add constraint methods to MultiTableSynthesizers
3 participants