kristynsmith commented on code in PR #35656:
URL: https://github.com/apache/beam/pull/35656#discussion_r2254715919


##########
sdks/python/apache_beam/internal/code_object_pickler.py:
##########
@@ -15,7 +15,391 @@
 # limitations under the License.
 #
 
+import collections
+import hashlib
+import inspect
+import re
+import sys
+import types
+
 
 def get_normalized_path(path):
   """Returns a normalized path. This function is intended to be overridden."""
   return path
+
+
+def _get_code_path(callable):

Review Comment:
   i'm not really sure what i could put to indicate that. i didn't write this 
function so i'm not sure of its purpose.



##########
sdks/python/apache_beam/internal/code_object_pickler.py:
##########
@@ -15,7 +15,391 @@
 # limitations under the License.
 #
 
+import collections
+import hashlib
+import inspect
+import re
+import sys
+import types
+
 
 def get_normalized_path(path):
   """Returns a normalized path. This function is intended to be overridden."""

Review Comment:
   done.



##########
sdks/python/apache_beam/internal/code_object_pickler.py:
##########
@@ -15,7 +15,391 @@
 # limitations under the License.
 #
 
+import collections
+import hashlib
+import inspect
+import re
+import sys
+import types
+
 
 def get_normalized_path(path):
   """Returns a normalized path. This function is intended to be overridden."""
   return path
+
+
+def _get_code_path(callable):
+  """Returns the stable reference to the code object.
+
+  Args:
+    callable: The callable object to search for.
+
+  Returns:
+    The stable reference to the code object.
+  """
+  code_path = _extend_path(
+      callable.__module__,
+      _search(
+          callable,
+          sys.modules[callable.__module__],
+          callable.__qualname__.split('.'),
+      ),
+  )
+  return code_path
+
+
+def _extend_path(prefix, suffix):
+  """Extends the path to the code object.
+
+  Args:
+    prefix: The prefix of the path.
+    suffix: The rest of the path.
+
+  Returns:
+    The extended path.
+  """
+  if suffix is None:
+    return None
+  if not suffix:

Review Comment:
   no. it is either hardcoded, or the first part of the qualified name. the 
function that gets the qualified name handles if it's empty. so prefix always 
has a value. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to