Skip to content
Merged
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
11 changes: 11 additions & 0 deletions keras_nlp/utils/preset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import re

from absl import logging
from packaging.version import parse

from keras_nlp.api_export import keras_nlp_export
from keras_nlp.backend import config as backend_config
Expand Down Expand Up @@ -437,6 +438,16 @@ def upload_preset(
_validate_tokenizer(preset, allow_incomplete)

if uri.startswith(KAGGLE_PREFIX):
if kagglehub is None:
raise ImportError(
"Uploading a model to Kaggle Hub requires the `kagglehub` package. "
"Please install with `pip install kagglehub`."
)
if parse(kagglehub.__version__) < parse("0.2.1"):
raise ImportError(
"Uploading a model to Kaggle Hub requires the `kagglehub` package version `0.2.1` or higher. "
"Please upgrade with `pip install --upgrade kagglehub`."
)
kaggle_handle = uri.removeprefix(KAGGLE_PREFIX)
kagglehub.model_upload(kaggle_handle, preset)
elif uri.startswith(HF_PREFIX):
Expand Down