You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the expected result?
The expected result (and the result previous version 7.0.0) is to have the MultipartWriter.close() been called to perform a S3 complete multipart upload and see the file uploaded into s3
What are you seeing instead?
The file is not uploaded and MultipartWriter.close() is not called.
Steps/code to reproduce the problem
Adding the following tests to test_s3.py (class MultipartWriterTest) shows our problem:
deftest_write_gz_using_context_manager(self):
"""Does s3 multipart upload create a compressed file using context manager?"""contents=b'get ready for a surprise'withsmart_open.open(
f's3://{BUCKET_NAME}/{WRITE_KEY_NAME}.gz',
mode="wb",
transport_params={
"multipart_upload": True,
"min_part_size": 10,
}
) asfout:
fout.write(contents)
withsmart_open.open(f's3://{BUCKET_NAME}/{WRITE_KEY_NAME}.gz', 'rb') asfin:
actual=fin.read()
assertactual==contentsdeftest_write_gz_not_using_context_manager(self):
"""Does s3 multipart upload create a compressed file not using context manager but close()?"""contents=b'get ready for a surprise'fout=smart_open.open(
f's3://{BUCKET_NAME}/{WRITE_KEY_NAME}.gz',
mode="wb",
transport_params={
"multipart_upload": True,
"min_part_size": 10,
}
)
fout.write(contents)
fout.close()
withsmart_open.open(f's3://{BUCKET_NAME}/{WRITE_KEY_NAME}.gz', 'rb') asfin:
actual=fin.read()
assertactual==contents
Versions
This looks to be affecting from v7.0.0 to current version
Problem description
We are using smart_open to compress and upload files to s3 without a context manager:
e.g.
What is the expected result?
The expected result (and the result previous version 7.0.0) is to have the
MultipartWriter.close()
been called to perform a S3 complete multipart upload and see the file uploaded into s3What are you seeing instead?
The file is not uploaded and
MultipartWriter.close()
is not called.Steps/code to reproduce the problem
Adding the following tests to test_s3.py (
class MultipartWriterTest
) shows our problem:Versions
This looks to be affecting from v7.0.0 to current version
Please provide the output of:
Probably related to this PR #786 here:
https://github.com/piskvorky/smart_open/pull/786/files#diff-ba9d790d5607c344a97e86f15b3706586deb24d52d52cdf70b9776e3f3412b69L103
Recommendation
Probably closing both, outer and inner in
FileLikeProxy
will help:I can open a PR if that helps.
Thanks for reading!!
Checklist
Before you create the issue, please make sure you have:
The text was updated successfully, but these errors were encountered: