Skip to content

Commit

Permalink
Add callout of PIP failures as unrecoverable, link to new documentati…
Browse files Browse the repository at this point in the history
…on (#28743)
  • Loading branch information
jrmccluskey authored Sep 29, 2023
1 parent 5d6dcee commit 5e38dec
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sdks/python/container/piputil.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
"github.com/apache/beam/sdks/v2/go/pkg/beam/util/execx"
)

const unrecoverableURL string = "https://beam.apache.org/documentation/sdks/python-unrecoverable-errors/index.html#pip-dependency-resolution-failures"

// pipInstallRequirements installs the given requirement, if present.
func pipInstallRequirements(ctx context.Context, logger *tools.Logger, files []string, dir, name string) error {
pythonVersion, err := expansionx.GetPythonVersion()
Expand All @@ -56,7 +58,7 @@ func pipInstallRequirements(ctx context.Context, logger *tools.Logger, files []s
err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...)
if err != nil {
bufLogger.FlushAtError(ctx)
return err
return fmt.Errorf("PIP failed to install dependencies, got %s. This error may be unrecoverable, see %s for more information", err, unrecoverableURL)
}
bufLogger.FlushAtDebug(ctx)
return nil
Expand Down Expand Up @@ -114,15 +116,15 @@ func pipInstallPackage(ctx context.Context, logger *tools.Logger, files []string
err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...)
if err != nil {
bufLogger.FlushAtError(ctx)
return err
return fmt.Errorf("PIP failed to install dependencies, got %s. This error may be unrecoverable, see %s for more information", err, unrecoverableURL)
} else {
bufLogger.FlushAtDebug(ctx)
}
args = []string{"-m", "pip", "install", "--no-cache-dir", "--disable-pip-version-check", filepath.Join(dir, packageSpec)}
err = execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...)
if err != nil {
bufLogger.FlushAtError(ctx)
return err
return fmt.Errorf("PIP failed to install dependencies, got %s. This error may be unrecoverable, see %s for more information", err, unrecoverableURL)
}
bufLogger.FlushAtDebug(ctx)
return nil
Expand All @@ -133,7 +135,7 @@ func pipInstallPackage(ctx context.Context, logger *tools.Logger, files []string
err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...)
if err != nil {
bufLogger.FlushAtError(ctx)
return err
return fmt.Errorf("PIP failed to install dependencies, got %s. This error may be unrecoverable, see %s for more information", err, unrecoverableURL)
}
bufLogger.FlushAtDebug(ctx)
return nil
Expand Down

0 comments on commit 5e38dec

Please sign in to comment.