-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
How to use lab as a python module #37
Comments
Hi - you would need to make your Python program depend on the module, something like this:
Inside your Python code, import the lab module in the same way the demo code does it. |
My understanding is that after doing what you're saying, I would run the program with the command
will produce
I tried rectifying this by adding the bazel-bin directory to PYTHONPATH. This lets me import deepmind_lab, but attempting to create a lab environment ie produces the error
This runtime error doesn't happen if the python interpreter is called inside the bazel-bin directory. Eventually, after creating symbolic links to the files in bazel-bin and creating a baselab folder containing assets, I managed to create a lab environment without error in a python interpreter. However
produces a popup error message that says "VM_Create on UI failed. See "~/.deepmind_lab/baselab/crashlog.txt" for details." I read through the crashlog but couldn't figure what was going on. |
Does the I think you have to use |
No, there's no error when doing bazel run. I ask about running it with |
No, unfortunately Bazel does not really lend itself to exporting reusable library components. This is a known issue, but I'm afraid I don't have a good solution for it right now. |
(Try |
|
Try also the other DSO that's loaded by |
Also, I was thinking it would be easier to give this up and directly run the binaries that bazel creates, however I run into the exact same issues listed above when I try to run the binaries with |
@johnholl https://github.com/miyosuda/unreal I put project dir inside |
Thanks @miyosuda, that's definitely very helpful. Also, another person in my lab, @junhyukoh, figured out that /bazel-bin/random_agent.runfiles/org_deepmind_lab is where all the necessary files reside. Running a python interpreter from here allows one to import deepmind lab, create a lab environment, and reset it without any problems. |
Ah yes, that's right: there's a wrapper script in |
@tkoeppe the solution proposed by @miyosuda works perfectly fine. However I think the better way would be to let bazel handle it automatically. I am trying to get a working example which uses the bazel tools to get lab as external dependency. However I am facing some problems. I get following error ERROR: ~/.cache/bazel/_bazel_noone/ae6e9d00e8c783d8279db324d79ccc60/external/org_deepmind_lab/BUILD:432:1: no such package '@zlib_archive//': error loading package 'external': The repository named 'zlib_archive' could not be resolved and referenced by '@org_deepmind_lab//:bspc'. ` my-project workspace(name = "maze_a3c") new_local_repository( git_repository( $cat BUILD py_binary( ` Kindly suggest what is the correct way to add bazel repository as external dependency and also correctly build it. As this pertains more to bazel build system I have asked the question there as well. Another similar issue in bazel. |
@arpit15: I'm afraid I don't have an answer for you. I've discussed this with the Bazel team in the past, and I think we all agree that Bazel is not very well suited at the moment to make exportable builds of reusable libraries. Bazel works well for a single-root project, where it gives you a very convenient mechanism to assemble dependencies of both compile-time code and runtime assets -- but it only works if you stay within the confines of the system. My understanding is that the Bazel team is working on making Bazel more flexible, and I'd encourage you to keep up with the developments there. But as far as the immediate present is concerned, I am thinking that it might be useful to set up an alternative build system if you want something exportable -- but I don't know what that would look like. |
@tkoeppe , do you any updates on this issue? |
@RylanSchaeffer: I think we have some code in the works to produce a pip package. I hope we'll get to push that soon. |
@tkoeppe Awesome! Do you have a rough estimate of when "soon" will be? |
@RylanSchaeffer: No hard guarantees, but hopefully soon. |
We didn't put this into the recent release, but it should make it into HEAD very soon. |
This should be available as of 0a0638c. |
@tkoeppe , I finally returned to this issue and I ran into a problem following the instructions. Specifically,
Do you know what might have caused this? |
@RylanSchaeffer: On which platform is this? You may have to edit |
Hi,
I built lab on Ubuntu 14.04. The python module tests all pass. I'm a little confused about importing deepmind_lab and running experiments with it in python. I apologize if this is due to my lack of general python/bazel knowledge. My understanding is that the process of experimentation with deepmind_lab is:
bazel run :experiment
Is this correct? And, is there any way to instead run experiments directly with
python experiment.py
?The text was updated successfully, but these errors were encountered: