@@ -111,14 +111,15 @@ class TaskDecoratorCollection:
111
111
# _PythonVirtualenvDecoratedOperator.
112
112
requirements : None | Iterable [str ] | str = None ,
113
113
python_version : None | str | int | float = None ,
114
- use_dill : bool = False ,
114
+ serializer : Literal [ "pickle" , "cloudpickle" , "dill" ] | None = None ,
115
115
system_site_packages : bool = True ,
116
116
templates_dict : Mapping [str , Any ] | None = None ,
117
117
pip_install_options : list [str ] | None = None ,
118
118
skip_on_exit_code : int | Container [int ] | None = None ,
119
119
index_urls : None | Collection [str ] | str = None ,
120
120
venv_cache_path : None | str = None ,
121
121
show_return_value_in_logs : bool = True ,
122
+ use_dill : bool = False ,
122
123
** kwargs ,
123
124
) -> TaskDecorator :
124
125
"""Create a decorator to convert the decorated callable to a virtual environment task.
@@ -129,6 +130,13 @@ class TaskDecoratorCollection:
129
130
"requirements file" as specified by pip.
130
131
:param python_version: The Python version to run the virtual environment with. Note that
131
132
both 2 and 2.7 are acceptable forms.
133
+ :param serializer: Which serializer use to serialize the args and result. It can be one of the following:
134
+
135
+ - ``"pickle"``: (default) Use pickle for serialization. Included in the Python Standard Library.
136
+ - ``"cloudpickle"``: Use cloudpickle for serialize more complex types,
137
+ this requires to include cloudpickle in your requirements.
138
+ - ``"dill"``: Use dill for serialize more complex types,
139
+ this requires to include dill in your requirements.
132
140
:param use_dill: Whether to use dill to serialize
133
141
the args and result (pickle is default). This allow more complex types
134
142
but requires you to include dill in your requirements.
@@ -154,6 +162,9 @@ class TaskDecoratorCollection:
154
162
logs. Defaults to True, which allows return value log output.
155
163
It can be set to False to prevent log output of return value when you return huge data
156
164
such as transmission a large amount of XCom to TaskAPI.
165
+ :param use_dill: Deprecated, use ``serializer`` instead. Whether to use dill to serialize
166
+ the args and result (pickle is default). This allows more complex types
167
+ but requires you to include dill in your requirements.
157
168
"""
158
169
@overload
159
170
def virtualenv (self , python_callable : Callable [FParams , FReturn ]) -> Task [FParams , FReturn ]: ...
@@ -164,9 +175,10 @@ class TaskDecoratorCollection:
164
175
multiple_outputs : bool | None = None ,
165
176
# 'python_callable', 'op_args' and 'op_kwargs' since they are filled by
166
177
# _PythonVirtualenvDecoratedOperator.
167
- use_dill : bool = False ,
178
+ serializer : Literal [ "pickle" , "cloudpickle" , "dill" ] | None = None ,
168
179
templates_dict : Mapping [str , Any ] | None = None ,
169
180
show_return_value_in_logs : bool = True ,
181
+ use_dill : bool = False ,
170
182
** kwargs ,
171
183
) -> TaskDecorator :
172
184
"""Create a decorator to convert the decorated callable to a virtual environment task.
@@ -176,9 +188,13 @@ class TaskDecoratorCollection:
176
188
(so usually start with "/" or "X:/" depending on the filesystem/os used).
177
189
:param multiple_outputs: If set, function return value will be unrolled to multiple XCom values.
178
190
Dict will unroll to XCom values with keys as XCom keys. Defaults to False.
179
- :param use_dill: Whether to use dill to serialize
180
- the args and result (pickle is default). This allow more complex types
181
- but requires you to include dill in your requirements.
191
+ :param serializer: Which serializer use to serialize the args and result. It can be one of the following:
192
+
193
+ - ``"pickle"``: (default) Use pickle for serialization. Included in the Python Standard Library.
194
+ - ``"cloudpickle"``: Use cloudpickle for serialize more complex types,
195
+ this requires to include cloudpickle in your requirements.
196
+ - ``"dill"``: Use dill for serialize more complex types,
197
+ this requires to include dill in your requirements.
182
198
:param templates_dict: a dictionary where the values are templates that
183
199
will get templated by the Airflow engine sometime between
184
200
``__init__`` and ``execute`` takes place and are made available
@@ -187,6 +203,9 @@ class TaskDecoratorCollection:
187
203
logs. Defaults to True, which allows return value log output.
188
204
It can be set to False to prevent log output of return value when you return huge data
189
205
such as transmission a large amount of XCom to TaskAPI.
206
+ :param use_dill: Deprecated, use ``serializer`` instead. Whether to use dill to serialize
207
+ the args and result (pickle is default). This allows more complex types
208
+ but requires you to include dill in your requirements.
190
209
"""
191
210
@overload
192
211
def branch ( # type: ignore[misc]
@@ -211,14 +230,15 @@ class TaskDecoratorCollection:
211
230
# _PythonVirtualenvDecoratedOperator.
212
231
requirements : None | Iterable [str ] | str = None ,
213
232
python_version : None | str | int | float = None ,
214
- use_dill : bool = False ,
233
+ serializer : Literal [ "pickle" , "cloudpickle" , "dill" ] | None = None ,
215
234
system_site_packages : bool = True ,
216
235
templates_dict : Mapping [str , Any ] | None = None ,
217
236
pip_install_options : list [str ] | None = None ,
218
237
skip_on_exit_code : int | Container [int ] | None = None ,
219
238
index_urls : None | Collection [str ] | str = None ,
220
239
venv_cache_path : None | str = None ,
221
240
show_return_value_in_logs : bool = True ,
241
+ use_dill : bool = False ,
222
242
** kwargs ,
223
243
) -> TaskDecorator :
224
244
"""Create a decorator to wrap the decorated callable into a BranchPythonVirtualenvOperator.
@@ -232,9 +252,13 @@ class TaskDecoratorCollection:
232
252
"requirements file" as specified by pip.
233
253
:param python_version: The Python version to run the virtual environment with. Note that
234
254
both 2 and 2.7 are acceptable forms.
235
- :param use_dill: Whether to use dill to serialize
236
- the args and result (pickle is default). This allow more complex types
237
- but requires you to include dill in your requirements.
255
+ :param serializer: Which serializer use to serialize the args and result. It can be one of the following:
256
+
257
+ - ``"pickle"``: (default) Use pickle for serialization. Included in the Python Standard Library.
258
+ - ``"cloudpickle"``: Use cloudpickle for serialize more complex types,
259
+ this requires to include cloudpickle in your requirements.
260
+ - ``"dill"``: Use dill for serialize more complex types,
261
+ this requires to include dill in your requirements.
238
262
:param system_site_packages: Whether to include
239
263
system_site_packages in your virtual environment.
240
264
See virtualenv documentation for more information.
@@ -253,6 +277,9 @@ class TaskDecoratorCollection:
253
277
logs. Defaults to True, which allows return value log output.
254
278
It can be set to False to prevent log output of return value when you return huge data
255
279
such as transmission a large amount of XCom to TaskAPI.
280
+ :param use_dill: Deprecated, use ``serializer`` instead. Whether to use dill to serialize
281
+ the args and result (pickle is default). This allows more complex types
282
+ but requires you to include dill in your requirements.
256
283
"""
257
284
@overload
258
285
def branch_virtualenv (self , python_callable : Callable [FParams , FReturn ]) -> Task [FParams , FReturn ]: ...
@@ -264,9 +291,10 @@ class TaskDecoratorCollection:
264
291
multiple_outputs : bool | None = None ,
265
292
# 'python_callable', 'op_args' and 'op_kwargs' since they are filled by
266
293
# _PythonVirtualenvDecoratedOperator.
267
- use_dill : bool = False ,
294
+ serializer : Literal [ "pickle" , "cloudpickle" , "dill" ] | None = None ,
268
295
templates_dict : Mapping [str , Any ] | None = None ,
269
296
show_return_value_in_logs : bool = True ,
297
+ use_dill : bool = False ,
270
298
** kwargs ,
271
299
) -> TaskDecorator :
272
300
"""Create a decorator to wrap the decorated callable into a BranchExternalPythonOperator.
@@ -279,9 +307,13 @@ class TaskDecoratorCollection:
279
307
(so usually start with "/" or "X:/" depending on the filesystem/os used).
280
308
:param multiple_outputs: If set, function return value will be unrolled to multiple XCom values.
281
309
Dict will unroll to XCom values with keys as XCom keys. Defaults to False.
282
- :param use_dill: Whether to use dill to serialize
283
- the args and result (pickle is default). This allow more complex types
284
- but requires you to include dill in your requirements.
310
+ :param serializer: Which serializer use to serialize the args and result. It can be one of the following:
311
+
312
+ - ``"pickle"``: (default) Use pickle for serialization. Included in the Python Standard Library.
313
+ - ``"cloudpickle"``: Use cloudpickle for serialize more complex types,
314
+ this requires to include cloudpickle in your requirements.
315
+ - ``"dill"``: Use dill for serialize more complex types,
316
+ this requires to include dill in your requirements.
285
317
:param templates_dict: a dictionary where the values are templates that
286
318
will get templated by the Airflow engine sometime between
287
319
``__init__`` and ``execute`` takes place and are made available
@@ -290,6 +322,9 @@ class TaskDecoratorCollection:
290
322
logs. Defaults to True, which allows return value log output.
291
323
It can be set to False to prevent log output of return value when you return huge data
292
324
such as transmission a large amount of XCom to TaskAPI.
325
+ :param use_dill: Deprecated, use ``serializer`` instead. Whether to use dill to serialize
326
+ the args and result (pickle is default). This allows more complex types
327
+ but requires you to include dill in your requirements.
293
328
"""
294
329
@overload
295
330
def branch_external_python (
0 commit comments