Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions sdks/python/container/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,14 @@ func launchSDKProcess() error {
}

experiments := getExperiments(options)
logger.Printf(ctx, "Experiments=%v", experiments)

pipNoBuildIsolation = false
if slices.Contains(experiments, "pip_no_build_isolation") {
pipNoBuildIsolation = true
logger.Printf(ctx, "Disabled build isolation when installing packages with pip")
logger.Printf(ctx, "Build isolation disabled when installing packages with pip")
} else {
logger.Printf(ctx, "Build isolation enabled when installing packages with pip")
}

// (2) Retrieve and install the staged packages.
Expand Down Expand Up @@ -406,7 +410,11 @@ func setupVenv(ctx context.Context, logger *tools.Logger, baseDir, workerId stri
// installSetupPackages installs Beam SDK and user dependencies.
func installSetupPackages(ctx context.Context, logger *tools.Logger, files []string, workDir string, requirementsFiles []string) error {
bufLogger := tools.NewBufferedLogger(logger)
bufLogger.Printf(ctx, "Installing setup packages ...")
bufLogger.Printf(ctx, "Installing Beam SDK and user dependencies ...")
Comment thread
shunping marked this conversation as resolved.
Outdated

if err := logRuntimeDependencies(ctx, bufLogger, "initial runtime environment"); err != nil {
bufLogger.Printf(ctx, "Failed to fetch the runtime python dependencies: %v", err)
}

// Install the Dataflow Python SDK if one was staged. In released
// container images, SDK is already installed, but can be overriden
Expand All @@ -432,11 +440,11 @@ func installSetupPackages(ctx context.Context, logger *tools.Logger, files []str
if err := pipInstallPackage(ctx, logger, files, workDir, workflowFile, false, true, nil); err != nil {
return fmt.Errorf("failed to install workflow: %v", err)
}
if err := logRuntimeDependencies(ctx, bufLogger); err != nil {
bufLogger.Printf(ctx, "couldn't fetch the runtime python dependencies: %v", err)
if err := logRuntimeDependencies(ctx, bufLogger, "final runtime environment"); err != nil {
bufLogger.Printf(ctx, "Failed to fetch the runtime python dependencies: %v", err)
}
if err := logSubmissionEnvDependencies(ctx, bufLogger, workDir); err != nil {
bufLogger.Printf(ctx, "couldn't fetch the submission environment dependencies: %v", err)
bufLogger.Printf(ctx, "Failed to fetch the submission environment dependencies: %v", err)
}

return nil
Expand Down Expand Up @@ -485,20 +493,20 @@ func processArtifactsInSetupOnlyMode() {

// logRuntimeDependencies logs the python dependencies
// installed in the runtime environment.
func logRuntimeDependencies(ctx context.Context, bufLogger *tools.BufferedLogger) error {
func logRuntimeDependencies(ctx context.Context, bufLogger *tools.BufferedLogger, phase string) error {
pythonVersion, err := expansionx.GetPythonVersion()
if err != nil {
return err
}
bufLogger.Printf(ctx, "Using Python version:")
bufLogger.Printf(ctx, "Python version in %s:", phase)
args := []string{"--version"}
if err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...); err != nil {
bufLogger.FlushAtError(ctx)
} else {
bufLogger.FlushAtDebug(ctx)
}
bufLogger.Printf(ctx, "Logging runtime dependencies:")
args = []string{"-m", "pip", "freeze"}
bufLogger.Printf(ctx, "Dependencies in %s:", phase)
args = []string{"-m", "pip", "freeze", "--all"}
Copy link
Copy Markdown
Collaborator Author

@shunping shunping Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argument "--all" ensures that the versions of pip, setuptools, etc are included in the result.

if err := execx.ExecuteEnvWithIO(nil, os.Stdin, bufLogger, bufLogger, pythonVersion, args...); err != nil {
bufLogger.FlushAtError(ctx)
} else {
Expand All @@ -510,7 +518,7 @@ func logRuntimeDependencies(ctx context.Context, bufLogger *tools.BufferedLogger
// logSubmissionEnvDependencies logs the python dependencies
// installed in the submission environment.
func logSubmissionEnvDependencies(ctx context.Context, bufLogger *tools.BufferedLogger, dir string) error {
bufLogger.Printf(ctx, "Logging submission environment dependencies:")
bufLogger.Printf(ctx, "Dependencies in submission environment:")
// path for submission environment dependencies should match with the
// one defined in apache_beam/runners/portability/stager.py.
filename := filepath.Join(dir, "submission_environment_dependencies.txt")
Expand Down
Loading