robertwb commented on a change in pull request #11314: [BEAM-9562] Send Timers
over Data Channel as Elements
URL: https://github.com/apache/beam/pull/11314#discussion_r405985691
##########
File path: sdks/python/apache_beam/transforms/core.py
##########
@@ -1323,12 +1325,47 @@ def _pardo_fn_data(self):
windowing = None
return self.fn, self.args, self.kwargs, si_tags_and_types, windowing
- def to_runner_api_parameter(self, context):
+ def _get_key_and_window_coder(self, named_inputs):
+ if named_inputs is None or not self._signature.is_stateful_dofn():
+ return None, None
+ main_input = list(set(named_inputs.keys()) - set(self.side_inputs))[0]
+ input_pcoll = named_inputs[main_input]
+ kv_type_hint = input_pcoll.element_type
+ if kv_type_hint and kv_type_hint != typehints.Any:
+ coder = coders.registry.get_coder(kv_type_hint)
+ if not coder.is_kv_coder():
+ raise ValueError(
+ 'Input elements to the transform %s with stateful DoFn must be '
+ 'key-value pairs.' % self)
+ key_coder = coder.key_coder()
+ else:
+ key_coder = coders.registry.get_coder(typehints.Any)
+ window_coder = input_pcoll.windowing.windowfn.get_window_coder()
+ return key_coder, window_coder
+
+ def to_runner_api(self, context, **extra_kwargs):
+ # type: (PipelineContext, bool) -> beam_runner_api_pb2.FunctionSpec
+ has_parts = extra_kwargs.get('has_part', False)
Review comment:
You can leave this in the parameter list.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services