[Bugfix] Fix order of arguments matters in config.yaml (#8960)

This commit is contained in:
Andy Dai
2024-10-05 10:35:11 -07:00
committed by GitHub
parent cfadb9c687
commit 5df1834895
4 changed files with 36 additions and 9 deletions

View File

@@ -1201,11 +1201,21 @@ class FlexibleArgumentParser(argparse.ArgumentParser):
config_args = FlexibleArgumentParser._load_config_file(file_path)
# 0th index is for {serve,chat,complete}
# followed by model_tag (only for serve)
# followed by config args
# followed by rest of cli args.
# maintaining this order will enforce the precedence
# of cli > config > defaults
args = [args[0]] + config_args + args[1:index] + args[index + 2:]
if args[0] == "serve":
if index == 1:
raise ValueError(
"No model_tag specified! Please check your command-line"
" arguments.")
args = [args[0]] + [
args[1]
] + config_args + args[2:index] + args[index + 2:]
else:
args = [args[0]] + config_args + args[1:index] + args[index + 2:]
return args