Closed Silloky closed 1 month ago
Hi @Silloky!
Due to the way the tskit C extension works you can't pickle a Tree
. You can, however pickle a TreeSequence
so I suggest passing that and an index if you really need to do so.
Hello @benjeffery Thanks for your answer. Right, OK, I didn't know ; tskit is fairly new to me tbh. I'll try that then.
I'd just like your opinion though.
In the code above, the f
function only needs one single tree.
Is it still efficient if I pass the entire TreeSequence
instead of the one Tree
it needs ?
Finally, it turns out that the issue I was encountering is insignificant as I can easily bypass this whole problem. Thanks for your help and I am now closing this issue.
I am trying to multiprocess a function that takes a
Tree
object as an parameter. I understand multiprocessing requires serializing any data exchanged to other cores or even processors.Thus, the
Tree
object needs to be pickled to be passed to the function running on another core. Here is my code :pd_sequence
is apandas
DataFrame
containingtskit
Tree
objects.This code throws :
I've tried debugging a bit using just
dill
and I can confirm a simpledill.dumps
throws the same error.I thought of transforming the
Tree
object to adict
usingTree.as_dict_of_dicts
and then serializing. This works, but I then realised that I couldn't re-transform thedict
into a validTree
object, which is what I need...I hope you'll have enough information here to understand the issue and reproduce.
Thanks !