refactor(pyamber): drop PyFilesystem2 for stdlib tempfile - #6928
Closed
aglinxinyuan wants to merge 2 commits into
Closed
refactor(pyamber): drop PyFilesystem2 for stdlib tempfile#6928aglinxinyuan wants to merge 2 commits into
aglinxinyuan wants to merge 2 commits into
Conversation
Every spawned Python UDF worker imports fs (PyFilesystem2), whose import of pkg_resources emits a UserWarning on stderr. Filter that one message before the core import chain, and mirror the filter for pytest output. Follow-up item from apache#6796.
fs (PyFilesystem2) is EOL: 2.4.16 (2022) is the last release ever and its import-time pkg_resources use is the sole reason setuptools was pinned below 82 (apache#4199, apache#6412). ExecutorManager was the only consumer; its temp:// filesystem becomes tempfile.mkdtemp + shutil.rmtree, with the UDF source encoding pinned to UTF-8 exactly as fs did (new non-ASCII round-trip regression test). Removes the fs and setuptools pins, syncs LICENSE-binary-python (drops fs-only transitive appdirs), and reverts the now-unneeded pkg_resources warning filters from apache#6880. Closes apache#6917.
Contributor
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6928 +/- ##
============================================
+ Coverage 77.31% 77.66% +0.35%
Complexity 3524 3524
============================================
Files 1161 1161
Lines 45920 46043 +123
Branches 5099 5099
============================================
+ Hits 35501 35760 +259
+ Misses 8839 8703 -136
Partials 1580 1580
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 401 | 0.244 | 24,463/37,126/37,126 us | 🔴 +11.4% / 🔴 +126.8% |
| ⚪ | bs=100 sw=10 sl=64 | 804 | 0.491 | 124,583/152,331/152,331 us | ⚪ within ±5% / 🔴 +39.4% |
| ⚪ | bs=1000 sw=10 sl=64 | 911 | 0.556 | 1,093,537/1,177,616/1,177,616 us | ⚪ within ±5% / 🔴 +12.1% |
Baseline details
Latest main 49f9e2c from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 401 tuples/sec | 412 tuples/sec | 759.72 tuples/sec | -2.7% | -47.2% |
| bs=10 sw=10 sl=64 | MB/s | 0.244 MB/s | 0.251 MB/s | 0.464 MB/s | -2.8% | -47.4% |
| bs=10 sw=10 sl=64 | p50 | 24,463 us | 24,037 us | 12,653 us | +1.8% | +93.3% |
| bs=10 sw=10 sl=64 | p95 | 37,126 us | 33,336 us | 16,371 us | +11.4% | +126.8% |
| bs=10 sw=10 sl=64 | p99 | 37,126 us | 33,336 us | 19,941 us | +11.4% | +86.2% |
| bs=100 sw=10 sl=64 | throughput | 804 tuples/sec | 817 tuples/sec | 966.78 tuples/sec | -1.6% | -16.8% |
| bs=100 sw=10 sl=64 | MB/s | 0.491 MB/s | 0.499 MB/s | 0.59 MB/s | -1.6% | -16.8% |
| bs=100 sw=10 sl=64 | p50 | 124,583 us | 121,341 us | 103,654 us | +2.7% | +20.2% |
| bs=100 sw=10 sl=64 | p95 | 152,331 us | 150,049 us | 109,308 us | +1.5% | +39.4% |
| bs=100 sw=10 sl=64 | p99 | 152,331 us | 150,049 us | 116,369 us | +1.5% | +30.9% |
| bs=1000 sw=10 sl=64 | throughput | 911 tuples/sec | 913 tuples/sec | 997.95 tuples/sec | -0.2% | -8.7% |
| bs=1000 sw=10 sl=64 | MB/s | 0.556 MB/s | 0.557 MB/s | 0.609 MB/s | -0.2% | -8.7% |
| bs=1000 sw=10 sl=64 | p50 | 1,093,537 us | 1,100,192 us | 1,007,348 us | -0.6% | +8.6% |
| bs=1000 sw=10 sl=64 | p95 | 1,177,616 us | 1,137,155 us | 1,050,149 us | +3.6% | +12.1% |
| bs=1000 sw=10 sl=64 | p99 | 1,177,616 us | 1,137,155 us | 1,079,497 us | +3.6% | +9.1% |
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,499.27,200,128000,401,0.244,24462.71,37125.55,37125.55
1,100,10,64,20,2487.95,2000,1280000,804,0.491,124582.85,152331.17,152331.17
2,1000,10,64,20,21951.00,20000,12800000,911,0.556,1093537.15,1177616.10,1177616.10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
fs(PyFilesystem2) is effectively EOL — 2.4.16 (2022) is the last release ever published, upstream still importspkg_resourcesat import time, and setuptools 82 removedpkg_resourcesentirely, which is the sole reason amber pinssetuptools==80.10.2(#4199, #6412).ExecutorManagerwas the only consumer, and fs'sTempFSis internally justtempfile.mkdtemp+shutil.rmtree, so the swap to stdlib is behavior-preserving.executor_manager.pyfs.open_fs("temp://")→tempfile.mkdtemp(prefix="texera-udf-")+shutil.rmtree; property renamedfs→tmp_dir; lazy creation,sys.pathhandling, the never-materialized close guard, and the tolerated leak-on-force-kill semantics all preservedtest_executor_manager.pymanager.fsaccesses usemanager.tmp_dir; new non-ASCII UDF round-trip regression test (see below)requirements.txtfs==2.4.16and thesetuptools==80.10.2pin — fs was the only distribution in the closure requiring setuptools (pytz'spkg_resourcesuse is a guarded fallback)LICENSE-binary-pythonfs==2.4.16andappdirs==1.4.4(an fs-only transitive);sixstays (python-dateutil needs it)texera_run_python_worker.py,pyproject.tomlmainthese files are net-untouched (pyproject keeps only an EOF-newline fix)One subtlety worth reviewer attention: fs's
open()forced UTF-8 for text writes, whilepathlib'sopen("w")uses the locale encoding — on a cp1252 Windows host, non-ASCII UDF code would crash at write time or fail at import (importlib decodes source as UTF-8 per PEP 3120). The swap therefore pinsencoding="utf-8", newline="\n"explicitly, keeping byte-identical behavior with fs, and a regression test pins it.Stacked on #6880 (contains its commit); whichever merges first works — if this one lands first, #6880 can simply be closed.
Any related issues, documentation, discussions?
Closes #6917.
How was this PR tested?
test_non_ascii_udf_source_round_tripwritten first: it fails withUnicodeEncodeErrorunder a cp1252 locale without the explicitencoding="utf-8"(reproduced on Windows), and passes with it — pinning encoding parity with fs.close()branch tests were repointed attmp_dirred-first (failing on the old attribute) before the source swap; all 23test_executor_manager.pytests pass.amber/: 750 passed, identical to the pre-change baseline apart from the added test (the handful of Iceberg-catalog failures on this Windows machine are identical on a clean tree). The suite'spkg_resourceswarnings disappeared at the source (5 → 1 total warnings) with no filter in place.fs/tempfs.py,fs/iotools.py): directory creation, close/cleanup semantics including double-close, and the cached-property guard translate 1:1.ruff checkandruff format --checkpass on all touched files.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Fable 5)