diff --git a/dvc/data/stage.py b/dvc/data/stage.py index 591530360..67225d4c7 100644 --- a/dvc/data/stage.py +++ b/dvc/data/stage.py @@ -33,7 +33,7 @@ def _upload_file(from_fs_path, fs, odb, upload_odb): tmp_info = fs_path.join(upload_odb.fs_path, tmp_fname()) with fs.open(from_fs_path, mode="rb", chunk_size=fs.CHUNK_SIZE) as stream: stream = HashedStreamReader(stream) - size = fs.getsize(from_fs_path) + size = fs.size(from_fs_path) upload_odb.fs.upload( stream, tmp_info, desc=fs_path.name(from_fs_path), total=size ) diff --git a/dvc/data/tree.py b/dvc/data/tree.py index 5996a7490..0d60327ca 100644 --- a/dvc/data/tree.py +++ b/dvc/data/tree.py @@ -226,7 +226,7 @@ class Tree(HashFile): def du(odb, tree): try: return sum( - odb.fs.getsize(odb.hash_to_path(oid.value)) for _, _, oid in tree + odb.fs.size(odb.hash_to_path(oid.value)) for _, _, oid in tree ) except FileNotFoundError: return None diff --git a/dvc/fs/base.py b/dvc/fs/base.py index cd82a1b99..a8e496515 100644 --- a/dvc/fs/base.py +++ b/dvc/fs/base.py @@ -305,8 +305,8 @@ class FileSystem: ): return self.fs.walk(path, topdown=topdown, **kwargs) - def getsize(self, path: AnyFSPath) -> Optional[int]: - return self.info(path).get("size") + def size(self, path: AnyFSPath) -> Optional[int]: + return self.fs.size(path) # pylint: enable=unused-argument diff --git a/dvc/fs/utils.py b/dvc/fs/utils.py index 9f33884e7..c19055b0a 100644 --- a/dvc/fs/utils.py +++ b/dvc/fs/utils.py @@ -47,7 +47,7 @@ def _copy( return from_fs.download_file(from_path, to_path) with from_fs.open(from_path, mode="rb") as fobj: - size = from_fs.getsize(from_path) + size = from_fs.size(from_path) return to_fs.upload(fobj, to_path, total=size) diff --git a/dvc/utils/__init__.py b/dvc/utils/__init__.py index 05f1ec9a3..81157ed99 100644 --- a/dvc/utils/__init__.py +++ b/dvc/utils/__init__.py @@ -48,7 +48,7 @@ def file_md5(fname, fs): hash_md5 = hashlib.md5() binary = not istextfile(fname, fs=fs) - size = fs.getsize(fname) or 0 + size = fs.size(fname) or 0 no_progress_bar = True if size >= LARGE_FILE_SIZE: no_progress_bar = False diff --git a/tests/func/test_fs.py b/tests/func/test_fs.py index 663e563d3..6f2adf85c 100644 --- a/tests/func/test_fs.py +++ b/tests/func/test_fs.py @@ -206,8 +206,8 @@ def test_fs_getsize(dvc, cloud): cls, config, path = get_cloud_fs(dvc, **cloud.config) fs = cls(**config) - assert fs.getsize(fs.path.join(path, "baz")) == 7 - assert fs.getsize(fs.path.join(path, "data", "foo")) == 3 + assert fs.size(fs.path.join(path, "baz")) == 7 + assert fs.size(fs.path.join(path, "data", "foo")) == 3 def test_fs_upload_fobj(dvc, tmp_dir, cloud): @@ -265,7 +265,7 @@ def test_download_callback(tmp_dir, dvc, cloud, local_cloud): (tmp_dir / "to_upload").write_text("foo") fs.upload((tmp_dir / "to_upload").fs_path, (cloud / "foo").fs_path) - expected_size = fs.getsize((cloud / "foo").fs_path) + expected_size = fs.size((cloud / "foo").fs_path) callback = fsspec.Callback() fs.download_file(