[ https://issues.apache.org/jira/browse/BEAM-9574?focusedWorklogId=410627&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-410627 ]
ASF GitHub Bot logged work on BEAM-9574: ---------------------------------------- Author: ASF GitHub Bot Created on: 26/Mar/20 21:10 Start Date: 26/Mar/20 21:10 Worklog Time Spent: 10m Work Description: TheNeuralBit commented on pull request #11196: [BEAM-9574] Ensure that instances of generated NamedTuple classes can be pickled URL: https://github.com/apache/beam/pull/11196#discussion_r398895069 ########## File path: sdks/python/apache_beam/typehints/schemas.py ########## @@ -205,6 +218,11 @@ def typing_from_runner_api(fieldtype_proto): pass # TODO +def _hydrate_namedtuple_instance(encoded_schema, values): + return named_tuple_from_schema( + proto_utils.parse_Bytes(encoded_schema, schema_pb2.Schema))(*values) + + def named_tuple_from_schema(schema): Review comment: It's effectively memoized with SCHEMA_REGISTRY inside `typing_from_runner_api`. We could short-circuit it here as well though ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 410627) Time Spent: 0.5h (was: 20m) > NamedTuple instances generated from schemas cannot be pickled > ------------------------------------------------------------- > > Key: BEAM-9574 > URL: https://issues.apache.org/jira/browse/BEAM-9574 > Project: Beam > Issue Type: Bug > Components: sdk-py-core > Reporter: Brian Hulette > Assignee: Brian Hulette > Priority: Major > Time Spent: 0.5h > Remaining Estimate: 0h > > Attempting to pickle an instance of a generated NamedTuple class results in > the following: > {code} > _pickle.PicklingError: Can't pickle <class > 'apache_beam.typehints.schemas.BeamSchema_a7de91e0_ae11_4c52_a041_0b58ada35ac1'>: > attribute lookup BeamSchema_a7de91e0_ae11_4c52_a041_0b58ada35ac1 on > apache_beam.typehints.schemas failed > {code} > In general, we shouldn't be pickling these instances, but occasionally it may > be necessary, and we should just do it rather than failing hard. -- This message was sent by Atlassian Jira (v8.3.4#803005)