21
21
import warnings
22
22
from typing import TYPE_CHECKING , Any
23
23
24
+ import attr
25
+
24
26
from airflow .exceptions import AirflowProviderDeprecationWarning
25
27
from airflow .models import BaseOperatorLink , XCom
26
28
from airflow .providers .google .cloud .links .base import BASE_LINK , BaseGoogleLink
@@ -42,6 +44,7 @@ def __getattr__(name: str) -> Any:
42
44
" Please use DATAPROC_JOB_LINK instead"
43
45
),
44
46
AirflowProviderDeprecationWarning ,
47
+ stacklevel = 2 ,
45
48
)
46
49
return DATAPROC_JOB_LINK
47
50
raise AttributeError (f"module { __name__ } has no attribute { name } " )
@@ -68,18 +71,15 @@ def __getattr__(name: str) -> Any:
68
71
)
69
72
70
73
74
+ @attr .s (auto_attribs = True )
71
75
class DataprocLink (BaseOperatorLink ):
72
76
"""
73
77
Helper class for constructing Dataproc resource link.
74
78
75
79
.. warning::
76
- This link is deprecated .
80
+ This link is pending to deprecate .
77
81
"""
78
82
79
- warnings .warn (
80
- "This DataprocLink is deprecated." ,
81
- AirflowProviderDeprecationWarning ,
82
- )
83
83
name = "Dataproc resource"
84
84
key = "conf"
85
85
@@ -116,7 +116,17 @@ def get_link(
116
116
else ""
117
117
)
118
118
119
+ def __attrs_post_init__ (self ):
120
+ # This link is still used into the selected operators
121
+ # - airflow.providers.google.cloud.operators.dataproc.DataprocScaleClusterOperator
122
+ # - airflow.providers.google.cloud.operators.dataproc.DataprocJobBaseOperator
123
+ # - airflow.providers.google.cloud.operators.dataproc.DataprocSubmitPigJobOperator
124
+ # As soon as we remove reference to this link we might deprecate it by add warning message
125
+ # with `stacklevel=3` below in this method.
126
+ ...
119
127
128
+
129
+ @attr .s (auto_attribs = True )
120
130
class DataprocListLink (BaseOperatorLink ):
121
131
"""
122
132
Helper class for constructing list of Dataproc resources link.
@@ -125,7 +135,6 @@ class DataprocListLink(BaseOperatorLink):
125
135
This link is deprecated.
126
136
"""
127
137
128
- warnings .warn ("This DataprocListLink is deprecated." , AirflowProviderDeprecationWarning )
129
138
name = "Dataproc resources"
130
139
key = "list_conf"
131
140
@@ -159,6 +168,13 @@ def get_link(
159
168
else ""
160
169
)
161
170
171
+ def __attrs_post_init__ (self ):
172
+ warnings .warn (
173
+ "This DataprocListLink is deprecated." ,
174
+ AirflowProviderDeprecationWarning ,
175
+ stacklevel = 3 ,
176
+ )
177
+
162
178
163
179
class DataprocClusterLink (BaseGoogleLink ):
164
180
"""Helper class for constructing Dataproc Cluster Link."""
0 commit comments