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

Move all tf distribution imports within try/except block #572

Merged
merged 3 commits into from
Mar 21, 2017

Conversation

dustinvtran
Copy link
Member

@dustinvtran dustinvtran commented Mar 21, 2017

We autogenerate random variables from tensorflow.contrib.distributions, thus relying on specific TensorFlow versions. This provides a more informative message if the user does not have a supported TensorFlow version, thus making installation issues (#569 (comment), #568) easier to solve.

Remarks

  • Ideally this would be caught during installation of Edward in setup.py, but due to the tensorflow/tensorflow-gpu dichotomy we cannot explicitly depend on a TensorFlow version.
  • This is not testable with Travis unless we use an outdated TensorFlow version just for this test; that's too impractical to have for all integration testing.

@dustinvtran dustinvtran force-pushed the error/tensorflow-distributions branch from a332ace to 14f0d7e Compare March 21, 2017 15:02
@dustinvtran
Copy link
Member Author

From manual testing, this PR works for the following versions:

>>> print(tf.__version__)
'0.10.0'
>>> import edward as ed
Traceback (most recent call last):
  File "/Users/dvt/.pythonrc", line 11, in <module>
    import edward as ed
  File "edward/__init__.py", line 5, in <module>
    from edward import criticisms
  File "edward/criticisms/__init__.py", line 5, in <module>
    from edward.criticisms.evaluate import *
  File "edward/criticisms/evaluate.py", line 9, in <module>
    from edward.models import RandomVariable
  File "edward/models/__init__.py", line 5, in <module>
    from edward.models.dirichlet_process import *
  File "edward/models/dirichlet_process.py", line 7, in <module>
    from edward.models.random_variable import RandomVariable
  File "edward/models/random_variable.py", line 11, in <module>
    raise ImportError("{0}. Your TensorFlow version is not supported.".format(e))
ImportError: cannot import name register_session_run_conversion_functions. Your TensorFlow version is not supported.
>>> print(tf.__version__)
'0.11.0'
>>> import edward as ed
Traceback (most recent call last):
  File "/Users/dvt/.pythonrc", line 11, in <module>
    import edward as ed
  File "edward/__init__.py", line 5, in <module>
    from edward import criticisms
  File "edward/criticisms/__init__.py", line 5, in <module>
    from edward.criticisms.evaluate import *
  File "edward/criticisms/evaluate.py", line 9, in <module>
    from edward.models import RandomVariable
  File "edward/models/__init__.py", line 5, in <module>
    from edward.models.dirichlet_process import *
  File "edward/models/dirichlet_process.py", line 7, in <module>
    from edward.models.random_variable import RandomVariable
  File "edward/models/random_variable.py", line 11, in <module>
    raise ImportError("{0}. Your TensorFlow version is not supported.".format(e))
ImportError: cannot import name register_session_run_conversion_functions. Your TensorFlow version is not supported.
>>> print(tf.__version__)
'0.12.0'
>>> import edward as ed
Traceback (most recent call last):
  File "/Users/dvt/.pythonrc", line 11, in <module>
    import edward as ed
  File "edward/__init__.py", line 5, in <module>
    from edward import criticisms
  File "edward/criticisms/__init__.py", line 5, in <module>
    from edward.criticisms.evaluate import *
  File "edward/criticisms/evaluate.py", line 9, in <module>
    from edward.models import RandomVariable
  File "edward/models/__init__.py", line 5, in <module>
    from edward.models.dirichlet_process import *
  File "edward/models/dirichlet_process.py", line 13, in <module>
    raise ImportError("{0}. Your TensorFlow version is not supported.".format(e))
ImportError: First parent class declared for Bernoulli must be Distribution, but saw 'RandomVariable'. Your TensorFlow version is not supported.
>>> print(tf.__version__)  # this is the nightly build, https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=mac-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.0.1-py2-none-any.whl
'1.0.1'
>>> import edward as ed
Traceback (most recent call last):
  File "/Users/dvt/.pythonrc", line 11, in <module>
    import edward as ed
  File "edward/__init__.py", line 6, in <module>
    from edward import inferences
  File "edward/inferences/__init__.py", line 11, in <module>
    from edward.inferences.laplace import *
  File "edward/inferences/laplace.py", line 16, in <module>
    raise ImportError("{0}. Your TensorFlow version is not supported.".format(e))
ImportError: cannot import name MultivariateNormalCholesky. Your TensorFlow version is not supported.

@dustinvtran dustinvtran merged commit c81bf8a into master Mar 21, 2017
@dustinvtran dustinvtran deleted the error/tensorflow-distributions branch March 21, 2017 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant