diff --git a/.github/workflows/quality-check.yaml b/.github/workflows/quality-check.yaml index cd8e1150..5eb7f985 100644 --- a/.github/workflows/quality-check.yaml +++ b/.github/workflows/quality-check.yaml @@ -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"] + 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"] include: - tensorflow: "~=2.5.0" keras: "~=2.6.0" @@ -45,6 +45,9 @@ jobs: - tensorflow: "~=2.11.0" keras: "~=2.11.0" tensorflow-probability: "~=0.19.0" + - tensorflow: "~=2.12.0" + keras: "~=2.12.0" + tensorflow-probability: "~=0.19.0" # sic! no new tfp release exclude: # These older versions of TensorFlow don't work with Python 3.10: - python-version: "3.10" @@ -53,12 +56,16 @@ jobs: tensorflow: "~=2.6.0" - python-version: "3.10" tensorflow: "~=2.7.0" + # These newer versions of TensorFlow don't work with Python 3.7: + - python-version: "3.7" + tensorflow: "~=2.12.0" name: Python-${{ matrix.python-version }} tensorflow${{ matrix.tensorflow }} env: VERSION_TF: ${{ matrix.tensorflow }} VERSION_KERAS: ${{ matrix.keras }} VERSION_TFP: ${{ matrix.tensorflow-probability }} + VERSION_PYTHON: ${{ matrix.python-version }} steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 diff --git a/Makefile b/Makefile index 3fcd1929..e97edbcf 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,13 @@ 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 +ifeq ("$(VERSION_PYTHON)", "3.7") + TEST_REQUIREMENTS = "tests_requirements_37.txt" +else + TEST_REQUIREMENTS = "tests_requirements.txt" +endif + help: ## Shows this help message # $(MAKEFILE_LIST) is set by make itself; the following parses the `target: ## help line` format and adds color highlighting @@ -35,7 +42,7 @@ install: ## Install repo for developement @echo "\n=== pip install package with dev requirements ==============" pip install --upgrade --upgrade-strategy eager \ -r notebook_requirements.txt \ - -r tests_requirements.txt \ + -r $(TEST_REQUIREMENTS) \ tensorflow${VERSION_TF} \ keras${VERSION_KERAS} \ tensorflow-probability${VERSION_TFP} \ diff --git a/gpflux/helpers.py b/gpflux/helpers.py index 45bfc6b6..8ae31505 100644 --- a/gpflux/helpers.py +++ b/gpflux/helpers.py @@ -22,7 +22,7 @@ import inspect import warnings from dataclasses import fields -from typing import List, Optional, Type, TypeVar, Union +from typing import List, Optional, Type, TypeVar, Union, Any import numpy as np @@ -261,7 +261,10 @@ def construct_gp_layer( T = TypeVar("T") -def make_dataclass_from_class(dataclass: Type[T], instance: object, **updates: object) -> T: +# HACK to get mypy to pass, should be (dataclass: Type[T], ...) -> T: +# mypy said: gpflux/helpers.py:271: error: Argument 1 to "fields" has incompatible type "Type[T]"; +# expected "Union[DataclassInstance, Type[DataclassInstance]]" [arg-type] +def make_dataclass_from_class(dataclass: Any, instance: object, **updates: object) -> Any: """ Take a regular object ``instance`` with a superset of fields for a :class:`dataclasses.dataclass` (``@dataclass``-decorated class), and return an diff --git a/gpflux/version.py b/gpflux/version.py index 66227560..58994b15 100644 --- a/gpflux/version.py +++ b/gpflux/version.py @@ -15,4 +15,4 @@ # """Adds __version__""" -__version__ = "0.4.1" +__version__ = "0.4.2" diff --git a/setup.py b/setup.py index a1adc2a3..ce5dcf8b 100644 --- a/setup.py +++ b/setup.py @@ -9,9 +9,9 @@ "gpflow>=2.6.3", "numpy", "scipy", - "tensorflow>=2.5.0,<2.12.0; platform_system!='Darwin' or platform_machine!='arm64'", + "tensorflow>=2.5.0,<2.13.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.12.0; platform_system=='Darwin' and platform_machine=='arm64'", + "tensorflow-macos>=2.5.0,<2.13.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", ] diff --git a/tests/gpflux/test_callbacks.py b/tests/gpflux/test_callbacks.py index 2d2998f2..872d4cca 100644 --- a/tests/gpflux/test_callbacks.py +++ b/tests/gpflux/test_callbacks.py @@ -136,7 +136,8 @@ def test_tensorboard_callback(tmp_path, model_and_loss, data, update_freq): "self_tracked_trackables[3].likelihood.variance", } - if Version(tf.__version__) < Version("2.8"): + tf_version = Version(tf.__version__) + if tf_version < Version("2.8") or tf_version >= Version("2.12"): if update_freq == "batch": expected_tags |= { "batch_loss", diff --git a/tests_requirements.txt b/tests_requirements.txt index 7029f463..9b4e916b 100644 --- a/tests_requirements.txt +++ b/tests_requirements.txt @@ -4,7 +4,7 @@ codecov click==8.0.4 flake8==4.0.1 isort==5.10.1 -mypy==0.921 +mypy pytest pytest-cov pytest-random-order @@ -12,7 +12,7 @@ pytest-mock # For mypy stubs: types-Deprecated -numpy<1.22.0 # Newer versions of numpy are not compatible with Python 3.7. +numpy tqdm diff --git a/tests_requirements_37.txt b/tests_requirements_37.txt new file mode 100644 index 00000000..25679f42 --- /dev/null +++ b/tests_requirements_37.txt @@ -0,0 +1,27 @@ +# Test requirements specific to Python 3.7 + +# Code quality tools: +black==21.7b0 +codecov +click==8.0.4 +flake8==4.0.1 +isort==5.10.1 +mypy +pytest +pytest-cov +pytest-random-order +pytest-mock + +# For mypy stubs: +types-Deprecated +numpy<1.22.0 # Newer versions of numpy are not compatible with Python 3.7. + +tqdm + +# Notebook tests: +jupytext +nbformat +nbconvert +jupyter_client +ipykernel +tornado