From 55396ade5aaa8297ad36e641470fb0ef1fc1a154 Mon Sep 17 00:00:00 2001 From: Samaneh Saadat Date: Mon, 15 Apr 2024 18:23:28 +0000 Subject: [PATCH] Handle cached model missing file exception. --- keras_nlp/utils/preset_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/keras_nlp/utils/preset_utils.py b/keras_nlp/utils/preset_utils.py index 8e2a9c0b38..ff76060dc8 100644 --- a/keras_nlp/utils/preset_utils.py +++ b/keras_nlp/utils/preset_utils.py @@ -120,6 +120,14 @@ def get_file(preset, path): ) else: raise ValueError(message) + except ValueError as e: + message = str(e) + if message.find("is not present in the model files"): + raise FileNotFoundError( + f"`{path}` doesn't exist in preset directory `{preset}`." + ) + else: + raise ValueError(message) elif preset.startswith(GS_PREFIX): url = os.path.join(preset, path)