-
Notifications
You must be signed in to change notification settings - Fork 1k
internal/gps: ensure packages are deducible before attempting to solve #697
internal/gps: ensure packages are deducible before attempting to solve #697
Conversation
bbde9bb
to
da33cb1
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.
Yep! Definitely the right direction.
One thing, though. I realize I'm countermanding myself, but let's actually do this under solver.Solve()
instead of Prepare()
. These deductions have the possibility of triggering network activity, and I'd prefer to keep the work done in Prepare()
strictly IO-free.
It'd be fine to add a solver.validateParams()
method that does this, and call it nearly first thing, immediately before solver.selectRoot()
in solver.Solve()
. Chances are we'll have some more validation like this to add, and we can lump it into that method.
@sdboyer Done. Note that
I've extracted the logic to a |
c7a2389
to
e159914
Compare
@sdboyer It seems that I tried to go back to Any preference on how to tackle this? |
@ibrasho ahh...crap. Yes, the bridge allows races, because the entire solver is designed to be strictly single-threaded. OK, given these issues, yes - let's move the verification back to |
@sdboyer That test case adds 2 dependencies called This is what's causing CI builds to fail. |
🤦♂️ sorry, of course, that make sense. let me ponder a bit on the least invasive way to fix this. |
OK, new plan. We don't actually need to do this validation within the solver, because it's all failures we'd arrive at eventually, anyway. That's a strong indication that this isn't actually "validation" in the sense that these conditions must be met for solver behavior to be defined. It's actually just preemptively doing work the solver would do later. Let's do this validation as a standalone function in gps, and call that function directly from dep, prior to Returning to the original panic encountered in #581, we can do yet another separate PR which is about gps' purely internal graceful handling of that case. |
b89b600
to
2058950
Compare
@sdboyer: This is passing now. But I still don't like it. I'm creating another instance of |
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, i know i've been slow the last week - trying to catch up!
} | ||
|
||
// ValidateParams validates the solver parameters to ensure solving can be completed. | ||
func ValidateParams(params SolveParameters, sm SourceManager) error { |
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.
Need just a basic test for this - feed it some SolveParameters
with both valid and invalid import paths.
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.
Are the tests in solver_test.go
enough?
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, yes, they are. but, how about we rename that file to solver_inputs_test.go
, and move TestBadSolveOpts
into there?
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.
done.
fc84b7b
to
f1d5b48
Compare
Add gps.ValidateParams to ensure all packages in SolverParams are deducible. Signed-off-by: Ibrahim AshShohail <[email protected]>
f1d5b48
to
a961d76
Compare
e8d34d0
to
a961d76
Compare
Signed-off-by: Ibrahim AshShohail <[email protected]>
i think the CLA issue should clear if a new commit comes in. maybe just rebase this and re-push, that should be enough. |
1f42a17
to
b6260d6
Compare
That trick actually 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.
little nit, looks like a debugging fmt.Println()
survived
internal/gps/solver.go
Outdated
} | ||
|
||
deducePkg := func(ip string, sm SourceManager) { | ||
fmt.Println(ip) |
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.
seems like a debugging print?
Signed-off-by: Ibrahim AshShohail <[email protected]>
b6260d6
to
92df3dc
Compare
Anything else needed here? 😁 |
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.
nothing! in we go 😄
see, i said that, but then...yeah, we need this to be expanded, now that there are more places we actually solve/prepare params in ensure. |
An attempt to resolve #581.
I still think it could use some polishing, but I wanted to check if I'm moving in the right direction.