diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 55a51758c..d4aca5d16 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -34,6 +34,33 @@ jobs: pytest --cov=keras_tuner --cov-report xml:coverage.xml - name: Codecov uses: codecov/codecov-action@v3 + compatibility: + name: Check compatibility with TF 2.0 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.7 + uses: actions/setup-python@v4 + with: + python-version: '3.7' + - name: Get pip cache dir + id: pip-cache + run: | + python -m pip install --upgrade pip setuptools + echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT + - name: pip cache + uses: actions/cache@v3 + with: + path: ${{ steps.pip-cache.outputs.dir }} + key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }} + - name: Install dependencies + run: | + pip install protobuf==3.20.1 + pip install "tensorflow<2.1" + pip install -e ".[tensorflow-cpu,tests]" --progress-bar off --upgrade + - name: Test with pytest + run: | + pytest keras_tuner/integration_tests/legacy_import_test.py format: name: Check the code format runs-on: ubuntu-latest @@ -84,7 +111,7 @@ jobs: - name: Run the guides run: bash shell/run_guides.sh deploy: - needs: [build, format] + needs: [build, format,compatibility] if: github.event_name == 'release' && github.event.action == 'created' runs-on: ubuntu-latest steps: diff --git a/RELEASE.md b/RELEASE.md index ff844e6ff..f8b1280b6 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -5,8 +5,6 @@ to install TensorFlow either separately with KerasTuner or with `pip install keras_tuner[tensorflow]`. This change is because some people may want to use KerasTuner with `tensorflow-cpu` instead of `tensorflow`. -* Remove the legacy import name of `kerastuner`. From now on, only - `import keras_tuner` is supported. ## Bug fixes * KerasTuner used to require protobuf version to be under 3.20. The limit is diff --git a/keras_tuner/integration_tests/legacy_import_test.py b/keras_tuner/integration_tests/legacy_import_test.py new file mode 100644 index 000000000..5c988c383 --- /dev/null +++ b/keras_tuner/integration_tests/legacy_import_test.py @@ -0,0 +1,53 @@ +# Copyright 2019 The KerasTuner Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + + +def test_kerastuner_same_as_keras_tuner(): + with pytest.deprecated_call(): + import kerastuner + from kerastuner.tuners import RandomSearch # noqa: F401 + from kerastuner.tuners import BayesianOptimization # noqa: F401 + from kerastuner.tuners import Hyperband # noqa: F401 + from kerastuner.engine.base_tuner import BaseTuner # noqa: F401 + from kerastuner.engine.conditions import Condition # noqa: F401 + from kerastuner.engine.hypermodel import HyperModel # noqa: F401 + from kerastuner.engine.hyperparameters import ( # noqa: F401 + HyperParameter, + ) + from kerastuner.engine.hyperparameters import ( # noqa: F401 + HyperParameters, + ) + from kerastuner.engine.metrics_tracking import ( # noqa: F401 + MetricObservation, + ) + from kerastuner import Objective # noqa: F401 + from kerastuner.engine.oracle import Oracle # noqa: F401 + from kerastuner.engine.tuner import Tuner # noqa: F401 + from kerastuner.engine.stateful import Stateful # noqa: F401 + from kerastuner.engine.trial import Trial # noqa: F401 + from kerastuner.engine.multi_execution_tuner import ( # noqa: F401 + MultiExecutionTuner, + ) + from kerastuner.applications import HyperResNet # noqa: F401 + from kerastuner.applications import HyperXception # noqa: F401 + + import keras_tuner + + attr1 = [attr for attr in dir(kerastuner) if not attr.startswith("__")] + attr2 = [attr for attr in dir(keras_tuner) if not attr.startswith("__")] + + assert len(attr1) > 20 + assert set(attr1) >= set(attr2) diff --git a/setup.py b/setup.py index efc487cf5..e7bd6316f 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ install_requires=[ "packaging", "requests", + "kt-legacy", ], extras_require={ "tensorflow": [