Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run keras saving tests on nightly and fix RobertaClassifier test #692

Merged
merged 1 commit into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v1
# TODO: we probably want 3.8 here, but are facing an issue with core
# keras.
with:
python-version: 3.8
python-version: 3.9
- name: Get pip cache dir
id: pip-cache
run: |
Expand Down
3 changes: 2 additions & 1 deletion keras_nlp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ def pytest_collection_modifyitems(config, items):
skip_xla = pytest.mark.skipif(
sys.platform == "darwin", reason="XLA unsupported on MacOS."
)
# Run Keras saving tests on 2.12 stable, nightlies and later releases.
skip_keras_saving_test = pytest.mark.skipif(
version.parse(tf.__version__) < version.parse("2.12"),
version.parse(tf.__version__) < version.parse("2.12.0-dev0"),
reason="keras_v3 format requires tf > 2.12.",
)
skip_large = pytest.mark.skipif(
Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/gpt2/gpt2_causal_lm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ def test_gpt2_causal_lm_generate(self, jit_compile):
("tf_format", "tf", "model"),
("keras_format", "keras_v3", "model.keras"),
)
def test_saving_model(self, save_format, filename):
def test_saved_model(self, save_format, filename):
keras.utils.set_random_seed(42)
model_output = self.causal_lm.predict(self.raw_batch)
save_path = os.path.join(self.get_temp_dir(), filename)
self.causal_lm.save(save_path, save_format)
self.causal_lm.save(save_path, save_format=save_format)
restored_model = keras.models.load_model(save_path)

# Check we got the real object back.
Expand Down
4 changes: 2 additions & 2 deletions keras_nlp/models/roberta/roberta_classifier_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ def test_roberta_classifier_fit_no_preprocessing(self, jit_compile):
("tf_format", "tf", "model"),
("keras_format", "keras_v3", "model.keras"),
)
def test_saving_model(self, save_format, filename):
def test_saved_model(self, save_format, filename):
model_output = self.classifier.predict(self.raw_batch)
save_path = os.path.join(self.get_temp_dir(), filename)
self.classifier.save(save_path, save_format)
self.classifier.save(save_path, save_format=save_format)
restored_model = keras.models.load_model(save_path)

# Check we got the real object back.
Expand Down