-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
checkout: show summary by default and introduce --show-changes flag #3401
Conversation
63de201
to
23256a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes our checkout tech debt even bigger. But I am fine for now as long as this works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment.
I find handling of added
, modified
, and no_change
as False
, True
, None
respectively a bit confusing at least in 2 places in code, one is base._checkout_dir
and another one is pointed by @Suor
here
Boolean has 2 values and I think it is easy to omit the information passed from within checkout
.
dvc/command/checkout.py
Outdated
logger = logging.getLogger(__name__) | ||
|
||
|
||
def _humanize_wordseries(words=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it to the utils? there should be some libraries that do different "humanization" stuff ... not sure if we want to utilize them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to keep it near to where it's used for now. If we later need it elsewhere, we can do so at that time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π up to you, absolutely minor thing.
Let me share my intuition behind this, though :)
- Readability - any boilerplate code that makes file longer and absolutely not relevant/generic makes it harder to see the "bigger picture" (tools like CodeClimate complain about file being too long, about too many methods, etc for a good reason);
- Reusability - the knowledge about this generic "text" util is only in your head. Low chances that someone will be able to find it when it's needed again. Means some probability of a duplicate later.
- Testing - you can unit test this simple things, would be strange to write a unit test for a private method though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not like humanizing, it's joining and not word series but some items in a list, so the name might be better, e.g. human_join()
or smth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On keeping it here - I am with @skshetry here, move it later if that is used elsewhere. Spreading code is the big source of errors. Also impairs readability.
dvc/stage.py
Outdated
def _fspath_dir(path): | ||
"""Return string with "/" at the end if it's a dir.""" | ||
p = os.path.join(path, "") if os.path.isdir(path) else fspath(path) | ||
return relpath(p, self.repo.root_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about it? (if I got the function purpose right)
rel = relpath(p, self.repo.root_dir)
return "{}{}".format(rel, os.path.sep) if os.path.isdir(path) else rel
30c9e5d
to
1f4fbf0
Compare
dvc/exceptions.py
Outdated
def __init__(self, target_infos): | ||
def __init__(self, target_infos, stats=None): | ||
self.target_infos = target_infos | ||
self.stats = stats | ||
targets = [str(t) for t in target_infos] | ||
m = ( | ||
"Checkout failed for following targets:\n {}\nDid you " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, really minor request (feel free to nor change this), came out as I was reviewing:
ERROR: unexpected error - Checkout failed for following targets:
data/prepared
data/features
data/data.xml
there is an extra space that is not needed before data/prepared
. I think the change is \n {}\n
-> \n{}\n
@skshetry going back to the requirements in the #2979 (you mention in the description) , I think it does not resolve them for the failed case:
we still have excessive WARNINGS . We can create a separate PR for this or keep the ticket open. I think a summary is enough:
Again, happy to just keep that ticket open. |
It still affects
and sometimes:
|
(Also, going through the example get started I have more and more reasons for the |
I'm also more inclined to make this the default, even more so with making output formats of Later, we could decide if we really need
Looks like on second example,
It'd be better to just reduce the level of loggings here to Thanks Ivan for checking out! |
@skshetry I don't think you can simply make those warnings debug, this will affect more things than just checkout, e.g. |
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 comment
The 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 remove_links()
at all if a particular target is specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Checkout in dvc:
- checks out particular thing(s) if that things (target) is specified
- if no target is specified it checks out everything and removes anything previously checked out and having no references now.
I.e. if there is target we don't try to change the rest of the workspace, so .remove_links()
should not be called. The logic of your code is different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If targets are specified, unused
will be empty and hence, nothing will get removed. If your concern is regarding calling .remove_links()
at all, I don't think there's any reason to be defensive.
@shcheklein, I have changed the defaults. There's a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff, thanks @skshetry !
(please, create a ticket of address docs and bash/zsh scripts? I assume the plan is to do a separate PR, right?)
sorry, wanted to approve initially, missed the button ) |
Co-Authored-By: Jorge Orpinel <jorgeorpinel@users.noreply.github.com>
@shcheklein, @efiop, I have created an issue #3483 for handling autocompletion scripts. |
β Have you followed the guidelines in the Contributing to DVC list?
π Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.
cmd-ref: document checkout displaying changesΒ dvc.org#1054
β Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addressed. Please review them carefully and fix those that actually improve code or fix bugs.
Thank you for the contribution - we'll try to review it as soon as possible. π
Resolves #2979.
TODO
CheckoutError
: go with the consensus.--relink
andmodified
case.--relink
successfully message. (Separate PR)