From fe7ab6e480aa16708fbdac2b64d476ede4af1ca8 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 28 Oct 2022 11:20:04 -0400 Subject: [PATCH] fix crash in !del_model command --- scripts/invoke.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/invoke.py b/scripts/invoke.py index 671a8ad227..5094473d33 100644 --- a/scripts/invoke.py +++ b/scripts/invoke.py @@ -532,12 +532,8 @@ def del_config(model_name:str, gen, opt, completer): if model_name == current_model: print("** Can't delete active model. !switch to another model first. **") return - yaml_str = gen.model_cache.del_model(model_name) - - tmpfile = os.path.join(os.path.dirname(opt.conf),'new_config.tmp') - with open(tmpfile, 'w') as outfile: - outfile.write(yaml_str) - os.rename(tmpfile,opt.conf) + if gen.model_cache.del_model(model_name): + gen.model_cache.commit(opt.conf) print(f'** {model_name} deleted') completer.del_model(model_name)