Skip to content

[SPARK-59920][BUILD] Remove unnecessary git clean from pip tests script - #59182

Closed
nchammas wants to merge 4 commits into
apache:masterfrom
nchammas:py-packaging-test-cleanup
Closed

nchammas wants to merge 4 commits into
apache:masterfrom
nchammas:py-packaging-test-cleanup

Conversation

@nchammas

@nchammas nchammas commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Remove the git clean step from run-pip-tests.

Why are the changes needed?

This cleanup was added in #42159 to help resolve intermittent space pressure. It had no other purpose.

It's not necessary anymore. We already free some space on the runner via the free-disk-space parameter to the setup-build-env composite action. More importantly, the runners themselves also have much more free space than in prior years when this fix was added.

Looking forward, this cleanup will also make it easier to change when or how the pip tests are triggered (as part of SPARK-59180), since we no longer have to worry about git clean removing build artifacts that other tests may need to run.

Finally, an environment preparation step like this, should we ever need to reintroduce it for some reason, doesn't belong inside the test script. It should happen upstream of it, so as not to mix in logically unrelated steps with the actual pip tests themselves.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing CI for this PR successfully ran the pip tests.

I also pushed a temporary commit at 0ce4a1b to get the macOS 26 build to run and confirmed that the runner has plenty of space available.

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

No.

@sarutak sarutak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The reasoning is sound, but the two mechanisms don't actually free the same space, so "we already free space via free-disk-space" doesn't by itself make git clean redundant:

  • free-disk-space runs dev/free_disk_space / dev/free_disk_space_container, which delete runner/container pre-installed bulk (dotnet, Android SDK, large Docker images, etc.) to increase total free space on the host/container.
  • The removed git clean -d -f -x deleted untracked/ignored build artifacts inside the Spark working tree.

These target different sources of disk pressure, so one isn't a drop-in replacement for the other. The stronger (and sufficient) justification is the one you already give alongside it: the runners simply have much more free space now, and (because the pip job starts from a fresh checkout and the existing CI run confirms it) the working-tree cleanup is no longer needed for the pip test to fit on disk.

Suggestion: reword to something fact-based, e.g.:

The runners have much more free space now, and the pip job already starts from a fresh checkout, so the pip test fits on disk without this working-tree cleanup (confirmed by existing CI). Note free-disk-space frees host/container space rather than the working tree, so it isn't a direct substitute; the point is that this cleanup simply isn't needed anymore.

This is purely a description nit; the code change itself is fine.

@dongjoon-hyun dongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the cleanup. Removing a CI environment-prep step from the test script itself makes sense to me. However, I'd like the following to be addressed (or clarified) before merging.

1. The macOS hosted-runner job loses its only disk cleanup

The PR description justifies the removal with the free-disk-space parameter of setup-build-env. python_hosted_runner_test.yml (default macos-15, used by build_python_3.12_arm.yml and build_python_3.12_macos26.yml) calls setup-build-env without free-disk-space, and the host/container scripts are Linux-only (dpkg, sudo rm -rf /usr/share/dotnet, ...). That workflow sets SKIP_PACKAGING=false for pyspark-errors, so dev/run-tests still invokes run-pip-tests there. The removed git clean was gated on GITHUB_ACTIONS, so it did run on those runners, and after this PR nothing replaces it. The runner-images link in the description is about Linux runners.

Could you confirm the macOS runners have enough headroom for the precompiled artifact (every module target/) plus two venvs and two PySpark installs? If not, please add an explicit cleanup step to that workflow rather than dropping it.

2. The script no longer guarantees a clean tree

git clean -d -f -x also removed ignored/untracked leftovers such as python/dist, python/build and generated *.json files. The script still hard-fails with Unexpected number of targets found in dist directory - please cleanup existing sdists first if python/dist has more than one sdist, and setup.py sdist uses include_package_data=True plus pyspark/**/*.json globs. On a fresh GitHub checkout this is fine. On a persistent or self-hosted workspace, or a re-run after a packaging run with a different version, it can now fail or ship stray files. If that is intentionally out of scope, a one-line note in the description would be enough.

3. Validation

The description says "Existing CI", but run-pip-tests only runs when SKIP_PACKAGING=false, i.e. for the pyspark-periodic module in build_and_test.yml (excluded unless pyspark-periodic is required) and pyspark-errors in python_hosted_runner_test.yml. A PR that only touches dev/run-pip-tests may not select either, so a green CI would not show that the pip tests still pass without the cleanup. Could you link a run where the pip packaging step actually executed with this change (ideally on both Linux and macOS)?

@nchammas

nchammas commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

The reasoning is sound, but the two mechanisms don't actually free the same space

They don't free the same space, but they do free space on the same disk, which is what I was getting at. I've adjusted the PR description.

Could you confirm the macOS runners have enough headroom for the precompiled artifact (every module target/) plus two venvs and two PySpark installs?

Confirmed and updated the PR description accordingly. I will revert the temporary commit after the macOS build completes. macOS build successful. Temp commit reverted.

On a persistent or self-hosted workspace, or a re-run after a packaging run with a different version, it can now fail or ship stray files.

The git cleanup was not introduced for any of these reasons. It was just to free up space on GitHub runners. I've updated the PR description accordingly.

Could you link a run where the pip packaging step actually executed with this change (ideally on both Linux and macOS)?

Done in the updated PR description.

@nchammas
nchammas requested a review from dongjoon-hyun October 2, 2026 13:05
HyukjinKwon

This comment was marked as outdated.

@HyukjinKwon

This comment was marked as outdated.

@nchammas nchammas closed this in b93fb8d Oct 5, 2026
nchammas added a commit that referenced this pull request Oct 5, 2026
…ript

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

Remove the `git clean` step from `run-pip-tests`.

### Why are the changes needed?

This cleanup was added in #42159 to help resolve intermittent space pressure. It had no other purpose.

It's not necessary anymore. We already free some space on the runner via the `free-disk-space` parameter to the `setup-build-env` composite action. More importantly, the runners themselves also have [much more free space][1] than in prior years when this fix was added.

[1]: actions/runner-images#14492 (comment)

Looking forward, this cleanup will also make it easier to change when or how the pip tests are triggered (as part of SPARK-59180), since we no longer have to worry about `git clean` removing build artifacts that other tests may need to run.

Finally, an environment preparation step like this, should we ever need to reintroduce it for some reason, doesn't belong inside the test script. It should happen upstream of it, so as not to mix in logically unrelated steps with the actual pip tests themselves.

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

No.

### How was this patch tested?

Existing CI for this PR [successfully ran the pip tests][ci].

[ci]: https://github.com/nchammas/spark/actions/runs/36834488478/job/110298902984#step:9:130

I also pushed a temporary commit at 0ce4a1b to get the macOS 26 build to run and confirmed that the runner has [plenty of space available][mac].

[mac]: https://github.com/nchammas/spark/actions/runs/36988944346/job/110793319313#step:2:29

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

No.

Closes #59182 from nchammas/py-packaging-test-cleanup.

Authored-by: Nicholas Chammas <[email protected]>
Signed-off-by: Nicholas Chammas <[email protected]>
(cherry picked from commit b93fb8d)
Signed-off-by: Nicholas Chammas <[email protected]>
@nchammas

nchammas commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merge Summary:

Posted by merge_spark_pr.py

@nchammas
nchammas deleted the py-packaging-test-cleanup branch October 5, 2026 18:33
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.

4 participants