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

[BugFix] Fixed import for importlib #1914

Merged
merged 6 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions .github/workflows/build-wheels-m1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ permissions:

jobs:
generate-matrix:
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@Remove-Builds-Limits-for-Testing
with:
package-type: wheel
os: macos-arm64
test-infra-repository: pytorch/test-infra
test-infra-ref: main
test-infra-ref: Remove-Builds-Limits-for-Testing
build:
needs: generate-matrix
strategy:
Expand Down
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
Loading