Skip to content

Commit

Permalink
Fix deprecation warnings location in google provider (#16403)
Browse files Browse the repository at this point in the history
These warnings were being issued from the wrong location, making them
hard for any users who hit them to fix

```
tests/serialization/test_dag_serialization.py::TestStringifiedDAGs::test_serialization
  /opt/airflow/airflow/models/dagbag.py:317: DeprecationWarning: This operator is deprecated. Please use BigQueryUpdateDatasetOperator.
    loader.exec_module(new_module)

tests/serialization/test_dag_serialization.py::TestStringifiedDAGs::test_roundtrip_provider_example_dags
tests/serialization/test_dag_serialization.py::TestStringifiedDAGs::test_serialization
  /opt/airflow/airflow/models/baseoperator.py:181: DeprecationWarning: `destination_bucket` is deprecated please use `bucket_name`
    result = func(self, *args, **kwargs)

tests/serialization/test_dag_serialization.py::TestStringifiedDAGs::test_roundtrip_provider_example_dags
tests/serialization/test_dag_serialization.py::TestStringifiedDAGs::test_serialization
  /opt/airflow/airflow/models/baseoperator.py:181: DeprecationWarning: `destination_object` is deprecated please use `object_name`
    result = func(self, *args, **kwargs)
```
  • Loading branch information
ashb authored Jun 14, 2021
1 parent b272f9c commit 3c5cc42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion airflow/providers/google/cloud/operators/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,14 @@ def __init__(
"The bigquery_conn_id parameter has been deprecated. You should pass "
"the gcp_conn_id parameter.",
DeprecationWarning,
stacklevel=2,
)
gcp_conn_id = bigquery_conn_id

warnings.warn(
"This operator is deprecated. Please use `BigQueryInsertJobOperator`.",
DeprecationWarning,
stacklevel=2,
)

self.sql = sql
Expand Down Expand Up @@ -1638,7 +1640,7 @@ def __init__(
warnings.warn(
"This operator is deprecated. Please use BigQueryUpdateDatasetOperator.",
DeprecationWarning,
stacklevel=3,
stacklevel=2,
)
self.dataset_id = dataset_id
self.project_id = project_id
Expand Down
12 changes: 10 additions & 2 deletions airflow/providers/google/cloud/transfers/gdrive_to_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,18 @@ def __init__(
super().__init__(**kwargs)
self.bucket_name = destination_bucket or bucket_name
if destination_bucket:
warnings.warn("`destination_bucket` is deprecated please use `bucket_name`", DeprecationWarning)
warnings.warn(
"`destination_bucket` is deprecated please use `bucket_name`",
DeprecationWarning,
stacklevel=2,
)
self.object_name = destination_object or object_name
if destination_object:
warnings.warn("`destination_object` is deprecated please use `object_name`", DeprecationWarning)
warnings.warn(
"`destination_object` is deprecated please use `object_name`",
DeprecationWarning,
stacklevel=2,
)
self.folder_id = folder_id
self.drive_id = drive_id
self.file_name = file_name
Expand Down

0 comments on commit 3c5cc42

Please sign in to comment.