Skip to content

Make the filesystem package independent of the rest of PyAthena (GH-1388) - #1431

Open
laughingman7743 wants to merge 10 commits into
masterfrom
feat/1388-filesystem-boundary
Open

laughingman7743 wants to merge 10 commits into
masterfrom
feat/1388-filesystem-boundary

Conversation

@laughingman7743

@laughingman7743 laughingman7743 commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

WHAT

The S3 filesystem (pyathena/filesystem/) no longer imports anything from PyAthena outside its package. PyAthena depends on the filesystem, not the other way round. The change is compatible with 4.x; the decisions are recorded in #1388 (comment).

  • Retries and stop scopes. pyathena.filesystem.s3_retry owns the filesystem's retry policy (S3RetryConfig), its retry function, and the retry stop scopes (stop_retries_on(), unstoppable_retries(), retries_stopped(), raise_if_stopped(), retry_stop_events()) with their context variable. pyathena.util.stop_retries_on(), unstoppable_retries(), and retries_stopped() keep their names and documentation and use those scopes, and pyathena.util.retry_api_call() and wait_with_retry_stop() read them through retry_stop_events(). So there is still one scope state, as before: any stop scope, PyAthena's or one that the filesystem opens (such as for a cancelled call in its thread pool), stops any retry in it, and either unstoppable block lets both run to their end. Closing a cursor or cancelling a task still stops the S3 retries of its reads.
  • Retry policy compatibility. The filesystem accepts any object with the five attributes of RetryConfig, settable as on RetryConfig (RetryPolicy), so S3FileSystem(retry_config=pyathena.util.RetryConfig(...)) keeps working, and S3Core.resolve_retry_config() keeps the type of the given policy when it adds the S3 error codes.
  • Helpers. pyathena.filesystem.util holds the filesystem's own override, its user_agent_extra (still PyAthena/<version>, read from the installed distribution's metadata), and a copy of create_in_thread() that uses the filesystem's scopes.
  • s3_filesystem() moves to pyathena.fs. The pandas, Polars, and s3fs result sets use it from there. pyathena.filesystem.s3_filesystem stays as a copy that only reads the connection's s3_client and retry_config, and emits a DeprecationWarning; it will be removed in 5.0.0 together with Remove the filesystem's connection= and pass client= to custom s3fs filesystem classes #1386. The connection= arguments are typed with a protocol instead of pyathena.connection.Connection.
  • Docs. docs/filesystem.md, docs/usage.md, and the API reference use pyathena.fs.s3_filesystem() and S3RetryConfig. The "S3 client" section of docs/usage.md also corrects an existing statement: chunked Parquet results of PolarsCursor are read through the shared client when PyArrow is installed and no read options are given.
  • Boundary check. tests/pyathena/filesystem/test_package.py parses every module of the package and fails on an import of PyAthena outside it, including imports under TYPE_CHECKING and relative imports, and reports any dynamic import (importlib.import_module(), __import__()), which the package does not need.

Behavior changes

  • import pyathena now loads boto3, fsspec, and the filesystem modules, since pyathena.util imports pyathena.filesystem.s3_retry. Measured locally on Python 3.15: with boto3 already loaded (as by connect()), import pyathena takes 32 ms instead of 5 ms; from a bare interpreter, 132 ms and 494 modules instead of 20 ms and 117 modules. The no-fsspec property from Replace the filesystem's connection= with client= and retry_config= injection #1363 was a design rationale, not a documented contract, and it was dropped by decision on Make the filesystem package independent of the rest of PyAthena #1388.
  • Without a retry_config, S3FileSystem.core.retry_config is an S3RetryConfig instead of a pyathena.util.RetryConfig, with the same values, and S3Core.retry_config is annotated as RetryPolicy: a type-checked assignment of it to a RetryConfig variable needs a cast.
  • The filesystem's user agent is computed once at import from the installed PyAthena distribution, instead of reading pyathena.user_agent_extra on each client build. The value is the same for an installed PyAthena (test_s3.py checks it); a source tree without distribution metadata sends PyAthena/unknown from the filesystem, and a later change to pyathena.user_agent_extra no longer reaches the filesystem.

WHY

Closes #1388. The filesystem is going to be published as s3filesystem (decision on #1315), which requires it to stand on its own first.

