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

[SPARK-51551] [ML] [PYTHON] [CONNECT] For tuning algorithm, allow using save / load to replace cache #50324

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

WeichenXu123
Copy link
Contributor

What changes were proposed in this pull request?

For tuning algorithm, allow using save / load to replace cache.

Why are the changes needed?

Dataframe persisting is not well supported in certain cases, so we need a replacement.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Manually.

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

No.

Signed-off-by: Weichen Xu <[email protected]>
@WeichenXu123 WeichenXu123 marked this pull request as draft March 19, 2025 10:32
Copy link
Contributor

@zhengruifeng zhengruifeng left a comment

Choose a reason for hiding this comment

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

need tests against this change

@@ -75,6 +76,15 @@
]


_SPARKML_TUNING_TEMP_DFS_PATH = "SPARKML_TUNING_TEMP_DFS_PATH"
Copy link
Contributor

Choose a reason for hiding this comment

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

what about a new parameter instead of this env variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spark config is not available in some circumstances. so I suggest to use environmental variable to config.

Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
@WeichenXu123 WeichenXu123 marked this pull request as ready for review March 20, 2025 10:01
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
validation = datasets[i][1]
train = datasets[i][0]

if tmp_dfs_path:
Copy link
Contributor

Choose a reason for hiding this comment

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

let's define a helper function:


def _cache(df):
    if ...:
        df.cache()
    else:
        spark = df._session
        df.save
        spark.read...


Copy link
Contributor Author

Choose a reason for hiding this comment

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

then we need to handler the uncache step together in the helper function, i.e., it should be a context manager. is this you want ?

Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[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.

2 participants