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

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

                Author: ASF GitHub Bot
            Created on: 27/Mar/20 23:07
            Start Date: 27/Mar/20 23:07
    Worklog Time Spent: 10m 
      Work Description: robertwb commented on pull request #11185: [BEAM-8019] 
Updates Python SDK to handle remote SDK coders and preserve tags added by 
remote SDKs
URL: https://github.com/apache/beam/pull/11185#discussion_r399563372
 
 

 ##########
 File path: sdks/python/apache_beam/coders/coders.py
 ##########
 @@ -1383,22 +1375,74 @@ def from_runner_api_parameter(payload, components, 
context):
         write_state_threshold=int(payload))
 
 
-class RunnerAPICoderHolder(Coder):
+class ElementTypeHolder(typehints.TypeConstraint):
+  """A dummy element type for external coders that cannot be parsed in 
Python"""
+  def __init__(self, coder, context):
+    self.coder = coder
+    self.context = context
+
+
+class ExternalCoder(Coder):
   """A `Coder` that holds a runner API `Coder` proto.
 
   This is used for coders for which corresponding objects cannot be
   initialized in Python SDK. For example, coders for remote SDKs that may
   be available in Python SDK transform graph when expanding a cross-language
   transform.
   """
-  def __init__(self, proto):
-    self._proto = proto
 
-  def proto(self):
-    return self._proto
+  coder_count = 0
 
-  def to_runner_api(self, context):
-    return self._proto
+  def __init__(self, element_type_holder):
+    self.element_type_holder = element_type_holder
 
-  def to_type_hint(self):
-    return Any
+  def as_cloud_object(self, coders_context=None):
+    if not coders_context:
+      raise Exception(
+          'coders_context must be specified to correctly encode external 
coders'
+      )
+    coder_id = coders_context.get_by_proto(
+        self.element_type_holder.coder, deduplicate=True)
+
+    coder_proto = self.element_type_holder.coder
+
+    kind_str = 'kind:external' + str(ExternalCoder.coder_count)
+    ExternalCoder.coder_count = ExternalCoder.coder_count + 1
+    component_encodings = []
+    if coder_proto.spec.urn == 'beam:coder:kv:v1':
 
 Review comment:
   I anticipate `kind:stream` will be needed to handle GBK of unknown types. 
Others may be needed for other cases, or in the future, and it seems risky to 
enumerate them here and in the dataflow runner. There may also be cases where 
we have to go more than one level deep. We should try to return the same thing 
the external SDK would have returned just to be safe, and that means wrapping 
only the leaves as external coders. I think that'll clean stuff up as well 
(e.g. no need for `_coerce_to_kv_type_from_external_type`). 
 
----------------------------------------------------------------
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: 411460)
    Time Spent: 11h 20m  (was: 11h 10m)

> Support cross-language transforms for DataflowRunner
> ----------------------------------------------------
>
>                 Key: BEAM-8019
>                 URL: https://issues.apache.org/jira/browse/BEAM-8019
>             Project: Beam
>          Issue Type: New Feature
>          Components: sdk-py-core
>            Reporter: Chamikara Madhusanka Jayalath
>            Assignee: Chamikara Madhusanka Jayalath
>            Priority: Major
>          Time Spent: 11h 20m
>  Remaining Estimate: 0h
>
> This is to capture the Beam changes needed for this task.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to