Skip to content

Commit e8879c1

Browse files
mresoagunapal
andauthored
Create export path if not present (#3331)
Co-authored-by: Ankith Gunapal <[email protected]>
1 parent 9d10087 commit e8879c1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

model-archiver/model_archiver/model_packaging_utils.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
MANIFEST_FILE_NAME = "MANIFEST.json"
4444
MAR_INF = "MAR-INF"
4545

46+
logger = logging.getLogger(__file__)
47+
4648

4749
class ModelExportUtils(object):
4850
"""
@@ -366,7 +368,12 @@ def check_model_name_regex_or_exit(model_name):
366368
@staticmethod
367369
def validate_inputs(model_name, export_path):
368370
ModelExportUtils.check_model_name_regex_or_exit(model_name)
369-
if not os.path.isdir(os.path.abspath(export_path)):
371+
if not os.path.exists(os.path.abspath(export_path)):
372+
logger.warning(
373+
f"Export directory ({export_path}) does not exist. Creating..."
374+
)
375+
os.makedirs(os.path.abspath(export_path))
376+
elif not os.path.isdir(os.path.abspath(export_path)):
370377
raise ModelArchiverError(
371378
"Given export-path {} is not a directory. "
372379
"Point to a valid export-path directory.".format(export_path)

0 commit comments

Comments
 (0)