Skip to content

[SPARK-51880][ML][PYTHON][CONNECT] Fix ML cache object python client references #50707

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

Closed
wants to merge 15 commits into from

Conversation

WeichenXu123
Copy link
Contributor

@WeichenXu123 WeichenXu123 commented Apr 25, 2025

What changes were proposed in this pull request?

Fix ML cache object python client references.

When a model is copied from client, it results in multiple client model objects refer to the same server cached model.
In this case, we need a reference count, only when reference count decreases to zero, we can release the server cached model.

Why are the changes needed?

Bugfix.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Unit tests.

Was this patch authored or co-authored using generative AI tooling?

No.

Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
@github-actions github-actions bot removed the SQL label Apr 27, 2025
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
@zhengruifeng
Copy link
Contributor

merged to master

@@ -1981,9 +1981,10 @@ def add_ml_cache(self, cache_id: str) -> None:
self.thread_local.ml_caches.add(cache_id)

def remove_ml_cache(self, cache_id: str) -> None:
deleted = self._delete_ml_cache([cache_id])
# TODO: Fix the code: change thread-local `ml_caches` to global `ml_caches`.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO

Kimahriman pushed a commit to Kimahriman/spark that referenced this pull request May 13, 2025
…references

### What changes were proposed in this pull request?

Fix ML cache object python client references.

When a model is copied from client, it results in multiple client model objects refer to the same server cached model.
In this case, we need a reference count, only when reference count decreases to zero, we can release the server cached model.

### Why are the changes needed?

Bugfix.

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Unit tests.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#50707 from WeichenXu123/ml-ref-id-fix.

Lead-authored-by: Weichen Xu <[email protected]>
Co-authored-by: WeichenXu <[email protected]>
Signed-off-by: Ruifeng Zheng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants