-
Notifications
You must be signed in to change notification settings - Fork 1k
Add itemized feedback for dep resolution in init #512
Conversation
cmd/dep/init.go
Outdated
// 3. if not exists in manifest, check in pkgT | ||
// 3.a. if exists in pkgT, it's direct dep, hint constraint, lock only | ||
// 3.b. if not exists in pkgT, it's transitive dep, lock only | ||
// 4. log 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.
Is this a good algo to separate direct and transitive deps? Any other simpler solution?
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.
Imports are the only thing responsible for deciding what's direct vs. transitive - not the manifest. (Well, required
packages in the manifest have the same effect, but it's not possible for there to be any here, so that's a wash). So, I think you can just drop 1 & 2 and go right to 3.
3.a. isn't quite on the mark either, but I think that what I wrote in the spec doc might be clearer with 1 & 2 out of the way? if not, i can clarify further 😄
Output of init with this change:
|
Let's also get rid of this feedback as part of the PR. We added it initially to provide some feedback to the user while work was being done, but the feedback we're adding here is much better.
Generally yes, but we can't actually rely on only having git SHA1s - there's also hg, bzr, svn, and whatever else we come up with in the future. hg also has SHA1 revs, but svn has simple integers, and bzr has a weird thing. I'd say that it's fine to trim if you can positively identify something shaped like a SHA1, but in the other cases, leave it as-is. |
cmd/dep/init.go
Outdated
cf.DependencyType = internal.DepTypeDirect | ||
cf.ConstraintType = internal.ConsTypeConstraint | ||
} else { | ||
if _, ok := pkgT.Packages[string(projectPath)]; ok { |
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.
The Packages
map isn't quite what you're looking for - it's the list of packages within the current project, not the imports of those packages. What you want is a bit more elaborate. I've got code that does it over in #489 - https://github.com/sdboyer/dep/blob/1b8edb3436f39dbc29b4fae81dc1d51b2e77a303/cmd/dep/ensure.go#L390-L409 .
cmd/dep/init.go
Outdated
// 3. if not exists in manifest, check in pkgT | ||
// 3.a. if exists in pkgT, it's direct dep, hint constraint, lock only | ||
// 3.b. if not exists in pkgT, it's transitive dep, lock only | ||
// 4. log 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.
Imports are the only thing responsible for deciding what's direct vs. transitive - not the manifest. (Well, required
packages in the manifest have the same effect, but it's not possible for there to be any here, so that's a wash). So, I think you can just drop 1 & 2 and go right to 3.
3.a. isn't quite on the mark either, but I think that what I wrote in the spec doc might be clearer with 1 & 2 out of the way? if not, i can clarify further 😄
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.
just a few things
7676985
to
7222809
Compare
cmd/dep/init.go
Outdated
|
||
// Get manifest version if available | ||
if pp, ok := m.Dependencies[lock.Ident().ProjectRoot]; ok { | ||
cf.Version = pp.Constraint.String() |
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.
@sdboyer any idea what's wrong here?
Integration tests for init case 1 and 3 are failing due to this line. If this assignment is removed, tests pass.
Is there any way to view the errors? go test -v
doesn't show the actual error, same as logs in appveyor and travis.
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'm not sure. And unfortunately, I don't think there's a way to see those errors. Would be a great thing to open an issue for 😄
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.
PR #523 for the same.
cmd/dep/init.go
Outdated
// 2.b.i. if it has a version attached, constraint dep | ||
// 2.b.ii. if it has revision only, hint dep | ||
// 2.c. else it's a transitive dep | ||
// 2.d. log 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.
Correct? 😅
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 think so, apart from those two nits
7222809
to
a2ee5e2
Compare
This is how the feedback looks now:
|
cmd/dep/init.go
Outdated
// 2.b. if it's a direct dep: | ||
// 2.b.i. if it has a version attached, constraint dep | ||
// 2.b.ii. if it has revision only, hint dep | ||
// 2.c. else it's a transitive dep |
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.
should be explicit and note that it goes into the lock
cmd/dep/init.go
Outdated
// 2. loop through lock projects | ||
// 2.a. check if the projects exists in direct deps list | ||
// 2.b. if it's a direct dep: | ||
// 2.b.i. if it has a version attached, constraint dep |
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.
nit: s/constraint/constrain/
cmd/dep/init.go
Outdated
// 2.b.i. if it has a version attached, constraint dep | ||
// 2.b.ii. if it has revision only, hint dep | ||
// 2.c. else it's a transitive dep | ||
// 2.d. log 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.
i think so, apart from those two nits
cmd/dep/init.go
Outdated
|
||
// Get manifest version if available | ||
if pp, ok := m.Dependencies[lock.Ident().ProjectRoot]; ok { | ||
cf.Version = pp.Constraint.String() |
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'm not sure. And unfortunately, I don't think there's a way to see those errors. Would be a great thing to open an issue for 😄
Guess it's ready? |
Ahh, crap. So instead of just reviewing the code, I finally actually set this up and ran it locally. And I now realize there was a basic miscommunication - I'm sorry 😢 All of the output itself is looks good, but the timing is off. This provides the itemized list of choices after solving has already occurred. That was not what I had in mind; rather, I wanted this output to replace the existing output that's generated during the discovery process. So, that's all of the:
This is why the spec has those header sections, e.g. |
@sdboyer I thought about it when I started implementing this. The feedback should be incremental. I realized that it would require changes in gps for instant feedback while resolving. But then, I thought these feedback should not be part of gps because they are dep specific. Hence, continued with this post-solve feedback. Maybe the gps solver could be modified to attach some function that would be called to log these feedback at every solving iteration and keep gps generic? About moving the output from post-solve segment to discovery segment, again I'm not sure how to get the solution data before running a solve. On another thought, this is a network mode specific issue, I guess, which is the only mode at the moment 😬. Not sure how to proceed from here. Maybe put this on hold until the other parts are implemented 🙂 |
oops! it can still be done. My bad. Right now, we do search $GOPATH and go for network for not on disk deps. Which means, feedback can be logged for them, no need to wait for -gopath PR 🤦♂️ silly me 😅. |
289e393
to
57d870b
Compare
Separated network and $GOPATH based dep's feedback. $GOPATH based deps show up incrementally as they are discovered but network based deps show up together because they are received together from the solver. Still wondering if it would be a good idea to attach a function to the solver to make network deps discovery incremental 🤔 Feedback output still looks the same, with $GOPATH and network headers:
Will remove these once we decide if this new approach is better. |
This obviously needs refactor after #525 (sorry 😞 ), but two nits for when you get around to it:
|
I'm prepping that feature branch - rebase, when you can? (plus those last couple nits). |
Will rebase once #544 is merged. Import cycle issues even if I rebase now. |
all merged up :) |
- Creates ConstraintFeedback struct to hold dep constraint data. - Adds GetUsingFeedback() and GetLockingFeedback() functions to generate feedback text. - Adds incremental feedback for deps found in $GOPATH and separate feedback for network solved deps.
57d870b
to
4c785b9
Compare
@sdboyer squashed, rebased and made some adjustments to fit with the new code.
|
OK, new |
So, I just ran b/c yeah, this is super confusing:
|
oops! 😅 that's really a mess. Will create a follow-up PR. |
cool, thank you :) i'm also inclined to revisit the enumerating of the items "over the network" - that's just listing out what ended up in the solution. this creates misleading output - what's read from GOPATH (and later, other projects' metadata) are hints/inputs that might change, whereas the "from network" output is what's actually been selected. i think it may instead be better to enumerate the list of dependencies for which the local search method did not turn up a result, enumerate them, and indicate that the dep will instead simply rely on its "default most recent version" logic. Only, yknow, wordsmithed in a way that will be understandable for users 😄 |
dependencies. Based on the constraints, logs them as feedback.
feedback text.
Fixes #503