def test_detect_video_labels_green_path(self, mock_hook): mocked_operation = mock.Mock() mocked_operation.result = mock.Mock(return_value=AnnotateVideoResponse( annotation_results=[])) mock_hook.return_value.annotate_video.return_value = mocked_operation CloudVideoIntelligenceDetectVideoLabelsOperator( input_uri=INPUT_URI, task_id="id", gcp_conn_id=GCP_CONN_ID, impersonation_chain=IMPERSONATION_CHAIN, ).execute(context={"task_instance": mock.Mock()}) mock_hook.assert_called_once_with( gcp_conn_id=GCP_CONN_ID, impersonation_chain=IMPERSONATION_CHAIN, ) mock_hook.return_value.annotate_video.assert_called_once_with( input_uri=INPUT_URI, features=[enums.Feature.LABEL_DETECTION], input_content=None, video_context=None, location=None, retry=None, timeout=None, )
# [START howto_operator_video_intelligence_other_args] INPUT_URI = f"gs://{GCP_BUCKET_NAME}/video.mp4" # [END howto_operator_video_intelligence_other_args] with models.DAG( "example_gcp_video_intelligence", schedule_interval=None, # Override to match your needs start_date=days_ago(1), tags=['example'], ) as dag: # [START howto_operator_video_intelligence_detect_labels] detect_video_label = CloudVideoIntelligenceDetectVideoLabelsOperator( input_uri=INPUT_URI, output_uri=None, video_context=None, timeout=5, task_id="detect_video_label", ) # [END howto_operator_video_intelligence_detect_labels] # [START howto_operator_video_intelligence_detect_labels_result] detect_video_label_result = BashOperator( bash_command="echo {{ task_instance.xcom_pull('detect_video_label')" "['annotationResults'][0]['shotLabelAnnotations'][0]['entity']}}", task_id="detect_video_label_result", ) # [END howto_operator_video_intelligence_detect_labels_result] # [START howto_operator_video_intelligence_detect_explicit_content] detect_video_explicit_content = CloudVideoIntelligenceDetectVideoExplicitContentOperator(