Skip to content

Commit d6ea6e7

Browse files
authored
Fix wild card in extra files (#3304)
1 parent 87c9823 commit d6ea6e7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

model-archiver/model_archiver/model_packaging_utils.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,21 @@ def copy_artifacts(model_name, runtime, **kwargs):
183183

184184
if file_type == "extra_files":
185185
for path_or_wildcard in path.split(","):
186-
if not Path(path_or_wildcard).exists():
186+
maybe_wildcard = "*" in path_or_wildcard
187+
maybe_wildcard |= "?" in path_or_wildcard
188+
maybe_wildcard |= (
189+
"[" in path_or_wildcard and "]" in path_or_wildcard
190+
)
191+
if not (maybe_wildcard or Path(path_or_wildcard).exists()):
187192
raise FileNotFoundError(
188193
f"File does not exist: {path_or_wildcard}"
189194
)
190-
for file in glob.glob(path_or_wildcard.strip()):
195+
files = glob.glob(path_or_wildcard.strip())
196+
if maybe_wildcard and len(files) == 0:
197+
logging.warning(
198+
f"Given wildcard pattern did not match any file: {path_or_wildcard}"
199+
)
200+
for file in files:
191201
if os.path.isfile(file):
192202
shutil.copy2(file, model_path)
193203
elif os.path.isdir(file) and file != model_path:

0 commit comments

Comments
 (0)