Skip to content
Merged
Changes from all 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
25 changes: 0 additions & 25 deletions sdks/python/apache_beam/internal/code_object_pickler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,7 @@
# limitations under the License.
#

import os
import sys


def get_relative_path(path):
"""Returns the path of filename relative to the first directory in sys.path
contained in filename. Returns the unchanged filename if it is not in any
sys.path directory.

Args:
path: The path to the file.
"""
for dir_path in sys.path:
# The path for /aaa/bbb/c.py is relative to /aaa/bbb and not /aaa/bb.
if not dir_path.endswith(os.path.sep):
dir_path += os.path.sep
if path.startswith(dir_path):
return os.path.relpath(path, dir_path)
return path


def get_normalized_path(path):
"""Returns a normalized path. This function is intended to be overridden."""
# Use relative paths to make pickling lambdas deterministic for google3
# This is needed only for code running inside Google on borg.
if '/borglet/' in path:
return get_relative_path(path)

return path
Loading