[
https://issues.apache.org/jira/browse/BEAM-14250?focusedWorklogId=765238&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-765238
]
ASF GitHub Bot logged work on BEAM-14250:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 03/May/22 00:32
Start Date: 03/May/22 00:32
Worklog Time Spent: 10m
Work Description: robertwb commented on code in PR #17531:
URL: https://github.com/apache/beam/pull/17531#discussion_r863277996
##########
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:
`getattr(typehint, '__name__', str(typehint))`
Similarly above.
Issue Time Tracking
-------------------
Worklog Id: (was: 765238)
Time Spent: 1.5h (was: 1h 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: 1.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.7#820007)