[ 
https://issues.apache.org/jira/browse/BEAM-14250?focusedWorklogId=765244&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-765244
 ]

ASF GitHub Bot logged work on BEAM-14250:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/May/22 00:39
            Start Date: 03/May/22 00:39
    Worklog Time Spent: 10m 
      Work Description: KevinGG commented on code in PR #17531:
URL: https://github.com/apache/beam/pull/17531#discussion_r863283873


##########
sdks/python/apache_beam/coders/typecoders.py:
##########
@@ -119,15 +119,21 @@ def register_coder(self, typehint_type, 
typehint_coder_class):
     if typehint_type.__module__ == '__main__':
       # See https://issues.apache.org/jira/browse/BEAM-14250
       # TODO(robertwb): Remove once all runners are portable.
-      typehint_type = str(typehint_type)
+      if hasattr(typehint_type, '__name__'):
+        typehint_type = typehint_type.__name__
+      else:
+        typehint_type = str(typehint_type)
     self._register_coder_internal(typehint_type, typehint_coder_class)
 
   def get_coder(self, typehint):
     # type: (Any) -> coders.Coder
     if typehint and typehint.__module__ == '__main__':
       # See https://issues.apache.org/jira/browse/BEAM-14250
       # TODO(robertwb): Remove once all runners are portable.
-      typehint = str(typehint)
+      if hasattr(typehint, '__name__'):

Review Comment:
   Thanks, will apply it!





Issue Time Tracking
-------------------

    Worklog Id:     (was: 765244)
    Time Spent: 1h 50m  (was: 1h 40m)

> Coder registration doesn't work for types in main module.
> ---------------------------------------------------------
>
>                 Key: BEAM-14250
>                 URL: https://issues.apache.org/jira/browse/BEAM-14250
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-core
>            Reporter: Robert Bradshaw
>            Assignee: Robert Bradshaw
>            Priority: P2
>          Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> This is because type equality is not preserved through pickling. (Similarly 
> for any other dynamic types that can't be pickled by reference.)



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to