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

Change dask_client to general setup method #861

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

RobbeSneyders
Copy link
Member

This PR changes the dask_client method introduced in #852 into a general setup method.

This method differs from __init__ in that it allows users to return a state, which is passed into the teardown method by Fondant. This is necessary since the Dask client is not pickleable, and setting it as an instance attribute leads to issues when executing the transform method across processes (as is the case in the PandasTransformComponent).

Comment on lines -458 to -462
with mock.patch.object(MyPandasComponent, "__init__", init), mock.patch.object(
MyPandasComponent,
"transform",
transform,
):
Copy link
Member Author

Choose a reason for hiding this comment

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

This was giving issues with recursion when pickling. I couldn't completely figure out the cause and how to fix it.

init.mock.assert_called_once()
assert transform.mock.call_count == N_PARTITIONS
executor.execute(MyPandasComponent)
assert init_called == 1
Copy link
Member Author

Choose a reason for hiding this comment

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

We cannot take the same approach for the transform method, since it's executed across Dask workers. Couldn't figure out how to make this work, so dropped the assertion for the transform method for now.

Copy link
Contributor

@mrchtr mrchtr left a comment

Choose a reason for hiding this comment

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

Thanks @RobbeSneyders.

@RobbeSneyders RobbeSneyders merged commit ae3aead into main Feb 20, 2024
11 checks passed
@RobbeSneyders RobbeSneyders deleted the feature/component-setup branch February 20, 2024 08:44
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.

2 participants