TEST

Tested commit: a831618. The S3 suites ran on f0564ca's code (before only a TODO comment, test-only commits, and docs were added); the unit tests touched afterwards ran on each commit (Python 3.15, local).

  • just lint: passed. just benchmark test: 363 passed, 1 skipped.
  • just docs lint: passed. sphinx-build of the working tree: no warnings from the changed files (the existing duplicate-description and docstring-indentation warnings remain).
  • uv run --with "botocore[crt]" --env-file .env pytest -n 4 tests/pyathena/filesystem tests/pyathena/test_util.py tests/pyathena/aio/test_util.py tests/pyathena/aio/test_common.py tests/pyathena/arrow/test_reader.py tests/pyathena/test_connection.py (real S3): 2355 passed, 6 skipped.
  • Mutation checks: without the filesystem scope in pyathena.util.stop_retries_on() / unstoppable_retries(), the bridge tests fail; with pyathena.util reading a separate variable (or the union of both, as in an earlier revision), test_filesystem_scope_stops_retries, test_wait_with_retry_stop_relays_filesystem_stop, or test_filesystem_unstoppable_block_covers_retries fail; test_s3_retry.py fails with the stop check disabled (6) or with with_exceptions() mutating its input (2); the boundary test reports master's pyathena.util import of s3_core.py, relative imports out of the package, and literal (also relative) import_module() / __import__() names, and accepts from .s3 import … in __init__.pyi.
  • tests.pyathena.util.retried() takes the retry function (default: the filesystem's, as S3Core.call() retries); the aio result-set tests pass PyAthena's. Test stubs of S3 requests (retried(), the direct calls in test_s3_executor.py) now send with the filesystem's retry function, as S3Core.call() does, and the helpers of test_s3.py and test_s3_async.py that observe the filesystem's stop scopes use its raise_if_stopped(). With PyAthena's functions they no longer saw the scopes that the filesystem opens itself (5 and 29 failures before these changes).

Follow-up: import pyathena loading the filesystem is accepted for now and marked with a TODO in pyathena/util.py, to revisit when the filesystem becomes its own distribution (#1315).

Not run locally: the pandas, Polars, Arrow, s3fs, and SQLAlchemy suites against Athena; the AWS CI runs them once the PR is Ready.

🤖 Generated with Claude Code

laughingman7743 and others added 2 commits November 21, 2026 23:57
)

The filesystem now imports nothing from PyAthena outside
pyathena/filesystem/, so that it can be released on its own later.

- pyathena.filesystem.s3_retry owns the retry policy (S3RetryConfig, any
  object with the attributes of RetryConfig is accepted), the retry
  function, and its own stop scopes. pyathena.util.stop_retries_on() and
  unstoppable_retries() also enter the filesystem's scopes, so closing a
  cursor still stops the S3 retries of its reads.
- pyathena.filesystem.util keeps the filesystem's own override, user
  agent, and create_in_thread().
- s3_filesystem() moves to pyathena.fs; pyathena.filesystem.s3_filesystem
  stays as a deprecated copy that warns until the next major version.
- A test fails when a module of the package imports PyAthena outside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread pyathena/util.py Outdated
token = _RETRY_STOP_EVENTS.set((*_RETRY_STOP_EVENTS.get(), event))
try:
yield
with s3_retry.stop_retries_on(event):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Self-review round one (implementation behavior): FINDINGS (2), both repaired.

Scope: git diff 703aaad82bfc0c11b35e35e80b03eba2507835fd..d68b464764c1edbf3653e1ce4dfcb03fc2ceeccb (base = merge-base with master), all 32 changed files.

Covered:

  • Stop scopes: every PyAthena path that runs filesystem requests (Arrow reader stop_retries_on + wait_with_retry_stop, pyathena.aio.util.run_in_thread / create_in_thread / run_in_thread_or_close, pyathena.pandas.util.to_sql with S3Core.resolve_retry_config) enters PyAthena's scope, which now also enters the filesystem's; the filesystem's internal scopes (executor batches and run(), writers, its create_in_thread copy, aborts under unstoppable_retries) only govern filesystem requests. No PyAthena retry runs inside a filesystem-only scope.
  • Import cycles: pyathena.filesystem.s3_retry, .s3_core, .util, .s3_async, pyathena.filesystem, pyathena.fs, pyathena.util, pyathena.aio.util, pyathena.pandas.util, pyathena.sqlalchemy.base each imported first in a fresh interpreter.
  • Retry policy: S3FileSystem(retry_config=pyathena.util.RetryConfig(...)), the default S3RetryConfig(), type-preserving with_exceptions() (copy.copy, so a subclass keeps its type), pickling and fsspec tokenization of the arguments (plain classes, as before).
  • Tests: the boundary test reports master's pyathena.util import and relative imports out of the package; the link tests fail without the two s3_retry scopes in pyathena.util; the deprecation test checks the warning's attribution.

Findings:

  1. benchmarks/pyathena_bench/filesystem.py:24: the new pyathena.fs import was out of order under the benchmark's ruff config, which just format does not cover; just benchmark test failed in _benchmark-lint. Repaired in 1324abc; just benchmark test: 363 passed, 1 skipped.
  2. PR body: the import cost was given as "about 25 ms". Measured import pyathena after boto3: 5 ms on master, 32 ms on this branch (importlib.metadata.version() adds about 2.7 ms once fsspec has loaded importlib.metadata); from a bare interpreter, 20 ms / 117 modules vs 132 ms / 494 modules. The PR body now states these numbers.

Limitations: the pandas, Polars, Arrow, s3fs, and SQLAlchemy suites against Athena were not run locally; the AWS CI covers them once Ready.

self.exponential_base = exponential_base


def with_exceptions(config: _PolicyT, exceptions: Iterable[str]) -> _PolicyT:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Self-review round two (claims, callers, operations): FINDINGS (3 overstated claims), corrected in the PR body; no code change.

Scope: git diff 703aaad82bfc0c11b35e35e80b03eba2507835fd..1324abc4b052988560a2865bc0d398ad3451392e, the PR body, changed docstrings and docs, the commit messages, and the decision comment on #1388.

Claims checked:

  • The filesystem imports nothing from PyAthena: test_package.py, which flags master's imports.
  • Retries behave as before: the copied retry loop differs from pyathena.util.retry_api_call() only by the removed stop_on and Glue unwrapping (diff of both bodies); the copied create_in_thread() differs only in its cross-reference and in using the filesystem's scopes.
  • import pyathena cost: measured (5 → 32 ms after boto3; 20 → 132 ms bare), already in the PR body.
  • Docs examples (docs/filesystem.md Basic usage and Retries) run offline with -W error::DeprecationWarning; pyathena.util.RetryConfig() keeps its type and gains the S3 codes.
  • Stale references: none left to pyathena.filesystem.s3_filesystem outside its deprecation; remaining pyathena.aio.util.create_in_thread / pyathena.util.RetryConfig references are on PyAthena's side or describe compatibility.
  • Tests seen failing with the behavior removed: test_s3_retry.py (stop check disabled → 6 failures; with_exceptions() mutating its input → 2), plus round one's link and boundary checks.

Corrected in the PR body:

  1. "accepts any object with the attributes of RetryConfig": with_exceptions() here copies and assigns exceptions, so the attributes must be settable (a frozen object fails); now stated.
  2. "The value is the same" for the user agent: only with distribution metadata; a bare source tree sends PyAthena/unknown, and later changes to pyathena.user_agent_extra no longer reach the filesystem; now stated.
  3. "Nothing in PyAthena calls them inside such a scope" for pyathena.util.retries_stopped() / raise_if_stopped(): PyAthena no longer calls them at all; reworded.

Follow-up recorded: #1386 now lists the removal of the deprecated pyathena.filesystem.s3_filesystem() (issuecomment-7064571843).

Deferred: the commit message of d68b464 keeps the shorter "any object with the attributes" wording; rewriting a published commit for it is not worth a force-push.

Limitations: AWS suites outside tests/pyathena/filesystem, test_util, aio/test_util, and test_connection were not run locally.

laughingman7743 and others added 2 commits November 22, 2026 00:47
The filesystem's own scopes, such as those of a cancelled call in its
thread pool, stopped only the filesystem's retries. A callable that used
pyathena.util.retry_api_call() in S3ThreadPool.run() kept retrying after
the cancellation, which it did not before the split. PyAthena's retries
and stop checks now observe the filesystem's scopes as well, through
s3_retry.retry_stop_events().

Also: the boundary test checks literal import_module()/__import__() names
and .pyi files; the aio result-set tests stub their requests with
PyAthena's retry function again; the stopped-before-call test no longer
sets the event during the request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…H-1388)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
from typing import Any, ClassVar, Generic, TypeVar, cast

