Skip to content

Commit c4baffb

Browse files
authored
[djl-converter] Exit with error if convert model failed (#3399)
1 parent 135fc56 commit c4baffb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

extensions/tokenizers/src/main/python/djl_converter/model_converter.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def main():
4343

4444
if os.listdir(output_dir):
4545
logging.error(f"output directory: {output_dir} is not empty.")
46-
return
46+
return False
4747

4848
if os.path.exists(args.model_id):
4949
logging.info(f"converting local model: {args.model_id}")
@@ -66,7 +66,7 @@ def main():
6666
if not task:
6767
logging.error(
6868
f"Unsupported model architecture: {arch} for {args.model_id}.")
69-
return
69+
return False
7070

7171
converter = SUPPORTED_TASKS[task]
7272

@@ -75,12 +75,16 @@ def main():
7575
output_dir, False)
7676
if result:
7777
logging.info(f"Convert model {model_info.modelId} finished.")
78+
return True
7879
else:
7980
logging.error(f"{model_info.modelId}: {reason}")
8081
except Exception as e:
8182
logging.warning(f"Failed to convert model: {model_info.modelId}.")
8283
logging.warning(e, exc_info=True)
8384

85+
return False
86+
8487

8588
if __name__ == "__main__":
86-
main()
89+
if not main():
90+
sys.exit(1)

0 commit comments

Comments
 (0)