-
Notifications
You must be signed in to change notification settings - Fork 153
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
Process-safe launching of minecraft instance to solve creating multiple minerl environments in parallel #352
base: master
Are you sure you want to change the base?
Process-safe launching of minecraft instance to solve creating multiple minerl environments in parallel #352
Conversation
Does this require waiting for one instance to lock then launching the next? |
@minerllabs Yes, one thread acquires the lock first, then other threads wait in a queue to acquire the lock after the first one exits. There could be a way to narrow the scope of the lock period, but so far as I see it, there isn't a good way as the logic is controlled in the Minecraft client. But in practice, I didn't see much of an issue with the locking, other than it taking a while to launch all of the environments. |
I found that this solution doesn't work with certain multiprocessing techniques to parallelize the environments, such as in RLlib. So this pull might not be the best to merge yet. I'll be looking into this. |
Hello @juliusfrost! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2020-07-14 20:43:18 UTC |
@@ -47,6 +48,8 @@ | |||
|
|||
missions_dir = os.path.join(os.path.dirname(__file__), 'missions') | |||
|
|||
launch_instance_lock = FileLock(os.path.join(os.path.dirname(__file__), 'env.lock')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileLock uses a file as communication for processes to proceed in the code. When a process enters the launch instance code, FileLock creates a file env.lock
in the same directory and prevents other processes from entering unless the lock is removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes require adding the filelock
module to requirements.txt
. I've replaced the thread lock to this instead to work with multiple processes. This is a necessary change to add multiprocessing support, but parallelization improvements can be made if direct modification with Malmo is involved.
@MadcowD @minerllabs What should be done further to merge this? |
Hey this would be nice to have @MadcowD @minerllabs. Can we approve this PR? |
Any update on this? |
This seems to have been fixed in the latest version. At least this test script runs fine (but for some reason runs slow on my machine, even with a single environment. Might be my mangled environments). Parallel instances do not work on Windows, tho. |
Adds a simple thread lock to prevent multiple processes from accessing the launch script. This prevents gradle build errors when trying to create multiple minerl environments in parallel. This passes asynchronous creation in #334 with the help of #351