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

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

                Author: ASF GitHub Bot
            Created on: 05/Apr/22 15:11
            Start Date: 05/Apr/22 15:11
    Worklog Time Spent: 10m 
      Work Description: yeandy commented on code in PR #17278:
URL: https://github.com/apache/beam/pull/17278#discussion_r842898174


##########
sdks/python/apache_beam/coders/typecoders.py:
##########
@@ -116,10 +116,18 @@ def register_coder(self, typehint_type, 
typehint_coder_class):
           'Received %r instead.' % typehint_coder_class)
     if typehint_type not in self.custom_types:
       self.custom_types.append(typehint_type)
+    if typehint_type.__module__ == '__main__':

Review Comment:
   Seems to be failures if `typehint_type` is None
   ```suggestion
       if typehint and typehint_type.__module__ == '__main__':
   ```



##########
sdks/python/apache_beam/coders/typecoders.py:
##########
@@ -116,10 +116,18 @@ def register_coder(self, typehint_type, 
typehint_coder_class):
           'Received %r instead.' % typehint_coder_class)
     if typehint_type not in self.custom_types:
       self.custom_types.append(typehint_type)
+    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)
     self._register_coder_internal(typehint_type, typehint_coder_class)
 
   def get_coder(self, typehint):
     # type: (Any) -> coders.Coder
+    if typehint.__module__ == '__main__':

Review Comment:
   ```suggestion
       if typehint and typehint.__module__ == '__main__':
   ```





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

    Worklog Id:     (was: 752942)
    Time Spent: 0.5h  (was: 20m)

> 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: 0.5h
>  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.1#820001)

Reply via email to