Skip to content

Commit 023b880

Browse files
authored
convert-hf : print output file name when completed (#8181)
* convert-hf : print output file name when completed This commit adds the output file name to the log message when the conversion is completed. The motivation for this change is that when `--outfile` option is not specified it migth not be obvious where the output file is written. With this change the output of running the script will be something like the following: ```console INFO:hf-to-gguf:Model successfully exported to models/gemma-2-9b-it.gguf. ``` Signed-off-by: Daniel Bevenius <[email protected]> * squash! convert-hf : print output file name when completed Updates the output of to support printing the directory if the output is split into multiple files. Also the output file name is now retrieved from the model_instance object. Signed-off-by: Daniel Bevenius <[email protected]> * squash! convert-hf : print output file name when completed Use parent attribute of Path object and string interpolation. Signed-off-by: Daniel Bevenius <[email protected]> * squash! convert-hf : print output file name when completed Use os.sep instead of hardcoding the path separator. Signed-off-by: Daniel Bevenius <[email protected]> --------- Signed-off-by: Daniel Bevenius <[email protected]>
1 parent 0e0590a commit 023b880

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

convert-hf-to-gguf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,8 @@ def main() -> None:
31203120
"auto": gguf.LlamaFileType.GUESSED,
31213121
}
31223122

3123-
if args.use_temp_file and (args.split_max_tensors > 0 or args.split_max_size != "0"):
3123+
is_split = args.split_max_tensors > 0 or args.split_max_size != "0"
3124+
if args.use_temp_file and is_split:
31243125
logger.error("Error: Cannot use temp file when splitting")
31253126
sys.exit(1)
31263127

@@ -3157,11 +3158,12 @@ def main() -> None:
31573158
if args.vocab_only:
31583159
logger.info("Exporting model vocab...")
31593160
model_instance.write_vocab()
3160-
logger.info("Model vocab successfully exported.")
3161+
logger.info(f"Model vocab successfully exported to {model_instance.fname_out}")
31613162
else:
31623163
logger.info("Exporting model...")
31633164
model_instance.write()
3164-
logger.info("Model successfully exported.")
3165+
out_path = f"{model_instance.fname_out.parent}{os.sep}" if is_split else model_instance.fname_out
3166+
logger.info(f"Model successfully exported to {out_path}")
31653167

31663168

31673169
if __name__ == '__main__':

0 commit comments

Comments
 (0)