Skip to content
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

Add back in imitation.envs.examples support to scripts #501

Closed
AdamGleave opened this issue Jul 28, 2022 · 2 comments · Fixed by #541
Closed

Add back in imitation.envs.examples support to scripts #501

AdamGleave opened this issue Jul 28, 2022 · 2 comments · Fixed by #541
Assignees

Comments

@AdamGleave
Copy link
Member

#484 removes the import to imitation.envs.examples from src/imitation/scripts/__init__.py to workaround sphinx-doc/sphinx#9069

Some options:

  1. Move this example env code out of the repo. It was never a great fit for imitation anyway. Perhaps put it in a new contrib repo, or in seals.
  2. Workaround the Sphinx bug, e.g. by a relative import or perhaps importing a specific function to call register() on.
  3. Document an alternative way to use the example environments. I think something like env_name=imitation.envs.examples:imitation/Random-v0 might just work? (gym.make has some magic to import modules.)
@Rocamonde
Copy link
Member

If we decide to keep the code, we probably should change the way we register the packages. Having module-level code that executes when it's imported is generally not a good idea for libraries (vs. frameworks). Could the user not manually call a register function if they want to use this? (maybe I'm wrong and it's how Gym is supposed to work)

@AdamGleave
Copy link
Member Author

This is fairly standard practice for Gym, e.g. this happens in Gym itself and roboschool.

Of course, standard practice is not necessarily the same as good practice. The main reasons to avoid module-level code that I'm aware of are performance and possible unintended side-effects. Performance overhead should be negligible, gym.register does not do much (just updates a dict). Side-effects are contained as things are only registered under the imitation/ namespace.

The most compelling reason I can see for moving it into a manual register function is just that it's more explicit / less magical. Already we have the issue we have to do import imitation.envs.example # noqa: F841 because it's an unused import. If we added an extra line to explicitly register it, that problem would go away.

Overall don't have a strong preference here either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants