Skip to content

Commit 5e38dec

Browse files
authored
Add callout of PIP failures as unrecoverable, link to new documentation (#28743)
1 parent 5d6dcee commit 5e38dec

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sdks/python/container/piputil.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import (
3232
"github.com/apache/beam/sdks/v2/go/pkg/beam/util/execx"
3333
)
3434

35+
const unrecoverableURL string = "https://beam.apache.org/documentation/sdks/python-unrecoverable-errors/index.html#pip-dependency-resolution-failures"
36+
3537
// pipInstallRequirements installs the given requirement, if present.
3638
func pipInstallRequirements(ctx context.Context, logger *tools.Logger, files []string, dir, name string) error {
3739
pythonVersion, err := expansionx.GetPythonVersion()
@@ -56,7 +58,7 @@ func pipInstallRequirements(ctx context.Context, logger *tools.Logger, files []s
5658
err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...)
5759
if err != nil {
5860
bufLogger.FlushAtError(ctx)
59-
return err
61+
return fmt.Errorf("PIP failed to install dependencies, got %s. This error may be unrecoverable, see %s for more information", err, unrecoverableURL)
6062
}
6163
bufLogger.FlushAtDebug(ctx)
6264
return nil
@@ -114,15 +116,15 @@ func pipInstallPackage(ctx context.Context, logger *tools.Logger, files []string
114116
err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...)
115117
if err != nil {
116118
bufLogger.FlushAtError(ctx)
117-
return err
119+
return fmt.Errorf("PIP failed to install dependencies, got %s. This error may be unrecoverable, see %s for more information", err, unrecoverableURL)
118120
} else {
119121
bufLogger.FlushAtDebug(ctx)
120122
}
121123
args = []string{"-m", "pip", "install", "--no-cache-dir", "--disable-pip-version-check", filepath.Join(dir, packageSpec)}
122124
err = execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...)
123125
if err != nil {
124126
bufLogger.FlushAtError(ctx)
125-
return err
127+
return fmt.Errorf("PIP failed to install dependencies, got %s. This error may be unrecoverable, see %s for more information", err, unrecoverableURL)
126128
}
127129
bufLogger.FlushAtDebug(ctx)
128130
return nil
@@ -133,7 +135,7 @@ func pipInstallPackage(ctx context.Context, logger *tools.Logger, files []string
133135
err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...)
134136
if err != nil {
135137
bufLogger.FlushAtError(ctx)
136-
return err
138+
return fmt.Errorf("PIP failed to install dependencies, got %s. This error may be unrecoverable, see %s for more information", err, unrecoverableURL)
137139
}
138140
bufLogger.FlushAtDebug(ctx)
139141
return nil

0 commit comments

Comments
 (0)