From ce744642b84be721621643c1acb72eb6c7ffb895 Mon Sep 17 00:00:00 2001 From: Richard Barnes Date: Wed, 27 Mar 2024 08:31:50 -0700 Subject: [PATCH] Fix rstrip bug in publish_model.py `.rstrip(".pth")` will convert `pthhtp.pth` to the empty string. `removesuffix` does the right thing. --- tools/model_converters/publish_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/model_converters/publish_model.py b/tools/model_converters/publish_model.py index e2660578af..de9219dbe0 100644 --- a/tools/model_converters/publish_model.py +++ b/tools/model_converters/publish_model.py @@ -23,7 +23,7 @@ def process_checkpoint(in_file, out_file): # add the code here. torch.save(checkpoint, out_file) sha = subprocess.check_output(['sha256sum', out_file]).decode() - final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8]) + final_file = out_file.removesuffix('.pth') + '-{}.pth'.format(sha[:8]) subprocess.Popen(['mv', out_file, final_file])