Skip to content

Commit

Permalink
[djl-converter] Exit with error if convert model failed (#3399)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfliu authored Aug 8, 2024
1 parent 135fc56 commit c4baffb
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main():

if os.listdir(output_dir):
logging.error(f"output directory: {output_dir} is not empty.")
return
return False

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

converter = SUPPORTED_TASKS[task]

Expand All @@ -75,12 +75,16 @@ def main():
output_dir, False)
if result:
logging.info(f"Convert model {model_info.modelId} finished.")
return True
else:
logging.error(f"{model_info.modelId}: {reason}")
except Exception as e:
logging.warning(f"Failed to convert model: {model_info.modelId}.")
logging.warning(e, exc_info=True)

return False


if __name__ == "__main__":
main()
if not main():
sys.exit(1)

0 comments on commit c4baffb

Please sign in to comment.