You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
migrate from dill to cloudpickle for advanced serialization #7870
Usage of dill for optional serialization in PythonVirtualenvOperator may be replaced with cloudpickle as its serialization library. This should be a mostly drop-in replacement.
Use case / motivation
Currently, the PythonVirtualenvOperator optionally uses dill in place of stock pickle to serialize advanced types. However, most major distributed compute frameworks have opted to shift to cloudpickle, meaning using dill for Airflow can introduce redundant dependencies for calling out to other distributed compute (e.g., farming compute-heavy tasks out to a remote dask cluster), and can interfere with serialization of tasks for those tools.
Since both dill and cloudpickle are largely drop-in replacements for pickle, the migration should be fairly minor.
so dill is optional to use (set by a flag in the PythonVirtualenvOperator) but is always imported and treated as a required dependency for Airflow, right? Keeping that pattern it should be super easy to cut over to cloudpickle.
I'd generally advocate for allowing fewer dependencies though, so it could be nice to make cloudpickle a proper extra-dependency and put some checks around the import. That would let people keep minimal environments if they choose/need to. I've also run into situations where it wasn't being used (no virtualenv operators in my dag) but because it was imported dill was still getting captured by serializers like cloudpickle since they scoop up a fair amount of runtime environment information.
either way it would probably also necessitate reworking some of the tests, since (for example) cloudpickle could conceivably serialize lambda functions for the python_callable inputs
Hi @jrwalk, can I work on this?
dill and cloudpickle seem to be fairly similar, is there anything else I should consider (except for the tests your mentioned)?
Assigned you. The issue is pretty old - we also have ExternalPythonOperator using same approach now. I think just focusing on tests for those might be enough
Activity
boring-cyborg commentedon Mar 25, 2020
Thanks for opening your first issue here! Be sure to follow the issue template!
ashb commentedon Mar 26, 2020
Is it worth making the pickle module a config setting, or just always using cloudpickle instead?
jrwalk commentedon Mar 27, 2020
so
dillis optional to use (set by a flag in thePythonVirtualenvOperator) but is always imported and treated as a required dependency for Airflow, right? Keeping that pattern it should be super easy to cut over tocloudpickle.I'd generally advocate for allowing fewer dependencies though, so it could be nice to make
cloudpicklea proper extra-dependency and put some checks around the import. That would let people keep minimal environments if they choose/need to. I've also run into situations where it wasn't being used (no virtualenv operators in my dag) but because it was importeddillwas still getting captured by serializers likecloudpicklesince they scoop up a fair amount of runtime environment information.jrwalk commentedon Mar 27, 2020
either way it would probably also necessitate reworking some of the tests, since (for example) cloudpickle could conceivably serialize
lambdafunctions for thepython_callableinputssumeshpremraj commentedon Jul 12, 2023
Hi @jrwalk, can I work on this?
dill and cloudpickle seem to be fairly similar, is there anything else I should consider (except for the tests your mentioned)?
potiuk commentedon Jul 12, 2023
Assigned you. The issue is pretty old - we also have ExternalPythonOperator using same approach now. I think just focusing on tests for those might be enough
Felix-neko commentedon Nov 8, 2023
#35529 -- maybe using cloudpickle could cure this problem?
potiuk commentedon Nov 8, 2023
If you would like to take a stab on it and attempt to try it - fee free to verify that hypothesis @Felix-neko - PRs are always most welcome.
Felix-neko commentedon Nov 8, 2023
Heh, it looks like you're overestimating my power (and my current knowledge in cloudpickle and airflow)
; )
Taragolis commentedon Nov 8, 2023
It might help. There is also limitations for cloudpickle exists:
Felix-neko commentedon Nov 8, 2023
That won't be a big problem. Especially if simple
dillwill still be supported.VladaZakharova commentedon Mar 21, 2024
@sumeshpremraj
Hi there! May I ask how is the progress going on this issue?
gyli commentedon Jul 20, 2024
With #39270 completed, argument
serializerwas added to support choosing from serializers. Looks like this issue can be closed.