Skip to content

Commit 578ab8e

Browse files
authored
Fix Google Dataflow hook failing import when apache-beam not installed (#65659)
1 parent deb9948 commit 578ab8e

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

  • providers/google/src/airflow/providers/google/cloud/hooks

providers/google/src/airflow/providers/google/cloud/hooks/dataflow.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,20 @@
5050
from googleapiclient.discovery import Resource, build
5151

5252
from airflow.exceptions import AirflowProviderDeprecationWarning
53-
from airflow.providers.apache.beam.hooks.beam import BeamHook, BeamRunnerType, beam_options_to_args
54-
from airflow.providers.common.compat.sdk import AirflowException, timeout
53+
from airflow.providers.common.compat.sdk import (
54+
AirflowException,
55+
AirflowOptionalProviderFeatureException,
56+
timeout,
57+
)
58+
59+
try:
60+
from airflow.providers.apache.beam.hooks.beam import BeamHook, BeamRunnerType, beam_options_to_args
61+
except ImportError as e:
62+
raise AirflowOptionalProviderFeatureException(
63+
"Failed to import apache-airflow-providers-apache-beam. "
64+
"To use the Dataflow service with Apache Beam pipelines, please install the apache-beam provider: "
65+
"pip install apache-airflow-providers-apache-beam"
66+
) from e
5567
from airflow.providers.google.common.hooks.base_google import (
5668
PROVIDE_PROJECT_ID,
5769
GoogleBaseAsyncHook,

0 commit comments

Comments
 (0)