[
https://issues.apache.org/jira/browse/BEAM-9146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17026526#comment-17026526
]
Elias Djurfeldt edited comment on BEAM-9146 at 1/30/20 10:14 AM:
-----------------------------------------------------------------
>From what I gather, this AnnotateVideo PTransform is not an input nor a sink.
>And should therefore implicitly take items in a PCollection as part of a
>pipeline. But I might be wrong here considering the spec says _io_.
Anyway,
When writing the test I initially figured that I could mock the
VideoIntelligenceClient and then assert that client.annotate_video was called.
However, since MagicMock isn't picklable, I cannot test this in a pipeline it
seems.
Example code for reference:
{code:java}
with patch.object(helper, 'get_client', return_value=self._mock_client):
with TestPipeline() as p:
(p
| "Create data" >> beam.Create(videos_to_annotate)
| "Annotate video" >> AnnotateVideo()
)
self.assertTrue(self._mock_client.annotate_video.called){code}
Where videos_to_annotate is just a list of URI's for now. And helper.get_client
returns the VideoIntelligenceClient.
Am I approaching this the wrong way (maybe it should accept input explicitly
after all) or is there something else I'm missing?
was (Author: eliasdjur):
>From what I gather, this AnnotateVideo PTransform is not an input nor a sink.
>And should therefore implicitly take items in a PCollection as part of a
>pipeline. But I might be wrong here considering the spec says _io_.
Anyway,
When writing the test I initially figured that I could mock the
VideoIntelligenceClient and then assert that client.annotate_video was called.
However, since MagicMock isn't picklable, I cannot test this in a pipeline it
seems.
Example code for reference:
{code:java}
with patch.object(helper, 'get_client', return_value=self._mock_client):
with TestPipeline() as p:
(p
| "Create data" >> beam.Create(videos_to_annotate)
| "Annotate video" >> AnnotateVideo()
)
self.assertTrue(self._mock_client.annotate_video.called){code}
Where videos_to_annotate is just a list of URI's for now. And helper.get_client
returns the VideoIntelligenceClient.
Am I approaching this the wrong way or is there something I'm missing?
> [Python] PTransform that integrates Video Intelligence functionality
> --------------------------------------------------------------------
>
> Key: BEAM-9146
> URL: https://issues.apache.org/jira/browse/BEAM-9146
> Project: Beam
> Issue Type: Sub-task
> Components: io-py-gcp
> Reporter: Kamil Wasilewski
> Assignee: Kamil Wasilewski
> Priority: Major
>
> The goal is to create a PTransform that integrates Google Cloud Video
> Intelligence functionality [1].
> The transform should be able to take both video GCS location or video data
> bytes as an input.
> The transform should be put into _sdks/python/apache_beam/io/gcp/ai_ folder.
> [1] https://cloud.google.com/video-intelligence/
--
This message was sent by Atlassian Jira
(v8.3.4#803005)