Skip to content

Commit

Permalink
Fix minor Optional Dependency issues (#580)
Browse files Browse the repository at this point in the history
* Add comment explaining the usage of ERROR_TYPES

* Fix tensorflow probability import edge case issue
  • Loading branch information
mauicv authored Aug 10, 2022
1 parent 51b76ce commit b618c39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions alibi_detect/utils/frameworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

try:
import tensorflow as tf # noqa
import tensorflow_probability as tfp # noqa
has_tensorflow = True
except ImportError:
has_tensorflow = False
Expand Down
9 changes: 9 additions & 0 deletions alibi_detect/utils/missing_optional_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
))


"""Mapping used to ensure correct pip install message is generated if a missing optional dependency is detected. This
dict is used to control two behaviours:
1. When we import objects from missing dependencies we check that any `ModuleNotFoundError` or `ImportError`
corresponds to a missing optional dependency by checking the name of the missing dependency is in `ERROR_TYPES`. We
then map this name to the corresponding optional dependency bucket that will resolve the issue.
2. Some optional dependencies have multiple names such as `torch` and `pytorch`, instead of enforcing a single
naming convention across the whole code base we instead use `ERROR_TYPES` to capture both cases. This is done right
before the pip install message is issued as this is the most robust place to capture these differences.
"""
ERROR_TYPES = {
"fbprophet": 'prophet',
"holidays": 'prophet',
Expand Down

0 comments on commit b618c39

Please sign in to comment.