from pyathena.util import override, stop_retries_on
from pyathena.filesystem.s3_retry import stop_retries_on

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent review (relayed), static: FINDINGS.

Reviewer: Codex CLI 0.169.0, model gpt-6.2-astra (configured reasoning effort max), codex exec --sandbox read-only, session 01a1fea2-ee16-7ce3-9306-ccf39cb7a965. Scope: git diff 703aaad82bfc0c11b35e35e80b03eba2507835fd 1324abc4b052988560a2865bc0d398ad3451392e in a detached snapshot at 1324abc (verified unchanged afterwards), with AGENTS.md and docs/testing.md; no PR text, commit messages, or prior findings were given. No edits, tests, or network were allowed. Covered: package imports (incl. TYPE_CHECKING, Python 3.11), the filesystem's retry policy/user agent/override/create_in_thread(), sync and asyncio reads and writes, executor context propagation, cursor cancellation, Arrow prefetch and close, multipart aborts, unstoppable cleanup, both factory paths, connection=, warning attribution, return types, pickling, fsspec instance caching, retry classification, tests, docs.

Findings (reviewer's severity) and disposition:

  1. P1 pyathena/filesystem/s3_executor.py:29: a caller-supplied callable using pyathena.util.retry_api_call() in S3ThreadPool.run() kept retrying (and could commit a write) after cancellation, since the executor's scope only entered the filesystem's variable. Verified; repaired in fb362c7 after the maintainer chose that PyAthena observes both variables: retry_api_call(), retries_stopped(), raise_if_stopped(), wait_with_retry_stop() read s3_retry.retry_stop_events() too. New tests test_filesystem_scope_stops_retries and test_wait_with_retry_stop_relays_filesystem_stop fail without it.
  2. P2 s3_core.py:616: without retry_config, isinstance(S3Core(client).retry_config, RetryConfig) turns False, and the RetryPolicy annotation breaks a typed assignment to RetryConfig. Verified; accepted and documented in the PR body's behavior changes (the filesystem cannot construct PyAthena's class).
  3. P2 s3_retry.py:228: core.call(..., stop_on=predicate) used to be consumed by PyAthena's retry function and is now sent to botocore. Rejected: S3Core.call() documents **request as request parameters sent as given; nothing passes stop_on, and the old consumption of a parameter by the retry layer was accidental.
  4. P2 s3_retry.py:110: a RetryConfig subclass that refuses copying, or a read-only exceptions, now fails in with_exceptions(). Deferred as documented: copying keeps the caller's type (the compatibility asked for in item 2's spirit); the PR body states that the attributes must be settable.
  5. P2 filesystem/util.py:50: a source tree without distribution metadata sends PyAthena/unknown, and other metadata on the path can advertise another release. Accepted and documented in the PR body; the filesystem cannot read pyathena._version across the boundary, and the separate distribution will carry its own version.
  6. P2 s3_retry.py:129: a Glue error wrapped in MetadataException is no longer unwrapped. Rejected: S3 does not return MetadataException; the unwrapping is Athena-specific by design (Make the filesystem package independent of the rest of PyAthena #1388 item 3).
  7. P2 test_package.py:52: literal importlib.import_module() calls and .pyi files escaped the boundary test. Repaired in fb362c7; probe with import_module('pyathena.util') and __import__('pyathena.connection') is now reported.
  8. P2 tests/pyathena/util.py:188: the shared retried() stub moved every caller, including the aio result-set tests, to the filesystem's retry function. Repaired in fb362c7: retried() takes the retry function; the aio result-set tests pass PyAthena's (the Arrow reader test keeps the filesystem's, as its fake stands for PyAthena's fsspec filesystem).
  9. P3 test_util.py:430: the copied-context case duplicated executor coverage, and the bridge tests did not distinguish the direction. Repaired in fb362c7: the copied-context case is gone; the reverse direction now has its own tests (item 1).
  10. P3 test_s3_retry.py:173: the stopped-before-call test set the event again during the request. Repaired in fb362c7 with an operation that does not touch the event.
  11. P3 test_s3_retry.py:152: the jitter-spread assertion can fail by chance. Rejected: six uniform draws within 1% of the multiplier have probability about 6e-10; the assertion mirrors test_util.py.
  12. P3 docs/usage.md:766: the sentence after the edited one says chunked Polars Parquet reads use the library's client, while _iter_parquet_chunks() uses s3_filesystem(self.connection). Verified as pre-existing, outside this change; to be filed separately with the maintainer's approval.

Validation after the repairs (fb362c7): just lint, just benchmark test (363 passed, 1 skipped), and the filesystem/util/aio-common/Arrow-reader/connection suites against S3: 2352 passed, 6 skipped. A follow-up independent review of 1324abc..6e195e1 is pending.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Self-review of the repairs (both perspectives), git range-diff-free narrow pass: 1324abc..6e195e1 (same merge-base 703aaad, appended commits fb362c7 and 6e195e1 only). CLEAN.

Behavior: _stop_events() (pyathena/util.py) keeps the union in scope order and drops the duplicate that a pyathena.util.stop_retries_on() scope puts in both variables, so a single scope still waits on its event instead of polling; retry_api_call() still captures the events once per call; async_retry_api_call() goes through it; pyathena.util.unstoppable_retries() clears both variables, and the filesystem's own unstoppable_retries() inside a stopped PyAthena scope stops only PyAthena retries (documented in the PR body; no code runs one there). The retried() default keeps the filesystem tests' stubs as they were; only the aio result-set tests switch back to PyAthena's function.

Claims: the new docstrings of pyathena.util.stop_retries_on(), retries_stopped(), _stop_events(), and s3_retry.retry_stop_events() match the code and are exercised by test_filesystem_scope_stops_retries / test_wait_with_retry_stop_relays_filesystem_stop (both fail when _stop_events() returns only PyAthena's variable). The PR body and the amendment on #1388 (issuecomment posted 2026-11-22) state the new contract; the API reference lists retries_stopped() and retry_stop_events() (Sphinx build of the working tree: no warnings from changed files; just docs lint clean).

Validation: just lint; just benchmark test 363 passed, 1 skipped; filesystem/util/aio-common/Arrow-reader/connection suites against S3 on fb362c7: 2352 passed, 6 skipped.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent follow-up review #1 (relayed), static: FINDINGS, then repairs.

Reviewer: Codex CLI 0.169.0, gpt-6.2-astra, codex exec --sandbox read-only, session 01a1fecc-dda4-7540-b830-068e967d71af. Scope: git diff 1324abc4..6e195e13 (fb362c7, 6e195e1) in the detached snapshot at 6e195e1 (unchanged afterwards), with its own earlier findings and the amended requirement that PyAthena's retries and stop checks also observe the filesystem's scopes.

The reviewer confirmed the repairs of P1 (executor cancellation now stops a callback's PyAthena retry), the aio result-set stubs, the stopped-before-call test, and the removed duplicate test. New or remaining findings and disposition:

  • P2 pyathena/util.py:310: with the union of two variables, the filesystem's unstoppable_retries() inside a stopped PyAthena scope still reported "stopped" to pyathena.util (e.g. an overridden S3Core.call() checking pyathena.util.raise_if_stopped() during an abort), unlike before the split. Repaired in f0564ca after the maintainer chose one state: PyAthena keeps no variable of its own and uses s3_retry's scopes and retry_stop_events(). test_filesystem_unstoppable_block_covers_retries fails with fb362c7's pyathena/util.py.
  • P2 pyathena/util.py:310: dict.fromkeys() dedup fails on unhashable events and merges equal ones. Resolved by the same repair (no dedup any more).
  • P2 tests/pyathena/test_util.py:435: the new bridge tests set the event before entering the scope. Repaired in f0564ca: they set it during the request or the backoff wait (StoppingOperation), or inside the scope for the wait relay.
  • P2 tests/pyathena/filesystem/test_package.py:65: relative import_module("..util", __package__) escaped the check. Repaired in f0564ca (relative literals resolved; probe reported). An aliased import_module (from importlib import import_module as load) is not covered: a static check cannot follow arbitrary aliases, and runtime imports are against the repository's rules.
  • P3 test_package.py:40: __init__.pyi was not treated as a package initializer. Repaired in f0564ca.
  • P3 pyathena/util.py:384: per-probe dictionary cost. Resolved by the repair (retries_stopped() delegates to s3_retry).
  • P3 test_util.py:455: elapsed-time assertion in the new wait-relay test. Repaired: removed; the bounded stop.wait() result already shows the relay.
  • Restated, dispositions unchanged from the first review: default core.retry_config type and annotation (accepted, documented), stop_on through S3Core.call() (rejected), copy hooks of RetryConfig subclasses (documented), Glue unwrapping (rejected), user agent without metadata (documented), jitter spread (rejected, about 6e-10), docs/usage.md:766 (pre-existing).

Self-review of f0564ca (both perspectives): CLEAN. Behavior: one context variable, so every stop scope stops every retry and either unstoppable block clears it, as with master's _RETRY_STOP_EVENTS; retry_api_call() still captures the events once per call and waits on a single event. Claims: the docstrings of pyathena.util.stop_retries_on(), unstoppable_retries(), retries_stopped() and the PR body describe that state; the TODO in pyathena/util.py records the accepted import cost (#1315). Validation: just lint; just benchmark test 363 passed, 1 skipped; filesystem/util/aio-common/Arrow-reader/connection suites against S3: 2355 passed, 6 skipped. An independent follow-up of 6e195e1..f0564ca is pending.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent follow-up review #2 (relayed), static: FINDINGS, then repairs.

Reviewer: Codex CLI 0.169.0, gpt-6.2-astra, codex exec --sandbox read-only, session 01a1fefb-dc44-73d3-99ac-ed08b453bb7c. Scope: git diff 6e195e13..f0564cab in the detached snapshot at f0564ca (unchanged afterwards), against the requirement of one stop state owned by the filesystem with master's semantics. The reviewer confirmed that f0564ca restores master's stop behavior on copied contexts, asyncio tasks, executor callbacks, Arrow prefetch and close, writer checks, and multipart aborts, and that unhashable and equal-comparing events work again.

Findings and disposition:

  • P2 tests/pyathena/test_util.py:481: the new relay test set the event before the wait, so a wait that checks only on entry would pass. Repaired in 5f92270: the worker stops the scope after the waiter's first check (_CheckedEvent); the test fails when wait_with_retry_stop() checks only once.
  • P2 tests/pyathena/filesystem/test_package.py:73: import_module(".util", package="pyathena") was resolved against the module's package. Repaired in 5f92270 (a literal package, positional or keyword, is the anchor; probe reported). Aliased import_module stays out of reach of the static check.
  • P3 tests/pyathena/test_util.py:419: the backoff cases could pass after sleeping the whole backoff. Repaired in 5f92270 with the elapsed-time bound of the existing test_retry_api_call_stopped_by_event.
  • P2 shared-dict exceptions in a RetryConfig subclass (s3_retry.py:111): same trade-off as before (with_exceptions() copies to keep the caller's type; the attributes must be settable and independent), documented in the PR body.
  • Restated and unchanged: stop_on through S3Core.call() (rejected), S3Core.retry_config annotation (documented), user agent without metadata (documented), docs/usage.md:766 (pre-existing).

Self-review of 5f92270 (both perspectives): CLEAN. Test-only change; each tightened test was seen to fail with the behavior removed (single-check wait) or reports the probe (literal package). tests/pyathena/test_util.py, test_package.py, test_s3_retry.py: 125 passed. A narrow independent follow-up of f0564ca..5f92270 is pending.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Independent follow-up reviews #3–#5 (relayed), static, narrow (test-only commits): FINDINGS each time, on the test helpers. Reviewer: Codex CLI 0.169.0, gpt-6.2-astra, read-only sandbox, detached snapshots (unchanged afterwards); sessions 01a1ff06-f492-72c0-822b-6b55d492dbbf (5f92270), 01a1ff10-9f9b-79d2-a36c-e941c7dce2f3 (ec8ffbe), 01a1ff16-ef02-7fd1-9d61-bd40d48a5839 (35c42ec).

  • Retry processing with API call #3 (on f0564cab..5f922709): relay-test race between the check and the worker's set (repaired in ec8ffbe: the worker sets the event after the waiter's second check; a single-check wait fails 3/3); keyword-only import_module(name=..., package=...) and a non-string package (repaired in ec8ffbe); scheduling-dependent timing of the backoff cases (declined: same pattern and 10-second margin as test_retry_api_call_stopped_by_event).
  • Cursor Skips First Row When Listing Partitions #4 (on 5f922709..ec8ffbeb): a timed-out acquire let a broken waiter pass, and package=__name__ / package=None were resolved wrongly (repaired in 35c42ec; a wait that sets stop on entry fails).
  • Fix cursor skips first row when listing partitions (fix #4) #5 (on ec8ffbeb..35c42ec8): import_module("..util", __spec__.parent) escaped the anchor resolution. Repaired differently in d2854c0: the package needs no dynamic import, so the boundary test now reports any call of import_module() / __import__() and any import of import_module (also catching aliases), instead of resolving anchors. Probe: from importlib import import_module as load, import_module(..., __spec__.parent), __import__(...), and from .. import util are reported; from .s3 import ... is not. The second Fix cursor skips first row when listing partitions (fix #4) #5 finding (a correct waiter using Event.wait() instead of polling is_set() would fail the relay test) is declined: the test, like the existing _CheckedEvent test, checks the polling relay that wait_with_retry_stop() implements and would change with it.

Self-review of these commits (both perspectives): CLEAN; test-only, each tightened test seen to fail with the named behavior removed. test_util.py, test_package.py, test_s3_retry.py: 125 passed (boundary test 13 passed on d2854c0).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Closing the independent review loop (maintainer's decision, 2026-11-22). Product code received no further findings after follow-up #2; follow-ups #3–#5 concerned test helpers only. The maintainer chose to mark the PR Ready without another follow-up of d2854c0 (test-only: the boundary test reports any dynamic import), which was checked by probes and the self-review above.

The pre-existing docs/usage.md:766 finding (raised in the first review and both later passes) is repaired in a831618 at the maintainer's request: PolarsCursor reads chunked Parquet results through the connection's shared client when PyArrow is installed and no read options are given (_iter_parquet_chunks() → s3_filesystem(self.connection, ...)); chunked CSV results and whole Parquet results still use Polars' own client (scan_csv(), read_parquet()); ArrowCursor reads through pyarrow's S3FileSystem. just docs lint: clean.

laughingman7743 and others added 6 commits November 22, 2026 01:40
PyAthena's stop scopes now are the filesystem's: pyathena.util's
stop_retries_on(), unstoppable_retries(), and retries_stopped() use
pyathena.filesystem.s3_retry, and retry_api_call() and
wait_with_retry_stop() read s3_retry.retry_stop_events(). Reading the
union of two variables still let a stopped PyAthena scope stop a PyAthena
retry in the filesystem's unstoppable block, which the single variable
before the split did not; the dependency still points only from PyAthena
to the filesystem.

The bridge tests now set the event after entering the scope, and the
boundary test resolves relative import_module() names and treats
__init__.pyi as a package initializer. A TODO records that importing
pyathena now loads the filesystem, to revisit once it is its own
distribution.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The relay test stops the filesystem's scope only after the waiter has
checked it, the backoff cases assert that the stop ended the wait early,
and the boundary test resolves relative import_module() names against a
literal package argument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A wait that checks the scopes only once could see the stop that the
worker set right after the first check. The boundary test also reads
import_module() calls whose arguments are all keywords and ignores a
package that is not a string.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…H-1388)

A relative name resolves against __package__, __name__, or a string
literal; another package argument is not followed. The relay test's
worker fails instead of setting the event when the waiter stops checking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolving the anchors of import_module() calls could not follow every
form, such as __spec__.parent or an alias of the function. The package
needs no dynamic import, so the boundary test now reports any call of
import_module() or __import__() and any import of import_module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…H-1388)

With PyArrow installed and no read options, chunked Parquet results of
PolarsCursor are read through PyAthena's filesystem with the connection's
shared S3 client, not through Polars' own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@laughingman7743
laughingman7743 marked this pull request as ready for review November 22, 2026 02:10

This branch has not been deployed

No deployments
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.

Make the filesystem package independent of the rest of PyAthena

1 participant