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

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

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


##########
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)

Review Comment:
   Actually `str()` might be non-deterministic for a Union type such as 
`Optional[Union[str, int]]`. So this could potentially break when it's 
stringified differently when register_coder and get_coder. An example flaky 
test we encountered in the past: https://github.com/apache/beam/pull/17351.





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

    Worklog Id:     (was: 765243)
    Time Spent: 1h 40m  (was: 1.5h)

> 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 40m
>  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