Skip to content

Commit

Permalink
add back kt-legacy for import kerastuner (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
haifeng-jin authored Apr 13, 2023
1 parent 5cec63f commit afe25e6
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 3 deletions.
29 changes: 28 additions & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions keras_tuner/integration_tests/legacy_import_test.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
install_requires=[
"packaging",
"requests",
"kt-legacy",
],
extras_require={
"tensorflow": [
Expand Down

0 comments on commit afe25e6

Please sign in to comment.