Skip to content

Commit

Permalink
Remove tensorflow as dependency (#860)
Browse files Browse the repository at this point in the history
* Removed tensorflow as a dependency.

* Moved the check in a function.

* Added packaging as a dependency.

* Formatted the message better.

* Install tensorflow in the CI.

* Fixed the version number in the CI

* Update setup.py

* Update .travis.yml

Co-authored-by: Haifeng Jin <[email protected]>
  • Loading branch information
gabrieldemarmiesse and haifeng-jin committed Dec 28, 2019
1 parent 9b257a1 commit e3f9bfc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions autokeras/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@
from autokeras.task import StructuredDataRegressor
from autokeras.task import TextClassifier
from autokeras.task import TextRegressor

from .utils import check_tf_version
check_tf_version()
14 changes: 14 additions & 0 deletions autokeras/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pickle
import re
from packaging.version import parse

import numpy as np
import tensorflow as tf
Expand Down Expand Up @@ -127,3 +128,16 @@ def to_type_key(dictionary, convert_func):
"""
return {convert_func(key): value
for key, value in dictionary.items()}


def check_tf_version():
if parse(tf.__version__) < parse('2.0.0'):
raise ImportError(
f'The Tensorflow package version needs to be at least v2.0.0 \n'
f'for AutoKeras to run. Currently, your TensorFlow version is \n'
f'v{tf.__version__}. Please upgrade with \n'
f'`$ pip install --upgrade tensorflow` -> GPU version \n'
f'or \n'
f'`$ pip install --upgrade tensorflow-cpu` -> CPU version. \n'
f'You can use `pip freeze` to check afterwards that everything is ok.'
)
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
url='http://autokeras.com',
download_url='https://github.com/keras-team/autokeras/archive/1.0.0b0.tar.gz',
keywords=['AutoML', 'keras'],
# TODO: Do not install tensorflow if tensorflow-gpu is installed.
install_requires=[
'tensorflow>=2.0.0',
'packaging',
'keras-tuner>=1.0.0',
'scikit-learn',
'numpy',
Expand Down

0 comments on commit e3f9bfc

Please sign in to comment.