Skip to content

[Python] Honor ProfilingOptions in BundleBasedDirectRunner - #41749

Open
Anurag-S1ngh wants to merge 1 commit into
apache:masterfrom
Anurag-S1ngh:feat/18011-direct-runner-profiling
Open

Anurag-S1ngh wants to merge 1 commit into
apache:masterfrom
Anurag-S1ngh:feat/18011-direct-runner-profiling

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Summary

Adds support for ProfilingOptions to BundleBasedDirectRunner, the one DirectRunner execution path that did not honor them. Portable runners and FnApiRunner already read these options, so this closes the remaining gap for the default DirectRunner when it falls back to the bundle-based implementation.

Changes

  • Build the profiler factory from ProfilingOptions in BundleBasedDirectRunner.run_pipeline and pass it to the executor.
  • Run the executor worker thread under the profiler. cProfile only profiles the calling thread, and bundle execution happens on the executor worker, so wrapping run_pipeline itself would not capture any pipeline work.
  • Add tests that verify a CPU profile is written and contains profiling data when profiling is enabled, and that nothing is written when it is disabled.
  • Update CHANGES.md.

Testing

  • python -m pytest apache_beam/runners/direct/direct_runner_test.py (9 passed)
  • yapf and ruff clean on the changed files

Fixes #18011

Build the profiler factory from ProfilingOptions in BundleBasedDirectRunner and pass it to the executor. The profiler wraps the executor worker thread, since cProfile only profiles the calling thread and the bundle work runs there.
@github-actions github-actions Bot added python runners size/s S: 10-49 lines changed labels Nov 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python runners size/s S: 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

All runners should support ProfilingOptions

1 participant