Skip to content

[BugFix] Changing the dm_control import to fail if not installed #515

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

Merged
merged 3 commits into from
Oct 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions torchrl/envs/libs/dm_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ class DMControlEnv(DMControlWrapper):
"""

def __init__(self, env_name, task_name, **kwargs):
if not _has_dmc:
raise ImportError(
"dm_control python package was not found."
"Please install this dependency."
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to check it with _has_dmc compared to self.available_envs, because it's easier to track why _has_dmc is False

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're absolutely right!

kwargs["env_name"] = env_name
kwargs["task_name"] = task_name
super().__init__(**kwargs)
Expand Down