From dd96f6bdb29ffcf328119a62760bfb6109bf74a5 Mon Sep 17 00:00:00 2001 From: Sivanantham <90966311+sivanantha321@users.noreply.github.com> Date: Fri, 7 Apr 2023 03:06:47 +0530 Subject: [PATCH] Handle file exist scenario for local storage (#2794) Signed-off-by: Sivanantham Chinnaiyan --- python/kserve/kserve/storage/storage.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/kserve/kserve/storage/storage.py b/python/kserve/kserve/storage/storage.py index 151e7c71bd7..3d1d52608c0 100644 --- a/python/kserve/kserve/storage/storage.py +++ b/python/kserve/kserve/storage/storage.py @@ -486,7 +486,7 @@ def _download_local(uri, out_dir=None): if out_dir is None: return local_path elif not os.path.isdir(out_dir): - os.makedirs(out_dir) + os.makedirs(out_dir, exist_ok=True) if os.path.isdir(local_path): local_path = os.path.join(local_path, "*") @@ -496,7 +496,10 @@ def _download_local(uri, out_dir=None): _, tail = os.path.split(src) dest_path = os.path.join(out_dir, tail) logging.info("Linking: %s to %s", src, dest_path) - os.symlink(src, dest_path) + if not os.path.exists(dest_path): + os.symlink(src, dest_path) + else: + logging.info("File %s already exist", dest_path) count = count + 1 if count == 0: raise RuntimeError(