-
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
Brancher refactor #1709
Brancher refactor #1709
Conversation
1e12751
to
986e72a
Compare
986e72a
to
858e1ee
Compare
955f6aa
to
fb293c4
Compare
fb293c4
to
42c750d
Compare
672cb74
to
e843a14
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.
Great change 🎉
Looks good to me but please wait for @efiop feedback.
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.
Good stuff! 👍 Put a few minor comments and questions. First two are important, last two are less important and simple:
- Check the metrics behavior change (see the comment). This is a pretty big one as far as I understand.
- May be I'm missing something, but I don't see that the brancher includes "working tree" implementation. It should include it, right? If we want to read the current workspace content.
- I would move brancher into a separate file, close to repo itself. It operates with repo, it's not a simple "util". It probably should be part of the repo since it actively changes its state.
- The same for tree - I think they deserve to be split into two files and moved to the relevant locations.
Overall, good progress! I like that we almost don't touch any external code, just introducing a layer of abstraction. Really good stuff.
oops, got some unrelated commits... |
9cf43e1
to
7d7ed42
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.
Outstanding work! 🎉 A few small comments down below:
253a302
to
ed56623
Compare
from dvc.repo.tree import WorkingTree | ||
|
||
self.tree = WorkingTree() | ||
yield "Working Tree" |
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 breaks tests that expect previous behaviour of yielding "" if it is not from any branch. Could we continue doing that?
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.
Oops. Not this one actually, but the same thing in line 16. I did run the tests many times, but not after the line 16 change which I added at the last moment :-/.
I think it is better to clarify in the docstring that what the brancher yeilds is not a branch names (instead it is just the abstract name of the currently selected tree), and adjust the tests for this behavior. What do you think? @efiop @shcheklein
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.
AFAIR it is currently used only to display the name for metrics in different branches in dvc metrics show -a
output.
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.
Oh... and in dvc push
output, where it is reduntant for sure...
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.
So I think it is still ok to leave the "Working Tree" string for iteration with --all-branches
, but yield an empty string when there is no things to iterate over.
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.
@ei-grad "index" is even more confusing IMHO :) Empty string feels nice, but maybe I'm just too used to it 🙂
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.
Updated the docstring to about what the brancher could yeild.
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.
so, this is about printing a tree name when we do some output, right? First, I would make a tree itself return the name, no need then to yield anything and pass it around, we will be able to access it from the repo, the same way we access the current object. Is it possible? Second, in the FsTree we can return "Working Tree" or "*" or "workspace", or whatever :) Btw, i'm more or less fine with the current solution as well, it's not ideal but it's not hard to fix anyway. As for the empty string. @efiop does it mean we will have to do something like if not branch: name "Working Tree"
further along, in multiple place? I would try to avoid that.
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.
@shcheklein No, I don't see why we even need "Working Tree" anywhere.
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.
In dvc metrics show -a
when we print output we need a way to distinguish "workspace" from an actual branch. May be some other places, @ei-grad should know better than me by now :)
ed56623
to
82ad0ac
Compare
Abstract access to filesystem and its implementation to access files and particulary Stage objects in different git branches without `git checkout` execution.
Uncommited files wouldn't be accessible as git objects. It needs `git clean -fd` to amend "Working Tree" metrics collection which took its part when the git tree is dirty.
readlines() returns entries with \n on the end
82ad0ac
to
9219398
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.
Minor issue with a branch name to yield. Nice to fix. Otherwise it looks great!!!
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 pull-request implements the access to Stage objects via the Git interface to give the possibility to work with them directly without executing the
git checkout
.Fixes #1688, fixes #1552 and fixes #1009.
Todo:
XXX:
commentsmetrics.show
moveexcept Exception
backoserr.CODE
s in raised IOError'sbranch
toStage.load
incollect
, write the test for itcheckout
argument inbrancher()
Stage.is_stage_file(fname)
be checked for Git?