From 8541b16166b0fb1a479533db4cd419db5eb4780f Mon Sep 17 00:00:00 2001 From: cofri Date: Wed, 26 Oct 2022 15:16:49 +0200 Subject: [PATCH 1/8] feat: deel-lip only supports TensorFlow >=2.2 Because of bugs in TensorFlow 2.0 and 2.1 when saving/loading custom losses or metrics, these versions are not supported anymore. deel-lip now supports TensorFlow 2.2 and higher. Moreover, we tell pip that Python versions 3.9 and 3.10 are supported. Since Python 3.6 is not maintained anymore, we also removed it from the classifiers. --- setup.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 88e729de..87785467 100644 --- a/setup.py +++ b/setup.py @@ -44,16 +44,17 @@ long_description_content_type="text/markdown", url="https://github.com/deel-ai/deel-lip", packages=setuptools.find_namespace_packages(include=["deel.*"]), - install_requires=["numpy", "tensorflow>=2,<3"], + install_requires=["numpy", "tensorflow~=2.2"], license="MIT", extras_require={"dev": dev_requires, "docs": docs_requires}, classifiers=[ "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], - python_requires=">=3.6", + python_requires=">=3.7", ) From de70addbac27703fdd78c16eb315cd7c6fed736f Mon Sep 17 00:00:00 2001 From: cofri Date: Thu, 29 Sep 2022 11:16:18 +0200 Subject: [PATCH 2/8] feat: different Python and TensorFlow versions in tox tests The tox configuration file is updated to add environments with different Python and TensorFlow versions. This allows to run unit tests with these environments and ensure that the library is stable across Python and TF versions. Note that TensorFlow 2.2 version requires an older version for protobuf package. --- setup.cfg | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 88b3d26b..3b696c66 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,18 +4,27 @@ max-line-length = 88 extend-ignore = # See https://github.com/PyCQA/pycodestyle/issues/373 E203, E231 -per-file-ignores = +per-file-ignores = */__init__.py: F401 [tox:tox] -envlist = py{36,37,38},py{36,37,38}-lint +envlist = py{37,38,39,310}-tf{22,23,24,25,26,27,28,29,latest},py{37,38,39,310}-lint [testenv] deps = + tf22: protobuf == 3.20.3 + tf22: tensorflow ~= 2.2.0 + tf23: tensorflow ~= 2.3.0 + tf24: tensorflow ~= 2.4.0 + tf25: tensorflow ~= 2.5.0 + tf26: tensorflow ~= 2.6.0 + tf27: tensorflow ~= 2.7.0 + tf28: tensorflow ~= 2.8.0 + tf29: tensorflow ~= 2.9.0 commands = python -m unittest -[testenv:py{36,37,38}-lint] +[testenv:py{37,38,39,310}-lint] skip_install = true deps = black From ab3911ae69cdf96c900e03b06f4ecff7d03d096e Mon Sep 17 00:00:00 2001 From: cofri Date: Thu, 27 Oct 2022 11:34:06 +0200 Subject: [PATCH 3/8] fix: test with "gelu" activation only for TensorFlow >= 2.4 Since a unit test uses a Keras gelu activation which was introduced in Tensorflow 2.4, a check is added. --- setup.cfg | 1 + tests/test_models.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 3b696c66..87113135 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,6 +12,7 @@ envlist = py{37,38,39,310}-tf{22,23,24,25,26,27,28,29,latest},py{37,38,39,310}-l [testenv] deps = + packaging tf22: protobuf == 3.20.3 tf22: tensorflow ~= 2.2.0 tf23: tensorflow ~= 2.3.0 diff --git a/tests/test_models.py b/tests/test_models.py index 4dcecf18..674bce8d 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,6 +1,7 @@ """These tests assert that deel.lip Sequential and Model objects behave as expected.""" import warnings +from packaging import version from unittest import TestCase import numpy as np import tensorflow as tf @@ -98,11 +99,13 @@ def test_warning_unsupported_1Lip_layers(self): kl.MaxPool2D(pool_size=3, strides=2), kl.Add(), kl.Concatenate(), - kl.Activation("gelu"), kl.Dense(5), kl.Conv2D(10, 3), kl.UpSampling2D(), ] + if version.parse(tf.__version__) >= version.parse("2.4.0"): + unsupported_layers.append(kl.Activation("gelu")) + for lay in unsupported_layers: with self.assertWarnsRegex( Warning, From fc2df9e152fa2d4ffd48f2d4e922225d526c6d06 Mon Sep 17 00:00:00 2001 From: cofri Date: Wed, 26 Oct 2022 16:06:28 +0200 Subject: [PATCH 4/8] feat: "make test" is updated with TF versions Since the tox configuration file now contains a large number of environments for multiple Python and TensorFlow versions, the targets "make test" and "make test-disable-gpu" now runs only a small subset of the tests. But these tests are representative of the different TF versions. --- CONTRIBUTING.md | 8 +------- Makefile | 10 ++++++++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b52a1954..aa5b7909 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,18 +27,12 @@ Before opening a pull request, please make sure you check your code and you run unit tests: ```bash -# Using make: $ make test - -# Or using directly tox in your development environment: -$ tox ``` This command will: - check your code with black PEP-8 formatter and flake8 linter. -- run `unittest` on the `tests/` folder with Python 3.6, 3.7 and 3.8. -> Note: If you do not have those 3 interpreters, the tests will only be only performed - with your current interpreter. +- run `unittest` on the `tests/` folder with different Python and TensorFlow versions. ## Submitting your changes diff --git a/Makefile b/Makefile index 95fa8365..d1adc7de 100644 --- a/Makefile +++ b/Makefile @@ -22,10 +22,16 @@ prepare-dev: . deel_lip_dev_env/bin/activate && pip install -e .[docs] test: - . deel_lip_dev_env/bin/activate && tox + . deel_lip_dev_env/bin/activate && tox -e py37-tf23 + . deel_lip_dev_env/bin/activate && tox -e py39-tf27 + . deel_lip_dev_env/bin/activate && tox -e py310-tflatest + . deel_lip_dev_env/bin/activate && tox -e py310-lint test-disable-gpu: - . deel_lip_dev_env/bin/activate && CUDA_VISIBLE_DEVICES=-1 tox + . deel_lip_dev_env/bin/activate && CUDA_VISIBLE_DEVICES=-1 tox -e py37-tf23 + . deel_lip_dev_env/bin/activate && CUDA_VISIBLE_DEVICES=-1 tox -e py39-tf27 + . deel_lip_dev_env/bin/activate && CUDA_VISIBLE_DEVICES=-1 tox -e py310-tflatest + . deel_lip_dev_env/bin/activate && CUDA_VISIBLE_DEVICES=-1 tox -e py310-lint doc: . deel_lip_dev_env/bin/activate && cd doc && make html && cd - From ea0b04f05d24300b38c9338e6ac2e12dd5a872df Mon Sep 17 00:00:00 2001 From: cofri Date: Thu, 27 Oct 2022 10:17:09 +0200 Subject: [PATCH 5/8] feat: update versions of Github actions The current versions were deprecated due to an update on Github workflows. The latest versions are now used for actions/checkout and actions/setup-python --- .github/workflows/python-linters.yml | 4 ++-- .github/workflows/python-publish.yml | 4 ++-- .github/workflows/python-tests.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-linters.yml b/.github/workflows/python-linters.yml index 05cf5005..85dafb30 100644 --- a/.github/workflows/python-linters.yml +++ b/.github/workflows/python-linters.yml @@ -11,9 +11,9 @@ jobs: python-version: [3.6, 3.7, 3.8] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 03760727..82ad4abd 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 3f6bbcf4..85ce72e5 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -11,9 +11,9 @@ jobs: python-version: [3.6, 3.7, 3.8] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies From 07751cee147d8acdb23a22d157dd55a740aa5328 Mon Sep 17 00:00:00 2001 From: cofri Date: Thu, 29 Sep 2022 11:16:37 +0200 Subject: [PATCH 6/8] feat: add TensorFlow versions in Github actions The Github workflows for unit testing are extended to test different Python and TensorFlow versions. Three tests are performed on Github CI with the following combinations: - Python 3.7 and TensorFlow 2.3 - Python 3.9 and TensorFlow 2.7 - Python 3.10 and TensorFlow latest (2.10 as of october 2022) --- .github/workflows/python-tests.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 85ce72e5..5ff35f11 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -8,7 +8,13 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.6, 3.7, 3.8] + include: + - python-version: 3.7 + tf-version: 2.3 + - python-version: 3.9 + tf-version: 2.7 + - python-version: "3.10" + tf-version: latest steps: - uses: actions/checkout@v3 @@ -20,5 +26,5 @@ jobs: run: | python -m pip install --upgrade pip pip install tox - - name: Test with tox - run: tox -e py$(echo ${{ matrix.python-version }} | tr -d .) \ No newline at end of file + - name: Test with tox (Python ${{ matrix.python-version }} - TensorFlow ${{ matrix.tf-version }}) + run: tox -e py$(echo ${{ matrix.python-version }}-tf${{ matrix.tf-version }} | tr -d .) From f38b857c9a444f9c7d72a4a0d46c7ce77cab857a Mon Sep 17 00:00:00 2001 From: cofri Date: Thu, 29 Sep 2022 16:34:12 +0200 Subject: [PATCH 7/8] feat: update CI Github workflows The Github workflows for linting and testing are done when: - a pull request is open (and updated) - pushing on master and develop Moreover, the unit tests are also performed: - every Sunday at 2am on master (i.e. the base branch) --- .github/workflows/python-linters.yml | 9 +++++++-- .github/workflows/python-tests.yml | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-linters.yml b/.github/workflows/python-linters.yml index 85dafb30..d18ad3b4 100644 --- a/.github/workflows/python-linters.yml +++ b/.github/workflows/python-linters.yml @@ -1,6 +1,11 @@ name: deel-lip linters -on: [push, pull_request] +on: + push: + branches: + - master + - develop + pull_request: jobs: checks: @@ -8,7 +13,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.6, 3.7, 3.8] + python-version: [3.7, "3.10"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 5ff35f11..7f4f5fb6 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1,6 +1,13 @@ name: deel-lip tests -on: [push, pull_request] +on: + push: + branches: + - master + - develop + pull_request: + schedule: + - cron: "0 2 * * 0" # Run tests every Sunday at 2am jobs: checks: From 341bae22f85c856e169c6123b0798cb7f6c7bf48 Mon Sep 17 00:00:00 2001 From: cofri Date: Wed, 26 Oct 2022 15:17:02 +0200 Subject: [PATCH 8/8] chore: VERSION file to have it at a single place The aim of this commit is to have the package version at a single place, and not across multiple files. The VERSION file contains the version number. It is now the only place where it is set. The setup.py and the Sphinx conf.py read this file. It is now possible to get the version number directly from the package: import deel.lip print(deel.lip.__version__) Note that to add non-Python files to the sdist package, it is required to add `include_package_data=True` in setup.py and a MANIFEST.in file containing the non-Python files to add in package. --- MANIFEST.in | 2 ++ deel/lip/VERSION | 1 + deel/lip/__init__.py | 6 ++++++ doc/source/conf.py | 6 ++++-- setup.py | 6 +++++- 5 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 MANIFEST.in create mode 100644 deel/lip/VERSION diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..86a41807 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include deel/lip/VERSION +include LICENSE diff --git a/deel/lip/VERSION b/deel/lip/VERSION new file mode 100644 index 00000000..f0bb29e7 --- /dev/null +++ b/deel/lip/VERSION @@ -0,0 +1 @@ +1.3.0 diff --git a/deel/lip/__init__.py b/deel/lip/__init__.py index aea6c3bd..df211cb2 100644 --- a/deel/lip/__init__.py +++ b/deel/lip/__init__.py @@ -2,6 +2,12 @@ # rights reserved. DEEL is a research program operated by IVADO, IRT Saint Exupéry, # CRIAQ and ANITI - https://www.deel.ai/ # ===================================================================================== + +from os import path + +with open(path.join(path.dirname(__file__), "VERSION")) as f: + __version__ = f.read().strip() + from . import activations from . import callbacks from . import constraints diff --git a/doc/source/conf.py b/doc/source/conf.py index eeef0cd4..46000190 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -14,7 +14,8 @@ # import sys # sys.path.insert(0, os.path.abspath('.')) # import guzzle_sphinx_theme -import sphinx_rtd_theme +# import sphinx_rtd_theme +from deel.lip import __version__ # -- Project information ----------------------------------------------------- @@ -31,7 +32,8 @@ ) # The full version, including alpha/beta/rc tags -release = "1.3.0" +version = __version__ +release = version # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index 87785467..8ffbb484 100644 --- a/setup.py +++ b/setup.py @@ -11,6 +11,9 @@ with open(path.join(this_directory, "README.md"), encoding="utf-8") as f: long_description = f.read() +with open(path.join(this_directory, "deel/lip/VERSION")) as f: + version = f.read().strip() + dev_requires = [ "tox", "black", @@ -30,7 +33,7 @@ setuptools.setup( name="deel-lip", - version="1.3.0", + version=version, author=", ".join(["Mathieu SERRURIER", "Franck MAMALET", "Thibaut BOISSIN"]), author_email=", ".join( [ @@ -44,6 +47,7 @@ long_description_content_type="text/markdown", url="https://github.com/deel-ai/deel-lip", packages=setuptools.find_namespace_packages(include=["deel.*"]), + include_package_data=True, install_requires=["numpy", "tensorflow~=2.2"], license="MIT", extras_require={"dev": dev_requires, "docs": docs_requires},