Skip to content

Commit

Permalink
deps: update dvc-data to >=2.24 (#10158)
Browse files Browse the repository at this point in the history
  • Loading branch information
skshetry authored Dec 13, 2023
1 parent 8ccae0a commit dec1ac7
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 24 deletions.
9 changes: 6 additions & 3 deletions dvc/data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import TYPE_CHECKING, Iterable, Optional, Set, Tuple

from dvc.config import NoRemoteError, RemoteConfigError
from dvc.fs.callbacks import Callback
from dvc.log import logger
from dvc.utils.objects import cached_property
from dvc_data.hashfile.db import get_index
Expand Down Expand Up @@ -206,11 +205,13 @@ def _push(
jobs: Optional[int] = None,
odb: "HashFileDB",
) -> "TransferResult":
from dvc.fs.callbacks import TqdmCallback

if odb.hash_name == "md5-dos2unix":
cache = self.repo.cache.legacy
else:
cache = self.repo.cache.local
with Callback.as_tqdm_callback(
with TqdmCallback(
desc=f"Pushing to {odb.fs.unstrip_protocol(odb.path)}",
unit="file",
) as cb:
Expand Down Expand Up @@ -265,11 +266,13 @@ def _pull(
jobs: Optional[int] = None,
odb: "HashFileDB",
) -> "TransferResult":
from dvc.fs.callbacks import TqdmCallback

if odb.hash_name == "md5-dos2unix":
cache = self.repo.cache.legacy
else:
cache = self.repo.cache.local
with Callback.as_tqdm_callback(
with TqdmCallback(
desc=f"Fetching from {odb.fs.unstrip_protocol(odb.path)}",
unit="file",
) as cb:
Expand Down
6 changes: 4 additions & 2 deletions dvc/fs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
from dvc_objects.fs.path import Path # noqa: F401

from .callbacks import Callback
from .callbacks import Callback # noqa: F401
from .data import DataFileSystem # noqa: F401
from .dvc import DVCFileSystem
from .git import GitFileSystem # noqa: F401
Expand All @@ -51,7 +51,9 @@ def download(
) -> int:
from dvc.scm import lfs_prefetch

with Callback.as_tqdm_callback(
from .callbacks import TqdmCallback

with TqdmCallback(
desc=f"Downloading {fs.path.name(fs_path)}",
unit="files",
) as cb:
Expand Down
10 changes: 5 additions & 5 deletions dvc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def commit(self, filter_info=None, relink=True) -> None:
self.hash_name,
ignore=self.dvcignore,
)
with Callback.as_tqdm_callback(
with TqdmCallback(
desc=f"Committing {self} to cache",
unit="file",
) as cb:
Expand Down Expand Up @@ -826,7 +826,7 @@ def _commit_granular_dir(self, filter_info, hardlink) -> Optional["HashFile"]:
save_obj = obj.filter(prefix)
assert isinstance(save_obj, Tree)
checkout_obj = save_obj.get_obj(self.cache, prefix)
with Callback.as_tqdm_callback(
with TqdmCallback(
desc=f"Committing {self} to cache",
unit="file",
) as cb:
Expand Down Expand Up @@ -1059,7 +1059,7 @@ def transfer(
upload=upload,
no_progress_bar=no_progress_bar,
)
with Callback.as_tqdm_callback(
with TqdmCallback(
desc=f"Transferring to {odb.fs.unstrip_protocol(odb.path)}",
unit="file",
) as cb:
Expand Down Expand Up @@ -1092,7 +1092,7 @@ def get_files_number(self, filter_info=None):

def unprotect(self):
if self.exists and self.use_cache:
with Callback.as_tqdm_callback(
with TqdmCallback(
size=self.meta.nfiles or -1, desc=f"Unprotecting {self}"
) as callback:
self.cache.unprotect(self.fs_path, callback=callback)
Expand Down Expand Up @@ -1438,7 +1438,7 @@ def add( # noqa: C901

assert staging
assert obj.hash_info
with Callback.as_tqdm_callback(
with TqdmCallback(
desc=f"Adding {self} to cache",
unit="file",
) as cb:
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ def init(root_dir=os.curdir, no_scm=False, force=False, subdir=False) -> "Repo":
return init(root_dir=root_dir, no_scm=no_scm, force=force, subdir=subdir)

def unprotect(self, target):
from dvc_objects.fs.callbacks import Callback
from dvc.fs.callbacks import TqdmCallback

with Callback.as_tqdm_callback(desc=f"Unprotecting {target}") as callback:
with TqdmCallback(desc=f"Unprotecting {target}") as callback:
return self.cache.repo.unprotect(target, callback=callback)

def _ignore(self):
Expand Down
5 changes: 3 additions & 2 deletions dvc/repo/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ def _download_studio(
) -> Tuple[int, str]:
from dvc_studio_client.model_registry import get_download_uris

from dvc.fs import Callback, HTTPFileSystem, generic, localfs
from dvc.fs import HTTPFileSystem, generic, localfs
from dvc.fs.callbacks import TqdmCallback

logger.debug("Trying to download artifact '%s' via studio", name)
out = out or os.getcwd()
Expand Down Expand Up @@ -244,7 +245,7 @@ def _download_studio(
) from exc
fs = HTTPFileSystem()
jobs = jobs or fs.jobs
with Callback.as_tqdm_callback(
with TqdmCallback(
desc=f"Downloading '{name}' from '{repo_url}'",
unit="files",
) as cb:
Expand Down
4 changes: 2 additions & 2 deletions dvc/repo/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ def save_imports(
Returns:
Objects which were downloaded from source location.
"""
from dvc.fs.callbacks import TqdmCallback
from dvc.stage.exceptions import DataSourceChanged
from dvc_data.index import md5, save
from dvc_data.index.checkout import apply, compare
from dvc_objects.fs.callbacks import Callback

downloaded: Set["HashInfo"] = set()

Expand All @@ -122,7 +122,7 @@ def save_imports(
if not cache.fs.exists(cache.path):
os.makedirs(cache.path)
with TemporaryDirectory(dir=cache.path) as tmpdir:
with Callback.as_tqdm_callback(
with TqdmCallback(
desc="Downloading imports from source",
unit="files",
) as cb:
Expand Down
8 changes: 3 additions & 5 deletions dvc/repo/worktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from funcy import first

from dvc.fs.callbacks import Callback
from dvc.log import logger
from dvc.stage.exceptions import StageUpdateError

Expand Down Expand Up @@ -247,11 +246,12 @@ def _fetch_out_changes(
remote_index: Union["DataIndex", "DataIndexView"],
remote: "Remote",
):
from dvc.fs.callbacks import TqdmCallback
from dvc_data.index.checkout import apply, compare

old, new = _get_diff_indexes(out, local_index, remote_index)

with Callback.as_tqdm_callback(
with TqdmCallback(
unit="entry",
desc="Comparing indexes",
) as cb:
Expand All @@ -265,9 +265,7 @@ def _fetch_out_changes(
)

total = len(new)
with Callback.as_tqdm_callback(
unit="file", desc=f"Updating '{out}'", disable=total == 0
) as cb:
with TqdmCallback(unit="file", desc=f"Updating '{out}'", disable=total == 0) as cb:
cb.set_size(total)
apply(
diff,
Expand Down
4 changes: 2 additions & 2 deletions dvc/stage/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def restore(self, stage, run_cache=True, pull=False, dry=False): # noqa: C901

def transfer(self, from_odb, to_odb):
from dvc.fs import HTTPFileSystem, LocalFileSystem
from dvc.fs.callbacks import Callback
from dvc.fs.callbacks import TqdmCallback

from_fs = from_odb.fs
to_fs = to_odb.fs
Expand Down Expand Up @@ -266,7 +266,7 @@ def transfer(self, from_odb, to_odb):

src_name = from_fs.path.name(src)
parent_name = from_fs.path.name(from_fs.path.parent(src))
with Callback.as_tqdm_callback(
with TqdmCallback(
desc=src_name,
bytes=True,
) as cb:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies = [
"configobj>=5.0.6",
"distro>=1.3",
"dpath<3,>=2.1.0",
"dvc-data>=2.23.1,<2.24",
"dvc-data>=2.24,<2.25",
"dvc-http>=2.29.0",
"dvc-render>=1.0.0,<2",
"dvc-studio-client>=0.17.1,<1",
Expand Down

0 comments on commit dec1ac7

Please sign in to comment.