Skip to content

Commit 5e8c44a

Browse files
committed
Run keras saving tests on nightly and fix RobertaClassifier test (#692)
Because of our version comparisons we were not actually running keras saving on nightly CI. This was masking a separate bug where we were not passing `save_format` as a kwarg to `model.save` in the roberta classifier test.
1 parent dec9614 commit 5e8c44a

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

.github/workflows/nightly.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15-
- name: Set up Python 3.8
15+
- name: Set up Python 3.9
1616
uses: actions/setup-python@v1
17+
# TODO: we probably want 3.8 here, but are facing an issue with core
18+
# keras.
1719
with:
18-
python-version: 3.8
20+
python-version: 3.9
1921
- name: Get pip cache dir
2022
id: pip-cache
2123
run: |

keras_nlp/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def pytest_collection_modifyitems(config, items):
5252
skip_xla = pytest.mark.skipif(
5353
sys.platform == "darwin", reason="XLA unsupported on MacOS."
5454
)
55+
# Run Keras saving tests on 2.12 stable, nightlies and later releases.
5556
skip_keras_saving_test = pytest.mark.skipif(
56-
version.parse(tf.__version__) < version.parse("2.12"),
57+
version.parse(tf.__version__) < version.parse("2.12.0-dev0"),
5758
reason="keras_v3 format requires tf > 2.12.",
5859
)
5960
skip_large = pytest.mark.skipif(

keras_nlp/models/roberta/roberta_classifier_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ def test_roberta_classifier_fit_no_preprocessing(self, jit_compile):
125125
("tf_format", "tf", "model"),
126126
("keras_format", "keras_v3", "model.keras"),
127127
)
128-
def test_saving_model(self, save_format, filename):
128+
def test_saved_model(self, save_format, filename):
129129
model_output = self.classifier.predict(self.raw_batch)
130130
save_path = os.path.join(self.get_temp_dir(), filename)
131-
self.classifier.save(save_path, save_format)
131+
self.classifier.save(save_path, save_format=save_format)
132132
restored_model = keras.models.load_model(save_path)
133133

134134
# Check we got the real object back.

0 commit comments

Comments
 (0)