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
registering a new environment #142
Comments
Can you use the env_id "gym_banana:Banana-v0"? This requires that |
@christopherhesse @nealmcb I'm also having this issue. We register the env before we invoke the ExperimentGrid and we confirm the env is registered by making it and printing custom env attributes in our script. However the experiment threads do not have the env registered (perhaps because the registration is limited in scope to only the master thread which runs our script) it may be necessary to edit gym itself to register the custom env in all threads instead of just the master thread as a local registration might not be globally available |
@bionicles do you have a short example script that demonstrates the issue? |
not really, our custom env is a file, and it's proprietary for now, but I did fix the registration issue by:
Now our custom env can be seen by all the threads because we spliced it into gym. Our environment also includes a custom numpy array space which i added into gym/spaces/array.py and added it to the now hitting a new issue; the replay buffers used in the td3 algorithm only support 1D observations, but our molecular environment has arbitrary dimensionality spaces (the aforementioned "Array" space I built) which do not fit into the current algos/td3/td3.py ReplayBuffer class (which just assumes observations are 17D, when in our case they are num_atoms x 17D i believe it would save considerable work for us to transpose our custom env observation and action spaces to be instead shape (num_features, num_atoms) and (3, num_atoms) for the xyz dimensions, as this would allow us to avoid changing a bunch of code inside spinup to index different dimensions of these spaces but we'll still need to augment the replay buffer class to support the additional dimension, and probably the training algorithm will need to change to read this buffer properly also |
If someone has a small example script that demonstrates this issue (it can use the |
this issue only happens because the master script registers the env in one thread, and then other mpi threads run the actors, and those threads re-import gym separately, such that the original version of gym has the custom env, but the threads do not. If we could pass a path to the custom env to the threads, and they could register the env automatically, then we wouldn't need to splice custom envs into gym, we could just pass a path to the env into the script:
then the algo can just register the env at the given path under the provided name |
My solution to this problem was doing the following:
|
@krishpop Did this solve the problem? How did you pass it as an argument to the experiment? Did you change the spinup.run? Or you defined this function and passed it to the experiment as:
Because this does not work for me. I am not sure if you meant to modify the spinup.run file or your main code. Inside the |
@alitk I am using my own run script and using the experiments API here's a minimal example: https://gist.github.com/krishpop/f4b2aa8d60d7b22bce8c258fd68ab11c |
Thank you @krishpop . I managed to fix it using these commands:
I basically added it as a box2d environment to gym (which was the idea mentioned by @bionicles ). I append a line in the two init.py in the original gym environment folder. It might be a different folder for Anaconda. These folders are in Google Colab since I am using it. Finally, the problem was solved and I am able to use it in the form I mentioned
|
What's the best solution here? I see:
I basically got this error when switching the environment name in the bench_ppo_cartpole.py example from the default env ( Should I be expecting this example code to work with my custom environment this easily?
thanks. |
I'm also running into the same issue and would love an answer to @billtubbs question! |
Same here, it's not clear the right way to inform spinup of your custom environments. I want to be able to indicate to others on my team how to install spinup and our custom environment and run them together |
Any updates on this? Looking to try on a custom environment. |
@hmate9 one modification worth trying is adding a file to utils that contains env_fn factory to create custom env generators that can be passed directly to the run script from the command line. For example, see my forked branch here. In spinup/utils/rrc_utils.py, I have added an env_fn factory (with the ability to add wrappers) that can make an arbitrary wrapped env. This way, env_fn can be passed in as a command line argument, for example, |
Any updates here? |
This commit contains a solution to the problems explained in openai#142. It adds two ways for people to use a custom environment with the Spinningup package: 1. People can add the code that initializes the custom gym environmeent in the 'env_config.py' file. 2. People can use the 'env_pkg' cmd line argument to specify which package should be imported for the custom environment to work.
This commit contains a solution to the problems explained in openai#142. It adds two ways for people to use a custom environment with the Spinningup package: 1. People can add the code that initializes the custom gym environment in the 'env_config.py' file. 2. People can use the 'env_pkg' cmd line argument to specify which the package should be imported for the custom environment to work.
@varunjammula I just created a pull request with our department's solution to this issue in a package based on the SpinningUp Package. You merge it into your fork to see if it suits your needs. |
@varunjammula I also just found the solution of @pkol in #201 which I think is an even more elegant solution. |
Is there any way to specify a custom environment on the command line, e.g. as a fully-qualified name or lambda? Using the name of a custom environment as is leads to this error:
I can get past that point in the code by throwing an import statement in run.py for my custom environment
import gym_banana
, but then I run in to this later on:....
gym.error.UnregisteredEnv: No registered env with id: Banana-v0
so evidently I need a more robust way to get it registered.
The text was updated successfully, but these errors were encountered: