Skip to content

Commit

Permalink
Merge branch 'release-7.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenkov committed Mar 21, 2024
2 parents c986a47 + 3864134 commit 2865174
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 7.0.3, 2024-03-21

* add support for zst writing (PR [#812](https://github.com/piskvorky/smart_open/pull/812), [@mpenkov](https://github.com/mpenkov))
* roll back PR [#812](https://github.com/piskvorky/smart_open/pull/788), restore compatibility with built-in open function ([@mpenkov](https://github.com/mpenkov))

# 7.0.2, 2024-03-21

* Add `__next__` method to FileLikeProxy (PR [#811](https://github.com/piskvorky/smart_open/pull/811), [@ddelange](https://github.com/ddelange))
Expand Down
10 changes: 0 additions & 10 deletions integration-tests/test_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ def write_read(key, content, write_mode, read_mode, **kwargs):
with smart_open.open(key, read_mode, **kwargs) as fin:
return fin.read()

def open_only(key, read_mode, **kwargs) -> None:
with smart_open.open(key, read_mode, **kwargs):
pass

def read_length_prefixed_messages(key, read_mode, **kwargs):
result = io.BytesIO()
Expand Down Expand Up @@ -124,10 +121,3 @@ def test_gcs_performance_small_reads(benchmark):

actual = benchmark(read_length_prefixed_messages, key, 'rb', buffering=ONE_MIB)
assert actual == one_megabyte_of_msgs

def test_gcs_performance_open(benchmark):
# we don't need to use a uri that actually exists in order to call GCS's open()
key = "gs://some-bucket/some_blob.txt"
transport_params = {'client': google.cloud.storage.Client()}
benchmark(open_only, key, 'rb', transport_params=transport_params)
assert True
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def read(fname):
'boto3',
'pytest',
'pytest-rerunfailures',
'pytest-benchmark',
]

setup(
Expand Down
4 changes: 2 additions & 2 deletions smart_open/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def _handle_gzip(file_obj, mode):


def _handle_zstd(file_obj, mode):
import zstandard as zstd
result = zstd.ZstdDecompressor().stream_reader(file_obj, closefd=True)
import zstandard # type: ignore
result = zstandard.open(filename=file_obj, mode=mode)
return result


Expand Down
5 changes: 4 additions & 1 deletion smart_open/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ def Reader(bucket,
warn_deprecated('line_terminator')

bkt = client.bucket(bucket)
blob = bkt.blob(key)
blob = bkt.get_blob(key)

if blob is None:
raise google.cloud.exceptions.NotFound(f'blob {key} not found in {bucket}')

return blob.open('rb', **blob_open_kwargs)

Expand Down
12 changes: 12 additions & 0 deletions smart_open/tests/test_smart_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ def named_temporary_file(mode='w+b', prefix=None, suffix=None, delete=True):
logger.error(e)


def test_zst_write():
with named_temporary_file(suffix=".zst") as tmp:
with smart_open.open(tmp.name, "wt") as fout:
print("hello world", file=fout)
print("this is a test", file=fout)

with smart_open.open(tmp.name, "rt") as fin:
got = list(fin)

assert got == ["hello world\n", "this is a test\n"]


class ParseUriTest(unittest.TestCase):
"""
Test ParseUri class.
Expand Down
2 changes: 1 addition & 1 deletion smart_open/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '7.0.2'
__version__ = '7.0.3'


if __name__ == '__main__':
Expand Down

0 comments on commit 2865174

Please sign in to comment.