Skip to content

Commit

Permalink
Handle file exist scenario for local storage (kubeflow#2794)
Browse files Browse the repository at this point in the history
Signed-off-by: Sivanantham Chinnaiyan <sivanantham.chinnaiyan@ideas2it.com>
  • Loading branch information
sivanantha321 authored Apr 6, 2023
1 parent 0a72c19 commit dd96f6b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/kserve/kserve/storage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "*")
Expand All @@ -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(
Expand Down

0 comments on commit dd96f6b

Please sign in to comment.