Skip to content

Share the upload body of put_file() with the async transaction write, and check put sources once #1427

Open

Description

@laughingman7743

These were found while reviewing #1426 (#1404). They predate it and are outside its scope.

1. The upload body of put_file() exists twice

AioS3FileSystem._put_file_in_transaction() (pyathena/filesystem/s3_async.py) repeats the body of S3FileSystem.put_file() line for line, except for the opener:

  • the directory and bucket checks;
  • the size check against the part count;
  • the ContentType guess;
  • the write of the local file;
  • the invalidation.

#1426 had to make each change to destinations twice. The pipe_file() body is split the same way.

S3FileSystem._open_path() and _S3TransactionWrite.open() now have the same signature: (path: str | S3Path, mode, **kwargs) -> S3File. So a private sync upload body that takes the opener could serve both, reducing _put_file_in_transaction() to a call.

2. The async _put() checks each local path twice and windows no parts

  • AioS3FileSystem._put() calls os.path.isdir() on the event loop for every pair to leave out the directories. fsspec's _put() used to check them again; since Type put destinations and document path addressing (GH-1404) #1426, _transfer_pairs() runs the uploads instead. A single check, in the thread that pairs the paths, would keep os.path.isdir() off the loop.
  • Unlike _get(), _put() does not pass its uploads the max_workers window that _batch_kwargs() computes. So each upload may send up to max_workers parts at once, however many uploads run.

Activity

  1. laughingman7743 commented on Nov 21, 2026

    @laughingman7743
    MemberAuthor

    Two more items from the review of #1426, which also predate it:

    3. The async _get() and a skipped _put() differ from fsspec's results

    • _get(): AioS3FileSystem._get() returns None. fsspec's _get() returns the list of the _get_file() results, as _put() does. That is [None] for one file with the default callback, and a custom branch_coro() wrapper can change the values.
    • A skipped _put(): given a single local directory as a string without recursive, it calls callback.set_size(0) and returns []. fsspec returns None before it uses the callback.
  2. laughingman7743 commented on Nov 21, 2026

    @laughingman7743
    MemberAuthor

    Section 3 (the results of the async _get() and of a _put() that uploads nothing) moves to #1429, since it changes return values to match fsspec. This issue keeps sections 1 and 2.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions