From 4162f7cee4294946df792c21b5bcf813c9ce6d70 Mon Sep 17 00:00:00 2001 From: Samaneh Saadat Date: Tue, 23 Apr 2024 18:51:51 +0000 Subject: [PATCH] Parse version. --- keras_nlp/utils/preset_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/keras_nlp/utils/preset_utils.py b/keras_nlp/utils/preset_utils.py index 5f9a5dca38..f328d7122e 100644 --- a/keras_nlp/utils/preset_utils.py +++ b/keras_nlp/utils/preset_utils.py @@ -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 @@ -442,10 +443,10 @@ def upload_preset( "Uploading a model to Kaggle Hub requires the `kagglehub` package. " "Please install with `pip install kagglehub`." ) - if kagglehub.__version__ < "0.2.1": + 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 `kagglehub` with `pip install --upgrade kagglehub`." + "Please upgrade with `pip install --upgrade kagglehub`." ) kaggle_handle = uri.removeprefix(KAGGLE_PREFIX) kagglehub.model_upload(kaggle_handle, preset)