mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
fix checkout callback during add/commit (#9445)
* fix checkout callback Fix https://github.com/iterative/dvc/issues/6226. * bump minversion of dvc-data to 0.49.1
This commit is contained in:
+42
-23
@@ -36,7 +36,7 @@ from dvc_objects.errors import ObjectFormatError
|
|||||||
|
|
||||||
from .annotations import ANNOTATION_FIELDS, ANNOTATION_SCHEMA, Annotation
|
from .annotations import ANNOTATION_FIELDS, ANNOTATION_SCHEMA, Annotation
|
||||||
from .fs import LocalFileSystem, RemoteMissingDepsError, Schemes, get_cloud_fs
|
from .fs import LocalFileSystem, RemoteMissingDepsError, Schemes, get_cloud_fs
|
||||||
from .fs.callbacks import DEFAULT_CALLBACK
|
from .fs.callbacks import DEFAULT_CALLBACK, Callback
|
||||||
from .utils import relpath
|
from .utils import relpath
|
||||||
from .utils.fs import path_isin
|
from .utils.fs import path_isin
|
||||||
|
|
||||||
@@ -45,7 +45,6 @@ if TYPE_CHECKING:
|
|||||||
from dvc_data.index import DataIndexKey
|
from dvc_data.index import DataIndexKey
|
||||||
from dvc_objects.db import ObjectDB
|
from dvc_objects.db import ObjectDB
|
||||||
|
|
||||||
from .fs.callbacks import Callback
|
|
||||||
from .ignore import DvcIgnoreFilter
|
from .ignore import DvcIgnoreFilter
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -740,15 +739,20 @@ class Output:
|
|||||||
hardlink=hardlink,
|
hardlink=hardlink,
|
||||||
)
|
)
|
||||||
if relink:
|
if relink:
|
||||||
self._checkout(
|
rel = self.fs.path.relpath(filter_info or self.fs_path)
|
||||||
filter_info or self.fs_path,
|
with Callback.as_tqdm_callback(
|
||||||
self.fs,
|
desc=f"Checking out {rel}", unit="files"
|
||||||
obj,
|
) as callback:
|
||||||
self.cache,
|
self._checkout(
|
||||||
relink=True,
|
filter_info or self.fs_path,
|
||||||
state=self.repo.state,
|
self.fs,
|
||||||
prompt=prompt.confirm,
|
obj,
|
||||||
)
|
self.cache,
|
||||||
|
relink=True,
|
||||||
|
state=self.repo.state,
|
||||||
|
prompt=prompt.confirm,
|
||||||
|
progress_callback=callback,
|
||||||
|
)
|
||||||
self.set_exec()
|
self.set_exec()
|
||||||
|
|
||||||
def _commit_granular_dir(self, filter_info, hardlink) -> Optional["HashFile"]:
|
def _commit_granular_dir(self, filter_info, hardlink) -> Optional["HashFile"]:
|
||||||
@@ -890,9 +894,19 @@ class Output:
|
|||||||
checkpoint_reset: bool = False,
|
checkpoint_reset: bool = False,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> Optional[Tuple[bool, Optional[bool]]]:
|
) -> Optional[Tuple[bool, Optional[bool]]]:
|
||||||
|
# callback passed act as a aggregate callback.
|
||||||
|
# do not let checkout to call set_size and change progressbar.
|
||||||
|
class CallbackProxy(Callback):
|
||||||
|
def relative_update(self, inc: int = 1) -> None:
|
||||||
|
progress_callback.relative_update(inc)
|
||||||
|
return super().relative_update(inc)
|
||||||
|
|
||||||
|
def branch(self, *args, **kwargs):
|
||||||
|
return progress_callback.branch(*args, **kwargs)
|
||||||
|
|
||||||
|
callback = CallbackProxy()
|
||||||
if not self.use_cache:
|
if not self.use_cache:
|
||||||
if progress_callback != DEFAULT_CALLBACK:
|
callback.relative_update(self.get_files_number(filter_info))
|
||||||
progress_callback.relative_update(self.get_files_number(filter_info))
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
obj = self.get_obj(filter_info=filter_info)
|
obj = self.get_obj(filter_info=filter_info)
|
||||||
@@ -914,7 +928,7 @@ class Output:
|
|||||||
obj,
|
obj,
|
||||||
self.cache,
|
self.cache,
|
||||||
force=force,
|
force=force,
|
||||||
progress_callback=progress_callback,
|
progress_callback=callback,
|
||||||
relink=relink,
|
relink=relink,
|
||||||
state=self.repo.state,
|
state=self.repo.state,
|
||||||
prompt=prompt.confirm,
|
prompt=prompt.confirm,
|
||||||
@@ -1342,15 +1356,20 @@ class Output:
|
|||||||
otransfer(staging, self.cache, {obj.hash_info}, hardlink=relink, shallow=False)
|
otransfer(staging, self.cache, {obj.hash_info}, hardlink=relink, shallow=False)
|
||||||
|
|
||||||
if relink:
|
if relink:
|
||||||
self._checkout(
|
rel = self.fs.path.relpath(path)
|
||||||
path,
|
with Callback.as_tqdm_callback(
|
||||||
self.fs,
|
desc=f"Checking out {rel}", unit="files"
|
||||||
obj,
|
) as callback:
|
||||||
self.cache,
|
self._checkout(
|
||||||
relink=True,
|
path,
|
||||||
state=self.repo.state,
|
self.fs,
|
||||||
prompt=prompt.confirm,
|
obj,
|
||||||
)
|
self.cache,
|
||||||
|
relink=True,
|
||||||
|
state=self.repo.state,
|
||||||
|
prompt=prompt.confirm,
|
||||||
|
progress_callback=callback,
|
||||||
|
)
|
||||||
self.set_exec()
|
self.set_exec()
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ def push_worktree(
|
|||||||
) as cb:
|
) as cb:
|
||||||
cb.set_size(total)
|
cb.set_size(total)
|
||||||
try:
|
try:
|
||||||
pushed += checkout(
|
stats = checkout(
|
||||||
new_index,
|
new_index,
|
||||||
remote_obj.path,
|
remote_obj.path,
|
||||||
remote_obj.fs,
|
remote_obj.fs,
|
||||||
@@ -184,6 +184,7 @@ def push_worktree(
|
|||||||
jobs=jobs,
|
jobs=jobs,
|
||||||
**diff_kwargs,
|
**diff_kwargs,
|
||||||
)
|
)
|
||||||
|
pushed += sum(len(changes) for changes in stats.values())
|
||||||
except VersioningNotSupported:
|
except VersioningNotSupported:
|
||||||
logger.exception("")
|
logger.exception("")
|
||||||
raise DvcException(
|
raise DvcException(
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ dependencies = [
|
|||||||
"configobj>=5.0.6",
|
"configobj>=5.0.6",
|
||||||
"distro>=1.3",
|
"distro>=1.3",
|
||||||
"dpath<3,>=2.1.0",
|
"dpath<3,>=2.1.0",
|
||||||
"dvc-data>=0.47.5,<0.48",
|
"dvc-data>=0.49.1,<0.50",
|
||||||
"dvc-http>=2.29.0",
|
"dvc-http>=2.29.0",
|
||||||
"dvc-render>=0.3.1,<1",
|
"dvc-render>=0.3.1,<1",
|
||||||
"dvc-studio-client>=0.9.0,<1",
|
"dvc-studio-client>=0.9.0,<1",
|
||||||
|
|||||||
Reference in New Issue
Block a user