We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eae6682 commit 43ab98bCopy full SHA for 43ab98b
src/lightning/fabric/utilities/imports.py
@@ -36,6 +36,17 @@
36
_PYTHON_GREATER_EQUAL_3_10_0 = (sys.version_info.major, sys.version_info.minor) >= (3, 10)
37
38
39
+@functools.lru_cache(maxsize=128)
40
+def _try_import_module(module_name: str) -> bool:
41
+ try:
42
+ __import__(module_name)
43
+ return True
44
+ # added also AttributeError fro case of impoerts like pl.LightningModule
45
+ except (ImportError, AttributeError) as err:
46
+ rank_zero_warn(f"Import of {module_name} package failed for some compatibility issues: \n{err}")
47
+ return False
48
+
49
50
@functools.lru_cache(maxsize=1)
51
def _lightning_xpu_available() -> bool:
52
# This is defined as a function instead of a constant to avoid circular imports, because `lightning_xpu`
0 commit comments