Skip to content

Commit

Permalink
Support TF 2.15 (#101)
Browse files Browse the repository at this point in the history
* Add TF=2.15 and TFP=0.23

* Exclude TF 2.15 with python 3.8

* Use older mypy version with python 3.7

* Use older mypy for py 37, 38, 39

* Exclude TF 2.15 with python 3.9

* Revert "Exclude TF 2.15 with python 3.9"

This reverts commit f9d95b5.

* Revert "Use older mypy for py 37, 38, 39"

This reverts commit 3e4f98c.

* Separate requirements for python 3.8

* Include python 3.9 in new requirements file

* Fix test by using sets directly with id

Behavior of tensorflow ObjectIdentitySet has change in 2.15,
resulting in the set equality comparing wrappers instead of
wrapped values. See tensorflow/tensorflow@bc28335.

* Also include intermediate TF versions

* Add exclude

* Add exclude

* Fix tfp versions
  • Loading branch information
khurram-ghani committed Jan 8, 2024
1 parent 47ed46a commit 83dafb0
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 14 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/quality-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
tensorflow: ["~=2.5.0", "~=2.6.0", "~=2.7.0", "~=2.8.0", "~=2.9.0", "~=2.10.0", "~=2.11.0", "~=2.12.0"]
tensorflow: ["~=2.5.0", "~=2.6.0", "~=2.7.0", "~=2.8.0", "~=2.9.0", "~=2.10.0", "~=2.11.0", "~=2.12.0", "~=2.13.0", "~=2.14.0", "~=2.15.0"]
include:
- tensorflow: "~=2.5.0"
keras: "~=2.6.0"
Expand All @@ -47,7 +47,16 @@ jobs:
tensorflow-probability: "~=0.19.0"
- tensorflow: "~=2.12.0"
keras: "~=2.12.0"
tensorflow-probability: "~=0.19.0" # sic! no new tfp release
tensorflow-probability: "~=0.20.0"
- tensorflow: "~=2.13.0"
keras: "~=2.13.0"
tensorflow-probability: "~=0.21.0"
- tensorflow: "~=2.14.0"
keras: "~=2.14.0"
tensorflow-probability: "~=0.22.0"
- tensorflow: "~=2.15.0"
keras: "~=2.15.0"
tensorflow-probability: "~=0.23.0"
exclude:
# These older versions of TensorFlow don't work with Python 3.10:
- python-version: "3.10"
Expand All @@ -59,6 +68,17 @@ jobs:
# These newer versions of TensorFlow don't work with Python 3.7:
- python-version: "3.7"
tensorflow: "~=2.12.0"
- python-version: "3.7"
tensorflow: "~=2.13.0"
- python-version: "3.7"
tensorflow: "~=2.14.0"
- python-version: "3.7"
tensorflow: "~=2.15.0"
# These newer versions of TensorFlow don't work with Python 3.8:
- python-version: "3.8"
tensorflow: "~=2.14.0"
- python-version: "3.8"
tensorflow: "~=2.15.0"

name: Python-${{ matrix.python-version }} tensorflow${{ matrix.tensorflow }}
env:
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Because GitHub's [graph of contributors](http://github.com/secondmind-labs/GPflu
[Jesper Nielsen](https://github.com/jesnie)
[Sebastian Ober](https://github.com/sebastianober)
[Simon Chiu](https://github.com/sc336)
[Khurram Ghani](https://github.com/khurram-ghani)

4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ LINT_FILE_IGNORES = "$(LIB_NAME)/__init__.py:F401,F403 \
$(LIB_NAME)/sampling/__init__.py:F401 \
$(LIB_NAME)/utils/__init__.py:F401"

# Python 3.7 uses a separate test requirements file
# Older Python versions use separate test requirements files
ifeq ("$(VERSION_PYTHON)", "3.7")
TEST_REQUIREMENTS = "tests_requirements_37.txt"
else ifeq ($(filter $(VERSION_PYTHON),3.8 3.9),$(VERSION_PYTHON))
TEST_REQUIREMENTS = "tests_requirements_38_39.txt"
else
TEST_REQUIREMENTS = "tests_requirements.txt"
endif
Expand Down
2 changes: 1 addition & 1 deletion gpflux/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
#
"""Adds __version__"""

__version__ = "0.4.2"
__version__ = "0.4.3"
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"gpflow>=2.6.3",
"numpy",
"scipy",
"tensorflow>=2.5.0,<2.13.0; platform_system!='Darwin' or platform_machine!='arm64'",
"tensorflow>=2.5.0,<=2.15.0; platform_system!='Darwin' or platform_machine!='arm64'",
# NOTE: Support of Apple Silicon MacOS platforms is in an experimental mode
"tensorflow-macos>=2.5.0,<2.13.0; platform_system=='Darwin' and platform_machine=='arm64'",
"tensorflow-macos>=2.5.0,<=2.15.0; platform_system=='Darwin' and platform_machine=='arm64'",
# NOTE: once we require tensorflow-probability>=0.12, we can remove our custom deepcopy handling
"tensorflow-probability>=0.13.0,<0.20.0",
"tensorflow-probability>=0.13.0,<=0.23.0",
]

with open("README.md", "r") as file:
Expand Down
10 changes: 4 additions & 6 deletions tests/gpflux/layers/test_dedup_trackable_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import pytest
import tensorflow as tf
from tensorflow.python.ops.resource_variable_ops import ResourceVariable
from tensorflow.python.util import object_identity

import gpflow
from gpflow.utilities import parameter_dict
Expand Down Expand Up @@ -141,11 +140,10 @@ def test_weights_equals_deduplicated_parameter_dict(model):
# We filter out the parameters of type ResourceVariable.
# They have been added to the model by the `add_metric` call in the layer.
parameters = [p for p in parameter_dict(model).values() if not isinstance(p, ResourceVariable)]
variables = map(lambda p: p.unconstrained_variable, parameters)
deduplicate_variables = object_identity.ObjectIdentitySet(variables)
variables = {id(p.unconstrained_variable) for p in parameters}

weights = model.trainable_weights
assert len(weights) == len(deduplicate_variables)
assert len(weights) == len(variables)

weights_set = object_identity.ObjectIdentitySet(weights)
assert weights_set == deduplicate_variables
weights_set = {id(w) for w in weights}
assert weights_set == variables
2 changes: 1 addition & 1 deletion tests_requirements_37.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ codecov
click==8.0.4
flake8==4.0.1
isort==5.10.1
mypy
mypy<1.4.0 # Newer mypy versions cause issues with Python 3.7 ('Self' from 'typing_extensions').
pytest
pytest-cov
pytest-random-order
Expand Down
27 changes: 27 additions & 0 deletions tests_requirements_38_39.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Test requirements specific to Python 3.8 and 3.9

# Code quality tools:
black==21.7b0
codecov
click==8.0.4
flake8==4.0.1
isort==5.10.1
mypy<1.4.0 # Newer mypy versions cause issues with older Python ('Self' from 'typing_extensions').
pytest
pytest-cov
pytest-random-order
pytest-mock

# For mypy stubs:
types-Deprecated
numpy

tqdm

# Notebook tests:
jupytext
nbformat
nbconvert
jupyter_client
ipykernel
tornado

0 comments on commit 83dafb0

Please sign in to comment.