Skip to content

Make s3.SinglepartWriter seekable#854

Merged
ddelange merged 6 commits intopiskvorky:developfrom
ddelange:s3-singlepart-seekable
Jul 1, 2025
Merged

Make s3.SinglepartWriter seekable#854
ddelange merged 6 commits intopiskvorky:developfrom
ddelange:s3-singlepart-seekable

Conversation

@ddelange
Copy link
Copy Markdown
Collaborator

Please pick a concise, informative and complete title for your PR.

The title is important because it will appear in our change log.

Motivation

Please explain the motivation behind this PR.

If you're fixing a bug, link to the issue using a supported keyword like "Fixes #{issue_number}".

If you're adding a new feature, then consider opening a ticket and discussing it with the maintainers before you actually do the hard work.

Fixes #787

Enable single part upload use-cases (open(..., transport_params={"multipart_upload": False})) that require seeking.

Tests

If you're fixing a bug, consider test-driven development:

  1. Create a unit test that demonstrates the bug. The test should fail.
  2. Implement your bug fix.
  3. The test you created should now pass.

If you're implementing a new feature, include unit tests for it.

Make sure all existing unit tests pass.
You can run them locally using:

pytest smart_open

If there are any failures, please fix them before creating the PR (or mark it as WIP, see below).

Work in progress

If you're still working on your PR, mark the PR as draft PR.

We'll skip reviewing it for the time being.

Once it's ready, mark the PR as "ready for review", and ping one of the maintainers (e.g. mpenkov).

Checklist

Before you mark the PR as "ready for review", please make sure you have:

  • Picked a concise, informative and complete title
  • Clearly explained the motivation behind the PR
  • Linked to any existing issues that your PR will be solving
  • Included tests for any new functionality
  • Checked that all unit tests pass

Workflow

Please avoid rebasing and force-pushing to the branch of the PR once a review is in progress.

Rebasing can make your commits look a bit cleaner, but it also makes life more difficult from the reviewer, because they are no longer able to distinguish between code that has already been reviewed, and unreviewed code.

@ddelange ddelange mentioned this pull request Mar 10, 2025
3 tasks
Comment thread smart_open/s3.py
Comment on lines -1146 to -1138
# This member is part of the io.BufferedIOBase interface.
#
self.raw = None
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

_BufferedIOMixin (not used here) would expect self._raw which would be accessed via the raw property

Comment thread smart_open/s3.py

logger.debug("%s: direct upload finished", self)
self._buf = None
self._buf.close()
Copy link
Copy Markdown
Collaborator Author

@ddelange ddelange Mar 10, 2025

Choose a reason for hiding this comment

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

such that calling seek, seekable etc at a later point in time will properly raise ValueError: I/O operation on closed file ref 2b31045

Comment thread smart_open/s3.py
if writebuffer is None:
self._buf = io.BytesIO()
elif not writebuffer.seekable():
raise ValueError('writebuffer needs to be seekable')
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

making this requirement explicit (needed in close)

@ddelange
Copy link
Copy Markdown
Collaborator Author

@mpenkov ready for review 👍

@ddelange
Copy link
Copy Markdown
Collaborator Author

ddelange commented Apr 5, 2025

@mpenkov kind reminder on this one and the other open PRs :)

@ddelange ddelange force-pushed the s3-singlepart-seekable branch 2 times, most recently from f3ad2f0 to 76ab3c5 Compare July 1, 2025 08:37
@ddelange ddelange force-pushed the s3-singlepart-seekable branch from 76ab3c5 to c606867 Compare July 1, 2025 08:46
@ddelange ddelange merged commit f37ab24 into piskvorky:develop Jul 1, 2025
31 checks passed
ddelange added a commit to ddelange/smart_open that referenced this pull request Jul 1, 2025
ddelange added a commit that referenced this pull request Jul 1, 2025
* develop:
  Update CHANGELOG.md
  Modernize python packaging (#851)
  Make s3.SinglepartWriter seekable (#854)
  Fix try-except in ssh.py for missing port in ssh config (#863)
  Fix integration test CI rot (#864)
  Add buffer_size transport param to ssh.py (#861)
  Add help.txt linting step (#853)
  Remove head_bucket call from s3.SinglepartWriter (#857)
  bump version to 7.2.0.dev0
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 1, 2025

Released v7.3.0

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.

Compatibility issue with soundfile

1 participant