Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamanehSaadat committed Mar 25, 2024
1 parent ca2992c commit b378d27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion keras_nlp/tokenizers/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from keras_nlp.layers.preprocessing.preprocessing_layer import (
PreprocessingLayer,
)
from keras_nlp.utils.preset_utils import TOKENIZER_CONFIG_FILE
from keras_nlp.utils.preset_utils import save_to_preset


Expand Down Expand Up @@ -128,7 +129,7 @@ def save_to_preset(self, preset):
Args:
preset: The path to the local model preset directory.
"""
save_to_preset(self, preset, config_filename="tokenizer.json")
save_to_preset(self, preset, config_filename=TOKENIZER_CONFIG_FILE)

def call(self, inputs, *args, training=None, **kwargs):
return self.tokenize(inputs, *args, **kwargs)
10 changes: 5 additions & 5 deletions keras_nlp/utils/preset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ def _validate_tokenizer(preset, allow_incomplete=False):
if not os.path.exists(config_path):
if allow_incomplete:
logging.warning(
f"`tokenizer.json` is missing from the preset directory `{preset}`."
f"`{TOKENIZER_CONFIG_FILE}` is missing from the preset directory `{preset}`."
)
return
else:
raise FileNotFoundError(
f"`tokenizer.json` is missing from the preset directory `{preset}`. "
"If you wish to upload the model without a tokenizer, "
f"`{TOKENIZER_CONFIG_FILE}` is missing from the preset directory `{preset}`. "
"To upload the model without a tokenizer, "
"set `allow_incomplete=True`."
)
try:
Expand Down Expand Up @@ -208,7 +208,7 @@ def _validate_backbone(preset):
config_path = os.path.join(preset, CONFIG_FILE)
if not os.path.exists(config_path):
raise FileNotFoundError(
f"`config.json` is missing from the preset directory `{preset}`."
f"`{CONFIG_FILE}` is missing from the preset directory `{preset}`."
)
try:
with open(config_path) as config_file:
Expand All @@ -227,7 +227,7 @@ def _validate_backbone(preset):
)
else:
raise ValueError(
"No weights listed in `config.json`. Make sure to use "
f"No weights listed in `{CONFIG_FILE}`. Make sure to use "
"`save_to_preset()` which adds additional data to a serialized "
"Keras object."
)
Expand Down

0 comments on commit b378d27

Please sign in to comment.