-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(fix) Add w
rite to opening mode in object writer
#7961
Conversation
Python's `open` needs a specification of one of create/read/write/append.
Any change requests to this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for letting this slip by me and the resultant delay in reviewing. Thanks!
Can you figure out a way to test this in clients/python-wrapper/tests/integration/test_object.py? If we made the error once, we might make it again. Please don't waste too much time on it, though; if you have no quick way, just open an issue.\
Again, thanks!
Running Esti through a clone #7978. |
otherwise, there will be errors for writes to the SpooledTemporaryFile larger than the buffersize as encoding shall not be set for binary files. The write mode is hardcoded to `wb+` due to an upstream bug.
for files larger than _WRITER_BUFFER_SIZE (hard coded value in /lakefs/object.py, set to 32 MB) Python's SpooledTemporaryFile forces a write to disk. Only then the kwargs passed to it are applied.
I've added a test in 62c1f63, with those i found that conditionally setting the encoding results in errors if the write mode is hardcode. Binary writes throw errors with an encoding set. I've removed the conditional in 9eadf81. Once no longer affected by the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Let me know if you want to add the requested TODO, or want me to do it. With that we're good to go.
MANY THANKS for the PR and your patience - it is very much appreciated.
# Create file of size greater than _WRITER_BUFFER_SIZE (32 MB) | ||
# set in SpooledTemporaryFile to force disk write | ||
binary_data = b"\x00" * (32 * 1024 * 1024 + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good stuff but unfortunate: we should be able to set a lower _WRITER_BUFFER_SIZE for this test, for instance, by passing ObjectWriter a max_size parameter.
Out of scope for this PR, so please add
# Create file of size greater than _WRITER_BUFFER_SIZE (32 MB) | |
# set in SpooledTemporaryFile to force disk write | |
binary_data = b"\x00" * (32 * 1024 * 1024 + 1) | |
# Create file of size greater than _WRITER_BUFFER_SIZE (32 MB) | |
# set in SpooledTemporaryFile to force disk write | |
# | |
# TODO(arielshaqed/n-o-z): set a smaller spool size. | |
binary_data = b"\x00" * (32 * 1024 * 1024 + 1) |
which are out of scope for this PR. Namely, reintroducing the write mode depending on user specification once we are no longer affected by the upstream urllib bug and a tuning parameter for the SpooledTemporaryFile size in the tests.
Happy to help :) All done from my side! |
Thanks! Sorry for delays, will pull shortly. @N-o-Z we can address this comment right after; I will open an issue. |
Head branch was pushed to by a user without write access
I had different linter settings and with hunk staging forgot imports to the tests. Sorry. |
System test passes :-) on my copy of this branch. Pulling this one, thanks! |
Python's
open
needs a specification of one ofcreate/read/write/append.
Closes #7928
Change Description
Add
w
rite mode to binary open.Background
Share context and relevant information for the PR: offline discussions, considerations, design decisions etc.
Bug Fix
If this PR is a bug fix, please let us know about:
Python needs specification of create/read/write/append.
The opening mode specification was missing.
Added the opening mode specification