mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-08 15:28:26 +01:00
objects.hash: rename HashedStreamReader to HashStreamFile
This commit is contained in:
committed by
Ruslan Kuprieiev
parent
01e5f9eadd
commit
36605eea4c
+2
-2
@@ -32,12 +32,12 @@ _STAGING_MEMFS_PATH = "dvc-staging"
|
||||
def _upload_file(from_fs_path, fs, odb, upload_odb, callback=None):
|
||||
from dvc.objects.fs._callback import FsspecCallback
|
||||
from dvc.objects.fs.utils import tmp_fname
|
||||
from dvc.objects.hash import HashedStreamReader
|
||||
from dvc.objects.hash import HashStreamFile
|
||||
|
||||
fs_path = upload_odb.fs.path
|
||||
tmp_info = fs_path.join(upload_odb.fs_path, tmp_fname())
|
||||
with fs.open(from_fs_path, mode="rb") as stream:
|
||||
stream = HashedStreamReader(stream)
|
||||
stream = HashStreamFile(stream)
|
||||
size = fs.size(from_fs_path)
|
||||
with FsspecCallback.as_tqdm_callback(
|
||||
callback,
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ def get_hasher(name: str) -> "hashlib._Hash":
|
||||
return hashlib.new(name)
|
||||
|
||||
|
||||
class HashedStreamReader(io.IOBase):
|
||||
class HashStreamFile(io.IOBase):
|
||||
def __init__(
|
||||
self,
|
||||
fobj: BinaryIO,
|
||||
@@ -75,7 +75,7 @@ def fobj_md5(
|
||||
# regardless of the size of the first chunk,
|
||||
# for which we may need to buffer till DEFAULT_CHUNK_SIZE.
|
||||
assert chunk_size >= DEFAULT_CHUNK_SIZE
|
||||
stream = HashedStreamReader(fobj, text=text)
|
||||
stream = HashStreamFile(fobj, text=text)
|
||||
while True:
|
||||
data = stream.read(chunk_size)
|
||||
if not data:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from dvc.objects.fs import LocalFileSystem
|
||||
from dvc.objects.hash import HashedStreamReader, file_md5
|
||||
from dvc.objects.hash import HashStreamFile, file_md5
|
||||
from dvc.objects.istextfile import DEFAULT_CHUNK_SIZE, istextfile
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ def test_hashed_stream_reader(tmp_dir):
|
||||
|
||||
foo = tmp_dir / "foo"
|
||||
with open(foo, "rb") as fobj:
|
||||
stream_reader = HashedStreamReader(fobj)
|
||||
stream_reader = HashStreamFile(fobj)
|
||||
|
||||
assert stream_reader.readable()
|
||||
assert not stream_reader.seekable()
|
||||
@@ -33,7 +33,7 @@ def test_hashed_stream_reader_as_chunks(tmp_dir):
|
||||
|
||||
actual_size = len(foo.read_bytes())
|
||||
with open(foo, "rb") as fobj:
|
||||
stream_reader = HashedStreamReader(fobj)
|
||||
stream_reader = HashStreamFile(fobj)
|
||||
|
||||
total_read = 0
|
||||
while True:
|
||||
@@ -63,7 +63,7 @@ def test_hashed_stream_reader_compatibility(tmp_dir, contents):
|
||||
data = tmp_dir / "data"
|
||||
|
||||
with open(data, "rb") as fobj:
|
||||
stream_reader = HashedStreamReader(fobj)
|
||||
stream_reader = HashStreamFile(fobj)
|
||||
stream_reader.read(chunk_size)
|
||||
|
||||
local_fs = LocalFileSystem()
|
||||
|
||||
Reference in New Issue
Block a user