Extract Output.download() into a function

Also, move the method to Dependency, since it's only used there.
This commit is contained in:
Ronan Lamy
2022-10-07 19:03:57 +03:00
committed by Ruslan Kuprieiev
parent 8640beb998
commit 6a0d7f9c51
3 changed files with 13 additions and 9 deletions
+4
View File
@@ -1,6 +1,7 @@
from typing import Type
from dvc.exceptions import DvcException
from dvc.fs import download as fs_download
from dvc.output import Output
@@ -32,3 +33,6 @@ class Dependency(Output):
def update(self, rev=None):
pass
def download(self, to, jobs=None):
fs_download(self.fs, self.fs_path, to, jobs=jobs)
+9
View File
@@ -26,6 +26,7 @@ from dvc_objects.fs.errors import ( # noqa: F401
)
from dvc_objects.fs.path import Path # noqa: F401
from .callbacks import Callback
from .data import DataFileSystem # noqa: F401
from .dvc import DVCFileSystem # noqa: F401
from .git import GitFileSystem # noqa: F401
@@ -47,6 +48,14 @@ known_implementations.update(
# pylint: enable=unused-import
def download(fs, fs_path, to, jobs=None):
with Callback.as_tqdm_callback(
desc=f"Downloading {fs.path.name(fs_path)}",
unit="files",
) as cb:
fs.get(fs_path, to.fs_path, batch_size=jobs, callback=cb)
def get_fs_config(config, **kwargs):
name = kwargs.get("name")
if name:
-9
View File
@@ -797,15 +797,6 @@ class Output:
f"binary file '{self.fs_path}' cannot be used as metrics."
)
def download(self, to, jobs=None):
from dvc.fs.callbacks import Callback
with Callback.as_tqdm_callback(
desc=f"Downloading {self.fs.path.name(self.fs_path)}",
unit="files",
) as cb:
self.fs.get(self.fs_path, to.fs_path, batch_size=jobs, callback=cb)
def get_obj(
self, filter_info: Optional[str] = None, **kwargs
) -> Optional["HashFile"]: