Skip to content

Commit

Permalink
Merge branch 'master' into msaroufim/fixk8deadlink
Browse files Browse the repository at this point in the history
  • Loading branch information
mreso committed Feb 27, 2023
2 parents 961ddf2 + b05c0ea commit 15303a8
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions model-archiver/model_archiver/model_packaging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Helper utils for Model Export tool
"""

import glob
import logging
import os
import re
Expand Down Expand Up @@ -156,20 +157,20 @@ def copy_artifacts(model_name, **kwargs):
path = (path.split(":")[0] if ":" in path else path) + ".py"

if file_type == "extra_files":
for file in path.split(","):
file = file.strip()
if os.path.isfile(file):
shutil.copy2(file, model_path)
elif os.path.isdir(file) and file != model_path:
for item in os.listdir(file):
src = os.path.join(file, item)
dst = os.path.join(model_path, item)
if os.path.isfile(src):
shutil.copy2(src, dst)
elif os.path.isdir(src):
shutil.copytree(src, dst, False, None)
else:
raise ValueError(f"Invalid extra file given {file}")
for path_or_wildcard in path.split(","):
for file in glob.glob(path_or_wildcard.strip()):
if os.path.isfile(file):
shutil.copy2(file, model_path)
elif os.path.isdir(file) and file != model_path:
for item in os.listdir(file):
src = os.path.join(file, item)
dst = os.path.join(model_path, item)
if os.path.isfile(src):
shutil.copy2(src, dst)
elif os.path.isdir(src):
shutil.copytree(src, dst, False, None)
else:
raise ValueError(f"Invalid extra file given {file}")
else:
shutil.copy(path, model_path)

Expand Down

0 comments on commit 15303a8

Please sign in to comment.