mirror of https://github.com/databricks/cli.git
Ensure that python dependencies are installed during upgrade (#1390)
## Changes The installer.Upgrade() processing did not install Python dependencies. This resulted in errors such as: ``` ModuleNotFoundError: No module named 'databricks.labs.blueprint' ``` Any new dependencies are now installed during the upgrade process. Resolves: databrickslabs/ucx#1276 ## Tests The TestUpgraderWorksForReleases test now checks to see if the upgrade process resulted in the dependencies being installed. --------- Signed-off-by: Jim.Idle <jimi@idle.ws>
This commit is contained in:
parent
1c02224902
commit
4c71f8cac4
|
@ -136,6 +136,10 @@ func (i *installer) Upgrade(ctx context.Context) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("installer: %w", err)
|
||||
}
|
||||
err = i.installPythonDependencies(ctx, ".")
|
||||
if err != nil {
|
||||
return fmt.Errorf("python dependencies: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -403,6 +403,12 @@ func TestUpgraderWorksForReleases(t *testing.T) {
|
|||
newHome := copyTestdata(t, "testdata/installed-in-home")
|
||||
ctx = env.WithUserHomeDir(ctx, newHome)
|
||||
|
||||
// Install stubs for the python calls we need to ensure were run in the
|
||||
// upgrade process.
|
||||
ctx, stub := process.WithStub(ctx)
|
||||
stub.WithStderrFor(`python[\S]+ -m pip install .`, "[mock pip install]")
|
||||
stub.WithStdoutFor(`python[\S]+ install.py`, "setting up important infrastructure")
|
||||
|
||||
py, _ := python.DetectExecutable(ctx)
|
||||
py, _ = filepath.Abs(py)
|
||||
ctx = env.Set(ctx, "PYTHON_BIN", py)
|
||||
|
@ -420,4 +426,17 @@ func TestUpgraderWorksForReleases(t *testing.T) {
|
|||
|
||||
r := internal.NewCobraTestRunnerWithContext(t, ctx, "labs", "upgrade", "blueprint")
|
||||
r.RunAndExpectOutput("setting up important infrastructure")
|
||||
|
||||
// Check if the stub was called with the 'python -m pip install' command
|
||||
pi := false
|
||||
for _, call := range stub.Commands() {
|
||||
if strings.HasSuffix(call, "-m pip install .") {
|
||||
pi = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !pi {
|
||||
t.Logf(`Expected stub command 'python[\S]+ -m pip install .' not found`)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue