Skip to content
Open
Changes from 2 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
20 changes: 14 additions & 6 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 @@ -408,6 +412,10 @@ func installSetupPackages(ctx context.Context, logger *tools.Logger, files []str
bufLogger := tools.NewBufferedLogger(logger)
bufLogger.Printf(ctx, "Installing setup packages ...")

if err := logRuntimeDependencies(ctx, bufLogger, "pre-installation"); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the use-case for this?

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.

While we already log dependencies after installation, boot.go exits immediately if any installation step fails.

Adding a pre-installation call ensures we capture the environment state regardless of whether the installation succeeds. This is useful for reproducing and triaging environment-specific failures from customers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

'pre-installation', 'post-installation' sounds a bit cryptic for end user who is not a beam dev, and the output may be a a bit verbose.

How about we think of a way to enable debug logging for boot.go and only print pre-installation env if debug logging is enabled? then, we can ask affected customers to run their pipeline with debug logging enabled if necessary.

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 new logs only add 4 lines and are already emitted at the DEBUG level, which allows users to filter them out as needed.

Given this minimal footprint, I’d prefer to avoid adding complexity of a new configuration mechanism or flag in boot.go to keep the boot logic as simple as possible.

image

'pre-installation', 'post-installation' sounds a bit cryptic for end user who is not a beam dev.

I used the term "installation" because of the line of "Installing setup packages ..." prior to these logs (see above screenshot too), but I am open to any better term.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sg, thanks!

Copy link
Copy Markdown
Contributor

@tvalentyn tvalentyn Apr 30, 2026

Choose a reason for hiding this comment

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

i do think that the pre-installation output is confusing unless you know why you need to look at it; most of the time, you need to look at the final list after all the installations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps we could change logs to the below:

Installing setup packages -> Installing additional runtime dependencies if any are specified in --requirements_file, --setup_file or --extra_package options.

post-installation-> post-installation (final runtime environment)

Copy link
Copy Markdown
Collaborator Author

@shunping shunping May 2, 2026

Choose a reason for hiding this comment

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

Great. I made the change to use "initial runtime environmemnt" and "final runtime environment". I also included some small edits to existing messages to make them consistent and concise. PTAL

bufLogger.Printf(ctx, "couldn't 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
// using the --sdk_location pipeline option.
Expand All @@ -432,7 +440,7 @@ 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 {
if err := logRuntimeDependencies(ctx, bufLogger, "post-installation"); err != nil {
bufLogger.Printf(ctx, "couldn't fetch the runtime python dependencies: %v", err)
}
if err := logSubmissionEnvDependencies(ctx, bufLogger, workDir); err != 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, "Using Python version (%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, "Logging runtime dependencies (%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 Down
Loading