Skip to content

Commit

Permalink
Fixed import for importlib
Browse files Browse the repository at this point in the history
  • Loading branch information
DanilBaibak committed Feb 15, 2024
1 parent 45764b5 commit bd154c9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions torchrl/_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

import importlib
import importlib.util
import warnings


def is_module_available(*modules: str) -> bool:
r"""Returns if a top-level module with :attr:`name` exists *without** importing it.
"""Returns if a top-level module with :attr:`name` exists *without** importing it.
This is generally safer than try-catch block around a
`import X`. It avoids third party libraries breaking assumptions of some of
our tests, e.g., setting multiprocessing start method when imported
(see librosa/#747, torchvision/#544).
"""
return all(importlib.util.find_spec(m) is not None for m in modules)

Expand Down

0 comments on commit bd154c9

Please sign in to comment.