Skip to content

chore(pyamber): silence pkg_resources deprecation warning from fs import#6880

Open
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:chore/silence-pkg-resources-warning
Open

chore(pyamber): silence pkg_resources deprecation warning from fs import#6880
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:chore/silence-pkg-resources-warning

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Every spawned Python UDF worker prints this on stderr at import time, dozens of times per amber-integration CI run:

site-packages/fs/__init__.py:4: UserWarning: pkg_resources is deprecated as an API. ...

Root cause: the worker entry point imports core.python_worker, which transitively imports fs (PyFilesystem2, used by ExecutorManager for the tmp filesystem that holds UDF source code); fs/__init__.py imports pkg_resources, which emits a UserWarning. It is a Python warnings warning, not a loguru log, so the existing log-level knobs (#6797) cannot suppress it. fs still needs pkg_resources — that is why setuptools is range-pinned (#6412) — so the warning is expected and not actionable on our side.

Before: worker spawn -> import core -> import fs -> UserWarning on stderr  (every worker)
After:  worker spawn -> install message-scoped filter -> import fs -> silent
File Change
amber/src/main/python/texera_run_python_worker.py warnings.filterwarnings scoped to this one message + category=UserWarning, installed above the core import chain
amber/pyproject.toml same filter mirrored via pytest filterwarnings so the suite's warnings summary is quiet too

Only this exact message is filtered — unrelated warnings still print (verified with an injected control warning). The companion declare_namespace DeprecationWarnings from fs remain, but they only surface in pytest summaries; Python's default filters already hide them in spawned worker processes.

Any related issues, documentation, discussions?

Listed as a follow-up item in #6796 (the log-verbosity reduction itself landed via #6797).

How was this PR tested?

  • Reproduced with the exact pinned deps (setuptools 80.10.2, fs 2.4.16): importing texera_run_python_worker printed the UserWarning before the change and is silent after; an injected unrelated UserWarning still prints, confirming the filter is not a blanket ignore.
  • pytest src/test/python -m "not integration" from amber/: 749 passed and the pkg_resources UserWarning is gone from the warnings summary (the handful of Iceberg-catalog failures on this Windows machine are identical on a clean tree).
  • ruff check and ruff format --check pass on the edited file.

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

Generated-by: Claude Code (Fable 5)

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.
Copilot AI review requested due to automatic review settings July 25, 2026 03:09
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @yangzhang75
    You can notify them by mentioning @yangzhang75 in a comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces noisy, non-actionable Python warnings emitted during Amber Python UDF worker startup by adding a targeted warnings filter for the pkg_resources is deprecated as an API... UserWarning that is triggered transitively via fs imports. It improves CI log signal (especially in integration runs that spawn many workers) without suppressing unrelated warnings.

Changes:

  • Add a narrowly scoped warnings.filterwarnings(...) rule in the Python worker entrypoint before the core import chain runs.
  • Mirror the same warning filter in pytest configuration to keep the test-suite warnings summary quiet and consistent.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
amber/src/main/python/texera_run_python_worker.py Installs a targeted UserWarning filter for the pkg_resources deprecation warning before importing core.python_worker (which transitively imports fs).
amber/pyproject.toml Adds a matching pytest filterwarnings entry so test runs don’t surface the same known, non-actionable warning.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.31%. Comparing base (429be11) to head (d13da15).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #6880   +/-   ##
=========================================
  Coverage     77.31%   77.31%           
  Complexity     3524     3524           
=========================================
  Files          1161     1161           
  Lines         45920    45922    +2     
  Branches       5099     5099           
=========================================
+ Hits          35501    35503    +2     
  Misses         8839     8839           
  Partials       1580     1580           
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 429be11
agent-service 76.76% <ø> (ø) Carriedforward from 429be11
amber 69.10% <ø> (ø) Carriedforward from 429be11
computing-unit-managing-service 20.49% <ø> (ø) Carriedforward from 429be11
config-service 66.66% <ø> (ø) Carriedforward from 429be11
file-service 67.21% <ø> (ø) Carriedforward from 429be11
frontend 82.58% <ø> (ø) Carriedforward from 429be11
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 429be11
pyamber 92.15% <100.00%> (+<0.01%) ⬆️
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 429be11

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

✅ No material benchmark regressions detected

🟢 2 better · 🔴 0 worse · ⚪ 13 noise (<±5%) · 0 without baseline

Compared against main 429be11 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
bs=10 sw=10 sl=64 368 0.225 25,799/37,969/37,969 us ⚪ within ±5% / 🔴 +128.8%
🟢 bs=100 sw=10 sl=64 774 0.472 128,638/159,174/159,174 us 🟢 -16.9% / 🔴 +45.9%
bs=1000 sw=10 sl=64 904 0.552 1,102,065/1,155,212/1,155,212 us ⚪ within ±5% / 🔴 +10.4%
Baseline details

Latest main 429be11 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 368 tuples/sec 382 tuples/sec 754.55 tuples/sec -3.7% -51.2%
bs=10 sw=10 sl=64 MB/s 0.225 MB/s 0.233 MB/s 0.461 MB/s -3.4% -51.1%
bs=10 sw=10 sl=64 p50 25,799 us 25,295 us 12,816 us +2.0% +101.3%
bs=10 sw=10 sl=64 p95 37,969 us 39,461 us 16,594 us -3.8% +128.8%
bs=10 sw=10 sl=64 p99 37,969 us 39,461 us 19,806 us -3.8% +91.7%
bs=100 sw=10 sl=64 throughput 774 tuples/sec 741 tuples/sec 969.38 tuples/sec +4.5% -20.2%
bs=100 sw=10 sl=64 MB/s 0.472 MB/s 0.452 MB/s 0.592 MB/s +4.4% -20.2%
bs=100 sw=10 sl=64 p50 128,638 us 126,373 us 103,584 us +1.8% +24.2%
bs=100 sw=10 sl=64 p95 159,174 us 191,573 us 109,097 us -16.9% +45.9%
bs=100 sw=10 sl=64 p99 159,174 us 191,573 us 117,304 us -16.9% +35.7%
bs=1000 sw=10 sl=64 throughput 904 tuples/sec 914 tuples/sec 1,004 tuples/sec -1.1% -9.9%
bs=1000 sw=10 sl=64 MB/s 0.552 MB/s 0.558 MB/s 0.613 MB/s -1.1% -9.9%
bs=1000 sw=10 sl=64 p50 1,102,065 us 1,088,225 us 1,002,357 us +1.3% +9.9%
bs=1000 sw=10 sl=64 p95 1,155,212 us 1,137,784 us 1,046,463 us +1.5% +10.4%
bs=1000 sw=10 sl=64 p99 1,155,212 us 1,137,784 us 1,073,661 us +1.5% +7.6%
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,542.81,200,128000,368,0.225,25799.00,37969.25,37969.25
1,100,10,64,20,2583.89,2000,1280000,774,0.472,128638.30,159174.20,159174.20
2,1000,10,64,20,22123.82,20000,12800000,904,0.552,1102065.07,1155211.62,1155211.62

@aglinxinyuan
aglinxinyuan requested a review from mengw15 July 25, 2026 05:13

@mengw15 mengw15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Left one comment

# at import time (#4199), which emits this deprecation warning on stderr in
# every spawned worker. It is not actionable on our side, so filter it before
# the import chain runs. Mirrored for pytest in amber/pyproject.toml.
warnings.filterwarnings(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Narrow, well-scoped filter — no objection to silencing this. One thing worth surfacing: this warning was also the only recurring signal that we're pinned on an EOL fs (2.4.16 is the last release) and holding setuptools below the pkg_resources removal (#4199). Once it's quiet, that debt only lives in this comment. There's no open tracking issue for migrating off PyFilesystem2 / handling the eventual pkg_resources removal — worth opening one and linking it here so the debt stays visible after the reminder is gone. Not blocking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants