Skip to content

Commit

Permalink
Catch AttributeError during JAX import.
Browse files Browse the repository at this point in the history
Importing edward2 leads to AttributeError if you use a Colab runtime without JAX dependency.

This fix catches AttributeError and omits the edward2.jax namespace.

PiperOrigin-RevId: 548798730
  • Loading branch information
dustinvtran authored and edward-bot committed Oct 16, 2023
1 parent 3a9b7ef commit 636704d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion edward2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
try:
from edward2 import jax
__all__ += ["jax"]
except ImportError:
except (ImportError, AttributeError):
# We also catch AttributeError. JAX can raise AttributeError during
# imports in colab unless JAX is directly installed first.
warnings.warn("JAX backend for Edward2 is not available.")

try:
Expand Down

0 comments on commit 636704d

Please sign in to comment.