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

Mock every usage of is_faker_function to speed up the unit tests #2158

Merged
merged 3 commits into from
Aug 7, 2024

Conversation

R-Palazzo
Copy link
Contributor

@R-Palazzo R-Palazzo commented Jul 31, 2024

CU-86b18qaaz
Resolve #2163

@R-Palazzo R-Palazzo self-assigned this Jul 31, 2024
@R-Palazzo R-Palazzo requested a review from a team as a code owner July 31, 2024 14:55
@sdv-team
Copy link
Contributor

@R-Palazzo R-Palazzo requested review from gsheni and removed request for a team August 1, 2024 14:43
@R-Palazzo R-Palazzo changed the title Metadata.add_column can be slow Mock every usage of is_faker_function to speed up the unit tests Aug 2, 2024
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.

Nice job, this is much faster! While we're at it can you fix this unit test to not actually fit and sample from the model. If we can just mock the _model part or something. This is the only test that still takes over a second

@R-Palazzo
Copy link
Contributor Author

Nice job, this is much faster! While we're at it can you fix this unit test to not actually fit and sample from the model. If we can just mock the _model part or something. This is the only test that still takes over a second

Hi @amontanez24, I didn’t find a good way to mock some methods while preserving the test logic, so I moved it to the integration folder. It also makes sense to have it in the integration tests because it validates end-to-end whether the estimated number of columns matches the actual one when we fit and sample HMA. There are still other tests in the unit folder for the _estimate_num_columns method. Let me know if it works. The change is in 75387aa

],
})
synthesizer = HMASynthesizer(metadata)
synthesizer._finalize = Mock(return_value=data)
Copy link
Member

Choose a reason for hiding this comment

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

@amontanez24 Are we allowed to use mocks in integration tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that's a good question. Ideally you wouldn't have to. This test is a little strange in that it is mocking the internals of another method (_finalize), to assert that the method under test is returning the right values. I'm not really sure of the context, so I don't know why this is the case.

Ideally, this test would just run _estimate_num_columns, and we'd know what the result should be and could just assert that outcome.

@R-Palazzo R-Palazzo merged commit 17aaa28 into main Aug 7, 2024
39 checks passed
@R-Palazzo R-Palazzo deleted the issue-2125-add-column branch August 7, 2024 06:42
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.

Mock every usage of is_faker_function to speed up the unit tests
4 participants