This is an automated email from the ASF dual-hosted git repository. husseinawala pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push: new 1ea623a834 Fix deprecations into the GCP Dataproc links (#36834) 1ea623a834 is described below commit 1ea623a834a003df50af208d583b98452a28d430 Author: Andrey Anshin <andrey.ans...@taragol.is> AuthorDate: Wed Jan 17 20:31:37 2024 +0400 Fix deprecations into the GCP Dataproc links (#36834) --- airflow/providers/google/cloud/links/dataproc.py | 28 +++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/airflow/providers/google/cloud/links/dataproc.py b/airflow/providers/google/cloud/links/dataproc.py index 917a1a7731..a7804d050d 100644 --- a/airflow/providers/google/cloud/links/dataproc.py +++ b/airflow/providers/google/cloud/links/dataproc.py @@ -21,6 +21,8 @@ from __future__ import annotations import warnings from typing import TYPE_CHECKING, Any +import attr + from airflow.exceptions import AirflowProviderDeprecationWarning from airflow.models import BaseOperatorLink, XCom from airflow.providers.google.cloud.links.base import BASE_LINK, BaseGoogleLink @@ -42,6 +44,7 @@ def __getattr__(name: str) -> Any: " Please use DATAPROC_JOB_LINK instead" ), AirflowProviderDeprecationWarning, + stacklevel=2, ) return DATAPROC_JOB_LINK raise AttributeError(f"module {__name__} has no attribute {name}") @@ -68,18 +71,15 @@ DATAPROC_CLUSTER_LINK_DEPRECATED = ( ) +@attr.s(auto_attribs=True) class DataprocLink(BaseOperatorLink): """ Helper class for constructing Dataproc resource link. .. warning:: - This link is deprecated. + This link is pending to deprecate. """ - warnings.warn( - "This DataprocLink is deprecated.", - AirflowProviderDeprecationWarning, - ) name = "Dataproc resource" key = "conf" @@ -116,7 +116,17 @@ class DataprocLink(BaseOperatorLink): else "" ) + def __attrs_post_init__(self): + # This link is still used into the selected operators + # - airflow.providers.google.cloud.operators.dataproc.DataprocScaleClusterOperator + # - airflow.providers.google.cloud.operators.dataproc.DataprocJobBaseOperator + # - airflow.providers.google.cloud.operators.dataproc.DataprocSubmitPigJobOperator + # As soon as we remove reference to this link we might deprecate it by add warning message + # with `stacklevel=3` below in this method. + ... + +@attr.s(auto_attribs=True) class DataprocListLink(BaseOperatorLink): """ Helper class for constructing list of Dataproc resources link. @@ -125,7 +135,6 @@ class DataprocListLink(BaseOperatorLink): This link is deprecated. """ - warnings.warn("This DataprocListLink is deprecated.", AirflowProviderDeprecationWarning) name = "Dataproc resources" key = "list_conf" @@ -159,6 +168,13 @@ class DataprocListLink(BaseOperatorLink): else "" ) + def __attrs_post_init__(self): + warnings.warn( + "This DataprocListLink is deprecated.", + AirflowProviderDeprecationWarning, + stacklevel=3, + ) + class DataprocClusterLink(BaseGoogleLink): """Helper class for constructing Dataproc Cluster Link."""