-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DreamPool implementation seems incompatible with Python3.8 multiprocess? #16
Comments
Thinking about this some more, I was wondering if anyone could maybe explain why using multiprocess as a dependency is better than using the standard multiprocessing library? |
Hi @lschwetlick, thank you for reporting this problem. I just checked and you are right, there is no need to use the multiprocess package. Regarding the issue with python 3.8, you are also right about the problem with the Also, it is possible to use the new concurrent futures api that supports the launching of child processes and thus there is no need to subclass the multiprocessing |
Thanks so much for actively maintaining the package! I use it a lot, so if I can contribute in some way, I'd be happy to. |
I am glad you find PyDREAM useful! I have made a pull request that should enable users to run PyDREAM with Python 3.8. I'll have to wait until someone from the lab reviews the PR to release a new version. In the meantime, you can install the pydream from the dream_pool_all_python branch using pip: I would appreciate it if you can take a look at the PR and see if something that doesn't make sense :) Also, if you know about Bayesian hierarchical modeling could you take a look at the issue #15? I haven't figured out yet how to do hierarchical bayes with pydream. Thanks! |
Hi, I only got around to trying it now and I do have a question about it. Although as far as I can tell you are getting the context from mp.get_context, so I'm really unsure what would be causing this...
|
Hi, thanks for reporting this issue. Since Python 3.8 the default method to start the processes in a mac changed from if __name__ == '__main__':
run_dream(...) As you mentioned above there is no need to call the freeze_support function() in a mac. Alternatively, you can run pydream with a from multiprocessing import get_context
run_dream(..., mp_context=get_context('fork')) I hope this is helpful. If you keep getting errors please let us know and we can reopen this issue |
Ah, I see! Thanks for clearing that up for me. I was quite mystified! I'm getting no further errors, so it all looks good. Thanks again for fixing :) |
I have been having troble getting PyDream to work with Python 3.8 and I think I have tracked down the root of the problem: The
DreamPool
class integrates with a multiprocess function that has changed in the Python3.8 version of multiprocess.What?
In Python3.8 when installing pyDream in a clean environment, a very simple test script kept outputting the error:
When doing the exact same thing (environment, pip install ., try script) it works as expected.
Why?
In previous implementations of multiprocess, the
Pool
class defined processes with just args and kw args see here.In the Python3.8 version
Pool
has an extra argumentctx
see here.In PyDream the
Process
member ofPool
gets overwritten by the custom classNoDaemonProcess
.NoDaemonProcess
does not expect to be passed thectx
variable, and interprets is as thegroup
argument.group
needs to beNone
, thus the error.Ideas
In order to be compatible with multiprocess, I assume we need to make
NoDaemonProcess
depend on ctx (which is amultiprocess.context.ForkContext
object, which incidentally hides another layer of indirection with anotherProcess
subclass). Unfortunately, I'm not really understanding what thectx
variable does.I tried simply catching it with
and that seemed to work, I'm not entirely sure of whether there are unwanted consequences of this.
The text was updated successfully, but these errors were encountered: