From a0203d26324d5c2de114fc09f5e718c60e9eb8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Wed, 18 Oct 2023 13:40:00 +0200 Subject: [PATCH] utils: prevent convert.py from erroring out `TextGeneration.__del__` is called while the interpreter is closing, resulting in an harmless `TypeError: 'NoneType' object is not callable` while finalizing `TextGeneration`. Having `model` in `main`'s scope prevents this from happening. --- utils/convert.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/utils/convert.py b/utils/convert.py index 89ffad76..79b622a3 100755 --- a/utils/convert.py +++ b/utils/convert.py @@ -3,12 +3,18 @@ import caikit_nlp import argparse -parser = argparse.ArgumentParser(prog="convert.py") -parser.add_argument("--model-path", help="Path of the base HuggingFace model", ) -parser.add_argument("--model-save-path", help="Path to save the Caikit format model to") -args = parser.parse_args() +def main(): + parser = argparse.ArgumentParser(prog="convert.py") + parser.add_argument("--model-path", help="Path of the base HuggingFace model", ) + parser.add_argument("--model-save-path", help="Path to save the Caikit format model to") -model = caikit_nlp.text_generation.TextGeneration.bootstrap(args.model_path) + args = parser.parse_args() -model.save(model_path=args.model_save_path) \ No newline at end of file + model = caikit_nlp.text_generation.TextGeneration.bootstrap(args.model_path) + + model.save(model_path=args.model_save_path) + + +if __name__ == "__main__": + main()