The Python Oracle

Why does `joblib.delayed` not work as decorator?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Industries in Orbit Looping

--

Chapters
00:00 Why Does `Joblib.Delayed` Not Work As Decorator?
00:42 Accepted Answer Score 1
01:05 Thank you

--

Full question
https://stackoverflow.com/questions/3884...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #python27 #decorator #pythondecorators #joblib

#avk47



ACCEPTED ANSWER

Score 1


It looks like it's a namespace issue, which causes joblib.delayed to attempt to pickle the output function (instead of the original function).

I haven't looked into the joblib code, but the thing you proposed would be the way to do it:

import joblib

def _func(*args, **kwargs):
    'your code here'

func = joblib.delayed(_func)

It's not ideal, but it works.