← Back to Pull requests

chore(spark): replace pyspark-connect with pyspark-client (#781) #795

Merged
Neha-Nimsatkar merged 4 files (408 lines) on Oct 02, 2026 17:14 UTC
View on GitHub
Neha-Nimsatkar Neha-Nimsatkar commented on Sep 10, 2026 13:40 UTC
Author

<!-- Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, check our contributor guidelines: https://www.kubeflow.org/docs/about/contributing
2. To know more about Kubeflow SDK, check the developer guide:
https://github.com/kubeflow/sdk/blob/main/CONTRIBUTING.md
3. If you want faster PR reviews, check how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
-->

What this PR does / why we need it:
Replaces the heavy pyspark-connect dependency with pyspark-client to remove unnecessary JVM/JAR runtime dependencies from the client environment while maintaining remote Spark Connect functionality (sc://).

Audit & Investigation Findings:


  • JAR Count Reduction: Reduced .jar count in .venv from 324 down to 0 (find .venv -name '.jar' | wc -l returned 0).

  • Dependencies Removed: Stripped transitive JVM runtime dependencies pyspark==4.2.0 and py4j==0.10.9.9.

  • Spark Version Alignment (4.2.0 → 4.0.4): Aligned pyspark-client to version 4.0.4 (matching DEFAULT_SPARK_VERSION and apache/spark:4.0.4), eliminating client/server protocol skew and preventing unintended runtime drift from floating 4.2.0.

  • Import Check: Verified from pyspark.sql import SparkSession imports cleanly without JVM dependencies.
  • Local Verification:


  • make verify (linting, formatting, and type checks passed)

  • make test-python (695/695 unit tests passed)

  • test_spark_connect_crd_smoke passed

  • Added entry to CHANGELOG/CHANGELOG-0.5.md covering pyspark-client migration, sc:// remote requirement, and JAR/Py4J removal.
  • Which issue(s) this PR fixes (optional, in Fixes #<issue number>, #<issue number>, ... format, will close the issue(s) when PR gets merged)*:

    Fixes #781

    Checklist:

  • Docs included if any changes are user facing
  • Diff: 408 lines (+152 / -256) across 4 files Reviewer: RobuRishabh Review duration: 31893m
    All Vouch review confidence checks passed
    Residual risk 0.08 = Change Risk (0.43) × (1 − Review Confidence (0.81)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 408 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.72 · 5 substantive comment(s)
    0.72
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    81%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.360
    Real PR Conversation Timeline
    15 items
    github-actions[bot] github-actions[bot] commented on Sep 10, 2026 13:41 UTC
    Bot

    🎉 Welcome to the Kubeflow SDK! 🎉

    Thanks for opening your first PR! We're happy to have you as part of our community 🚀

    Here's what happens next:

  • If you haven't already, please check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards

  • Our team will review your PR soon! cc @kubeflow/kubeflow-sdk-team
  • Join the community:

  • Slack: Join our #kubeflow-ml-experience and #kubeflow-trainer Slack channels

  • Meetings: Attend the Kubeflow SDK and ML Experience bi-weekly meetings
  • Feel free to ask questions in the comments if you need any help or clarification!
    Thanks again for contributing to Kubeflow! 🙏

    tariq-hasan tariq-hasan commented on Sep 10, 2026 13:49 UTC
    Contributor

    /ok-to-test
    /retest

    RobuRishabh RobuRishabh commented on Sep 11, 2026 22:37 UTC
    Contributor

    Hi @Neha-Nimsatkar thanks for this PR. Can you add a short CHANGELOG entry for the next release covering: [spark] now installs pyspark-client, remote-only via sc://, and full PySpark/Py4J/JARs no longer installed.

    Optionally mention the 4.2.0 → 4.0.4 alignment in the PR description, it’s a meaningful improvement worth calling out.

    Overall this looks good to me from a functionality and safety perspective. Nice work on #781!
    cc: @tariq-hasan @Shekharrajak

    Neha-Nimsatkar Neha-Nimsatkar commented on Sep 12, 2026 08:31 UTC
    Author

    @RobuRishabh Thanks for the review!

  • Added the CHANGELOG entry under CHANGELOG/CHANGELOG-0.5.md covering the pyspark-client migration, remote-only sc:// requirements, and removal of bundled JARs/Py4J.

  • Updated the PR description to call out the 4.2.0 → 4.0.4 version alignment with the Spark operator image.
  • All pre-commit checks and DCO sign-offs are in place. Ready for your final look!

    RobuRishabh RobuRishabh approved these changes on Sep 14, 2026 14:39 UTC
    Approved Reviewer

    Approved these changes.

    Shekharrajak Shekharrajak commented on Sep 17, 2026 11:08 UTC
    Contributor

    /lgtm
    /approve

    Shekharrajak Shekharrajak commented on Sep 17, 2026 11:21 UTC
    Contributor

    /assign @astefanutti

    tariq-hasan tariq-hasan commented on Sep 24, 2026 15:22 UTC
    Contributor

    We should remove the changelog. It’s auto-generated as part of cliff.toml.

    Neha-Nimsatkar Neha-Nimsatkar commented on Sep 28, 2026 06:28 UTC
    Author

    We should remove the changelog. It’s auto-generated as part of cliff.toml.

    Thanks @tariq-hasan , I have Reverted the changelog file and squashed down to a single clean commit .

    RobuRishabh RobuRishabh commented on Oct 02, 2026 01:43 UTC
    Contributor

    /lgtm

    Hi @andreyvelich @astefanutti @kramaranya @Electronic-Waste this PR has a direct security impact worth prioritizing.

    The current pyspark-connect dependency pulls in the full pyspark package (324 bundled JARs) including CVE-prone Java libraries (Jackson, Netty, Log4j components, Hadoop, etc.) that the SDK never uses, it only talks to Spark Connect servers over gRPC. Vulnerability scanners flag these JARs, creating noise and blocking deployments for teams with compliance gates. Switching to pyspark-client drops these JARs, removes py4j and zstandard, fixes the 4.2.0→4.0.4 version skew, and all CI checks (including E2E) are green. It's a drop-in replacement with no API changes.

    Could we get /approve when you get a chance? Thanks!

    Shekharrajak Shekharrajak commented on Oct 02, 2026 03:38 UTC
    Contributor

    /lgtm
    /approve

    Shekharrajak Shekharrajak commented on Oct 02, 2026 03:39 UTC
    Contributor

    @astefanutti for merge.

    andreyvelich andreyvelich commented on Oct 02, 2026 17:12 UTC
    Reviewer

    Thanks for this work everyone!
    /lgtm
    /approve

    google-oss-prow[bot] google-oss-prow[bot] commented on Oct 02, 2026 17:12 UTC
    Bot

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: <a href="https://github.com/kubeflow/sdk/pull/795#pullrequestreview-5394626433" title="Approved">andreyvelich</a>, <a href="https://github.com/kubeflow/sdk/pull/795#issuecomment-5945160689" title="Approved">Shekharrajak</a>

    The full list of commands accepted by this bot can be found here.

    The pull request process is described here

    <details >
    Needs approval from an approver in each of these files:

  • ~~OWNERS~~ [andreyvelich]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    Reviewers
    Assignees
    Neha-Nimsatkar Neha-Nimsatkar
    Labels
    risk: low confidence: 81.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.4% (MEDIUM) · Higher = larger blast radius
    43.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 81.3% · Lower = rushed or shallow review
    81.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.1% · Safe to merge
    8.1%
    Repository