SeldonIO / alibi-detect

Algorithms for outlier, adversarial and drift detection
https://docs.seldon.io/projects/alibi-detect/en/stable/
Other
2.24k stars 224 forks source link

Cloudpickle v1.5.0 breaks tensorflow probabilities. #124

Closed gipster closed 4 years ago

gipster commented 4 years ago

Hey. cloudpickle v1.5.0 breaks tensorflow probabilities.

Running import alibi_detect raises the error:

  File "<stdin>", line 1, in <module>
  File "/home/fdz/git/fork-alibi-detect/alibi_detect/__init__.py", line 1, in <module>
    from . import ad, cd, metrics, models, od, utils
  File "/home/fdz/git/fork-alibi-detect/alibi_detect/ad/__init__.py", line 1, in <module>
    from .adversarialae import AdversarialAE
  File "/home/fdz/git/fork-alibi-detect/alibi_detect/ad/adversarialae.py", line 8, in <module>
    from alibi_detect.models.autoencoder import AE
  File "/home/fdz/git/fork-alibi-detect/alibi_detect/models/__init__.py", line 3, in <module>
    from .pixelcnn import PixelCNN
  File "/home/fdz/git/fork-alibi-detect/alibi_detect/models/pixelcnn.py", line 9, in <module>
    from tensorflow_probability.python.bijectors import bijector
  File "/home/fdz/anaconda3/envs/test-alibi-detect/lib/python3.7/site-packages/tensorflow_probability/__init__.py", line 76, in <module>
    from tensorflow_probability.python import *  # pylint: disable=wildcard-import
  File "/home/fdz/anaconda3/envs/test-alibi-detect/lib/python3.7/site-packages/tensorflow_probability/python/__init__.py", line 23, in <module>
    from tensorflow_probability.python import distributions
  File "/home/fdz/anaconda3/envs/test-alibi-detect/lib/python3.7/site-packages/tensorflow_probability/python/distributions/__init__.py", line 88, in <module>
    from tensorflow_probability.python.distributions.pixel_cnn import PixelCNN
  File "/home/fdz/anaconda3/envs/test-alibi-detect/lib/python3.7/site-packages/tensorflow_probability/python/distributions/pixel_cnn.py", line 37, in <module>
    from tensorflow_probability.python.layers import weight_norm
  File "/home/fdz/anaconda3/envs/test-alibi-detect/lib/python3.7/site-packages/tensorflow_probability/python/layers/__init__.py", line 31, in <module>
    from tensorflow_probability.python.layers.distribution_layer import CategoricalMixtureOfOneHotCategorical
  File "/home/fdz/anaconda3/envs/test-alibi-detect/lib/python3.7/site-packages/tensorflow_probability/python/layers/distribution_layer.py", line 28, in <module>
    from cloudpickle.cloudpickle import CloudPickler
ImportError: cannot import name 'CloudPickler' from 'cloudpickle.cloudpickle' (/home/fdz/anaconda3/envs/test-alibi-detect/lib/python3.7/site-packages/cloudpickle/cloudpickle.py)

A related issue is raised here https://github.com/cloudpipe/cloudpickle/issues/390. A possible solution is here https://github.com/cloudpipe/cloudpickle/issues/390#issuecomment-652833748. All works fine with cloudpickle v1.4.1

mgarort commented 4 years ago

I confirm that after changing from cloudpickle.cloudpickle import CloudPickler to from cloudpickle import CloudPickler I was able to import.

arnaudvl commented 4 years ago

TensorFlow Probability released TFP 0.10.1 to mitigate this issue and pinned the cloudpickle version to 1.3.0 (https://github.com/tensorflow/probability/issues/991) which should fix it.