Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The motivation for this change is to support caching in Apache Beam. #32972

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

kushmiD
Copy link
Contributor

@kushmiD kushmiD commented Oct 29, 2024

Apache Beam does the following:

  • Pickle Python code
  • Send the pickled source code to "worker" VMs
  • The workers unpickle and execute the code

In the environment that these Beam pipelines execute, the source code is in a temporary directory whose name is random and changes. The source code paths relative to the temporary directory are constant. Using absolute paths prevents pickled code from being cached because the absolute path keeps changing. Using relative paths enables this caching and promises significant resource savings and speed-ups.

Additionally the absolute paths leak information about the directory structure of the machine pickling the source code. When the pickled code is passed across the network to another machine, the absolute paths may no longer be valid when the other machine has a different directory structure.

The reason for using relative paths rather than omitting the path entirely is because Python uses the co_filename attribute to create stack traces.

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

Apache Beam does the following:
- Pickle Python code
- Send the pickled source code to "worker" VMs
- The workers unpickle and execute the code

In the environment that these Beam pipelines execute, the source code is
in a temporary directory whose name is random and changes. The source
code paths relative to the temporary directory are constant. Using
absolute paths prevents pickled code from being cached because the
absolute path keeps changing. Using relative paths enables this caching
and promises significant resource savings and speed-ups.

Additionally the absolute paths leak information about the directory
structure of the machine pickling the source code. When the pickled code
is passed across the network to another machine, the absolute paths may
no longer be valid when the other machine has a different directory
structure.

The reason for using relative paths rather than omitting the path
entirely is because Python uses the co_filename attribute to create
stack traces.
@kushmiD
Copy link
Contributor Author

kushmiD commented Oct 29, 2024

R:robertwb@

@kushmiD
Copy link
Contributor Author

kushmiD commented Oct 29, 2024

R: robertwb@

Copy link
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

Apache Beam does the following:
- Pickle Python code
- Send the pickled source code to "worker" VMs
- The workers unpickle and execute the code

In the environment that these Beam pipelines execute, the source code is
in a temporary directory whose name is random and changes. The source
code paths relative to the temporary directory are constant. Using
absolute paths prevents pickled code from being cached because the
absolute path keeps changing. Using relative paths enables this caching
and promises significant resource savings and speed-ups.

Additionally the absolute paths leak information about the directory
structure of the machine pickling the source code. When the pickled code
is passed across the network to another machine, the absolute paths may
no longer be valid when the other machine has a different directory
structure.

The reason for using relative paths rather than omitting the path
entirely is because Python uses the co_filename attribute to create
stack traces.

Added unit test.
Copy link
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @shunping for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@kushmiD kushmiD marked this pull request as draft October 30, 2024 23:38
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Reminder, please take a look at this pr: @shunping

Copy link
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @liferoad for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

Copy link
Contributor

Reminder, please take a look at this pr: @liferoad

Copy link
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @tvalentyn for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

@liferoad
Copy link
Collaborator

Is this ready for review?

Copy link
Contributor

Reminder, please take a look at this pr: @tvalentyn

Copy link
Contributor

github-actions bot commented Dec 4, 2024

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @jrmccluskey for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

Copy link
Contributor

Reminder, please take a look at this pr: @jrmccluskey

Copy link
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @liferoad for label python.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

Copy link
Contributor

Reminder, please take a look at this pr: @liferoad

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

Successfully merging this pull request may close these issues.

2 participants