|
2 | 2 | Helper utils for Model Export tool
|
3 | 3 | """
|
4 | 4 |
|
| 5 | +import glob |
5 | 6 | import logging
|
6 | 7 | import os
|
7 | 8 | import re
|
@@ -156,20 +157,20 @@ def copy_artifacts(model_name, **kwargs):
|
156 | 157 | path = (path.split(":")[0] if ":" in path else path) + ".py"
|
157 | 158 |
|
158 | 159 | if file_type == "extra_files":
|
159 |
| - for file in path.split(","): |
160 |
| - file = file.strip() |
161 |
| - if os.path.isfile(file): |
162 |
| - shutil.copy2(file, model_path) |
163 |
| - elif os.path.isdir(file) and file != model_path: |
164 |
| - for item in os.listdir(file): |
165 |
| - src = os.path.join(file, item) |
166 |
| - dst = os.path.join(model_path, item) |
167 |
| - if os.path.isfile(src): |
168 |
| - shutil.copy2(src, dst) |
169 |
| - elif os.path.isdir(src): |
170 |
| - shutil.copytree(src, dst, False, None) |
171 |
| - else: |
172 |
| - raise ValueError(f"Invalid extra file given {file}") |
| 160 | + for path_or_wildcard in path.split(","): |
| 161 | + for file in glob.glob(path_or_wildcard.strip()): |
| 162 | + if os.path.isfile(file): |
| 163 | + shutil.copy2(file, model_path) |
| 164 | + elif os.path.isdir(file) and file != model_path: |
| 165 | + for item in os.listdir(file): |
| 166 | + src = os.path.join(file, item) |
| 167 | + dst = os.path.join(model_path, item) |
| 168 | + if os.path.isfile(src): |
| 169 | + shutil.copy2(src, dst) |
| 170 | + elif os.path.isdir(src): |
| 171 | + shutil.copytree(src, dst, False, None) |
| 172 | + else: |
| 173 | + raise ValueError(f"Invalid extra file given {file}") |
173 | 174 | else:
|
174 | 175 | shutil.copy(path, model_path)
|
175 | 176 |
|
|
0 commit comments