Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion generated/known_airflow_exceptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ providers/amazon/src/airflow/providers/amazon/aws/sensors/sagemaker.py::8
providers/amazon/src/airflow/providers/amazon/aws/sensors/sagemaker_unified_studio.py::1
providers/amazon/src/airflow/providers/amazon/aws/sensors/sqs.py::2
providers/amazon/src/airflow/providers/amazon/aws/sensors/step_function.py::1
providers/amazon/src/airflow/providers/amazon/aws/transfers/gcs_to_s3.py::1
providers/amazon/src/airflow/providers/amazon/aws/transfers/redshift_to_s3.py::1
providers/amazon/src/airflow/providers/amazon/aws/transfers/s3_to_dynamodb.py::3
providers/amazon/src/airflow/providers/amazon/aws/transfers/s3_to_redshift.py::3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from packaging.version import Version

from airflow.providers.amazon.aws.hooks.s3 import S3Hook
from airflow.providers.common.compat.sdk import AirflowException, BaseOperator
from airflow.providers.common.compat.sdk import BaseOperator
from airflow.providers.google.cloud.hooks.gcs import GCSHook

if TYPE_CHECKING:
Expand Down Expand Up @@ -146,10 +146,8 @@ def __init__(
self.__is_match_glob_supported = False
except ImportError: # __version__ was added in 10.1.0, so this means it's < 10.3.0
self.__is_match_glob_supported = False
if not self.__is_match_glob_supported and match_glob:
raise AirflowException(
"The 'match_glob' parameter requires 'apache-airflow-providers-google>=10.3.0'."
)
if not self.__is_match_glob_supported and match_glob is not None:
raise ValueError("The 'match_glob' parameter requires 'apache-airflow-providers-google>=10.3.0'.")
self.match_glob = match_glob
self.gcp_user_project = gcp_user_project

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,39 @@ def test_execute__match_glob(self, mock_hook):
user_project=None,
)

@pytest.mark.parametrize(
"match_glob",
[
pytest.param("**/*.csv", id="value_supplied"),
pytest.param("", id="empty_string_is_still_supplied"),
],
)
@mock.patch("airflow.providers.google.__version__", "10.2.0")
def test_init__match_glob_rejected_on_older_google_provider(self, match_glob):
"""Supplying match_glob requires apache-airflow-providers-google>=10.3.0.

The check asks whether the argument was supplied, not whether its value is truthy,
so an empty string is rejected too - it was supplied.
"""
with pytest.raises(ValueError, match=r"requires 'apache-airflow-providers-google>=10\.3\.0'"):
GCSToS3Operator(
task_id=TASK_ID,
gcs_bucket=GCS_BUCKET,
dest_s3_key=S3_BUCKET,
match_glob=match_glob,
)

@mock.patch("airflow.providers.google.__version__", "10.2.0")
def test_init__match_glob_omitted_is_accepted_on_older_google_provider(self):
"""Omitting match_glob leaves nothing to reject, whatever the google provider version."""
operator = GCSToS3Operator(
task_id=TASK_ID,
gcs_bucket=GCS_BUCKET,
dest_s3_key=S3_BUCKET,
)

assert operator.match_glob is None

@mock.patch("airflow.providers.amazon.aws.transfers.gcs_to_s3.GCSHook")
def test_execute_incremental(self, mock_hook):
mock_hook.return_value.list.return_value = MOCK_FILES
Expand Down
1 change: 0 additions & 1 deletion scripts/ci/prek/validate_operators_init_exemptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Burn-down tracked at https://github.com/apache/airflow/issues/70296
providers/amazon/src/airflow/providers/amazon/aws/operators/neptune.py::NeptuneStartDbClusterOperator
providers/amazon/src/airflow/providers/amazon/aws/operators/neptune.py::NeptuneStopDbClusterOperator
providers/amazon/src/airflow/providers/amazon/aws/transfers/gcs_to_s3.py::GCSToS3Operator
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py::KubernetesPodOperator
providers/google/src/airflow/providers/google/cloud/operators/cloud_batch.py::CloudBatchSubmitJobOperator
providers/google/src/airflow/providers/google/cloud/operators/cloud_build.py::CloudBuildCreateBuildOperator
Expand Down