OK, I finally found a workaround. I created a processing tool based on my function and I used it in the other script.