Why does `joblib.delayed` not work as decorator?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Luau
--
Chapters
00:00 Question
01:04 Accepted answer (Score 1)
01:34 Thank you
--
Full question
https://stackoverflow.com/questions/3884...
Question links:
[documentation]: https://pythonhosted.org/joblib/parallel...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #python27 #decorator #pythondecorators #joblib
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Luau
--
Chapters
00:00 Question
01:04 Accepted answer (Score 1)
01:34 Thank you
--
Full question
https://stackoverflow.com/questions/3884...
Question links:
[documentation]: https://pythonhosted.org/joblib/parallel...
--
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.