Skip to content

Commit

Permalink
Remove hard dependency on TensorFlow (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb authored Aug 2, 2021
1 parent 7c072fb commit cd845db
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ jobs:
- name: Install Dependencies
run: |
poetry remove tensorflow
poetry remove scikit-learn
poetry install
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ version = "0.3.3"
importlib-metadata = {version = "^3", python = "<3.8"}
python = ">=3.6.1,<4.0"
scikit-learn = ">=0.22.0"
tensorflow = ">=2.4.0"

[tool.poetry.dev-dependencies]
tensorflow = ">=2.4.0"
coverage = {extras = ["toml"], version = ">=5.4"}
dataclasses = {version = "^0.8", python = "<3.7"}
insipid-sphinx-theme = ">=0.2.2"
Expand Down
15 changes: 15 additions & 0 deletions scikeras/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@

__version__ = importlib_metadata.version("scikeras")


MIN_TF_VERSION = "2.4.0"
TF_VERSION_ERR = f"SciKeras requires TensorFlow >= {MIN_TF_VERSION}."

from packaging import version


try:
from tensorflow import __version__ as tf_version
except ImportError: # pragma: no cover
raise ImportError("TensorFlow is not installed. " + TF_VERSION_ERR)
else:
if version.parse(tf_version) < version.parse(MIN_TF_VERSION): # pragma: no cover
raise ImportError(TF_VERSION_ERR)

from tensorflow import keras as _keras

from scikeras import _saving_utils
Expand Down

0 comments on commit cd845db

Please sign in to comment.