-
Notifications
You must be signed in to change notification settings - Fork 1.2k
checkout: show summary by default and introduce --show-changes flag #3401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
839fbcb
f2cf62e
104b450
5bcd1bf
5fb1c90
b80a44b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import logging | ||
import os | ||
|
||
from dvc.compat import fspath | ||
from dvc.exceptions import CheckoutError | ||
from dvc.exceptions import CheckoutErrorSuggestGit | ||
from dvc.progress import Tqdm | ||
|
||
from dvc.utils import relpath | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def _cleanup_unused_links(repo): | ||
def _get_unused_links(repo): | ||
used = [ | ||
out.fspath | ||
for stage in repo.stages | ||
for out in stage.outs | ||
if out.scheme == "local" | ||
] | ||
repo.state.remove_unused_links(used) | ||
return repo.state.get_unused_links(used) | ||
skshetry marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def _fspath_dir(path, root): | ||
if not os.path.exists(str(path)): | ||
return str(path) | ||
|
||
path = relpath(fspath(path), root) | ||
return os.path.join(path, "") if os.path.isdir(path) else path | ||
|
||
|
||
def get_all_files_numbers(pairs): | ||
|
@@ -34,9 +44,19 @@ def _checkout( | |
): | ||
from dvc.stage import StageFileDoesNotExistError, StageFileBadNameError | ||
|
||
unused = [] | ||
stats = { | ||
"added": [], | ||
"deleted": [], | ||
"modified": [], | ||
"failed": [], | ||
} | ||
if not targets: | ||
targets = [None] | ||
_cleanup_unused_links(self) | ||
unused = _get_unused_links(self) | ||
|
||
stats["deleted"] = [_fspath_dir(u, self.root_dir) for u in unused] | ||
self.state.remove_links(unused) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this not under if? Looks fragile this way, we shouldn't call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's empty if there's no argument. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I need to check if something is a dir before deleting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checkout in dvc:
I.e. if there is target we don't try to change the rest of the workspace, so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If targets are specified, |
||
|
||
pairs = set() | ||
for target in targets: | ||
|
@@ -52,20 +72,23 @@ def _checkout( | |
raise CheckoutErrorSuggestGit(target) from exc | ||
|
||
total = get_all_files_numbers(pairs) | ||
if total == 0: | ||
logger.info("Nothing to do") | ||
failed = [] | ||
with Tqdm( | ||
total=total, unit="file", desc="Checkout", disable=total == 0 | ||
) as pbar: | ||
for stage, filter_info in pairs: | ||
failed.extend( | ||
stage.checkout( | ||
force=force, | ||
progress_callback=pbar.update_desc, | ||
relink=relink, | ||
filter_info=filter_info, | ||
) | ||
result = stage.checkout( | ||
force=force, | ||
progress_callback=pbar.update_desc, | ||
relink=relink, | ||
filter_info=filter_info, | ||
) | ||
if failed: | ||
raise CheckoutError(failed) | ||
for data in ["failed", "added", "modified"]: | ||
stats[data].extend( | ||
_fspath_dir(path, self.root_dir) for path in result[data] | ||
) | ||
|
||
if stats.get("failed"): | ||
raise CheckoutError(stats["failed"], stats) | ||
|
||
del stats["failed"] | ||
return stats |
Uh oh!
There was an error while loading. Please reload this page.