[
https://issues.apache.org/jira/browse/BEAM-10861?focusedWorklogId=489667&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-489667
]
ASF GitHub Bot logged work on BEAM-10861:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 23/Sep/20 16:28
Start Date: 23/Sep/20 16:28
Worklog Time Spent: 10m
Work Description: chamikaramj commented on a change in pull request
#12888:
URL: https://github.com/apache/beam/pull/12888#discussion_r493728664
##########
File path: sdks/python/apache_beam/io/iobase.py
##########
@@ -992,6 +1012,43 @@ def expand(self, pcoll):
'A sink must inherit iobase.Sink, iobase.NativeSink, '
'or be a PTransform. Received : %r' % self.sink)
+ def _pubsub_write_payload(self):
+ return beam_runner_api_pb2.PubSubWritePayload(
+ topic=self.sink.full_topic,
+ id_attribute=self.sink.id_label,
+ timestamp_attribute=self.sink.timestamp_attribute)
+
+ def to_runner_api_parameter(self, context):
+ # type: (PipelineContext) -> Tuple[str, Any]
+ # Importing locally to prevent circular dependencies.
+ from apache_beam.io.gcp.pubsub import _PubSubSink
+ if isinstance(self.sink, _PubSubSink):
+ payload = self._pubsub_write_payload()
+ return (common_urns.composites.PUBSUB_WRITE.urn, payload)
+ else:
+ return super(Write, self).to_runner_api_parameter(context)
+
+ @staticmethod
+ @ptransform.PTransform.register_urn(
+ common_urns.composites.PUBSUB_WRITE.urn,
+ beam_runner_api_pb2.PubSubWritePayload)
+ def from_runner_api_parameter(ptransform, payload, unused_context):
+ # type: (Any, Any, PipelineContext) -> Write
+ if ptransform.spec.urn != common_urns.composites.PUBSUB_WRITE.urn:
+ raise ValueError(
+ 'Write transform cannot be constructed for the given proto %r',
+ ptransform)
+
+ # Importing locally to prevent circular dependencies.
+ from apache_beam.io.gcp.pubsub import _PubSubSink
+ sink = _PubSubSink(
+ topic=payload.topic,
+ id_label=payload.id_attribute,
+ with_attributes=True,
Review comment:
I added 'with_attributes' property back. That should fix the failure
here. We can later deprecate/remove it from the proto if we truly remove all
it's usage including DirectRunner.
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 489667)
Time Spent: 16h 20m (was: 16h 10m)
> Adds URNs and payloads to PubSub transforms
> -------------------------------------------
>
> Key: BEAM-10861
> URL: https://issues.apache.org/jira/browse/BEAM-10861
> Project: Beam
> Issue Type: Bug
> Components: cross-language, runner-dataflow, sdk-py-core
> Reporter: Chamikara Madhusanka Jayalath
> Assignee: Chamikara Madhusanka Jayalath
> Priority: P1
> Fix For: 2.25.0
>
> Time Spent: 16h 20m
> Remaining Estimate: 0h
>
> This is needed to allow runners to override portable definition of transforms.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)