@@ -1138,6 +1138,12 @@ def parse_args(self, args=None, namespace=None):
1138
1138
args = FlexibleArgumentParser ._pull_args_from_config (args )
1139
1139
1140
1140
# Convert underscores to dashes and vice versa in argument names
1141
+ processed_args = self ._format_args (args )
1142
+
1143
+ return super ().parse_args (processed_args , namespace )
1144
+
1145
+ def _format_args (self , args : List [str ]) -> List [str ]:
1146
+ """Convert underscores to dashes and vice versa in argument names"""
1141
1147
processed_args = []
1142
1148
for arg in args :
1143
1149
if arg .startswith ('--' ):
@@ -1150,13 +1156,9 @@ def parse_args(self, args=None, namespace=None):
1150
1156
arg [len ('--' ):].replace ('_' , '-' ))
1151
1157
else :
1152
1158
processed_args .append (arg )
1153
- args , argv = super ().parse_known_args (processed_args , namespace )
1154
- # Raise error if there are more unknown args than --dummy-tag
1155
- if len (argv ) > 1 :
1156
- msg = 'unrecognized arguments: {}' .format (' ' .join (argv ))
1157
- raise argparse .ArgumentError (None , msg )
1158
- return args
1159
1159
1160
+ return processed_args
1161
+
1160
1162
@staticmethod
1161
1163
def _pull_args_from_config (args : List [str ]) -> List [str ]:
1162
1164
"""Method to pull arguments specified in the config file
@@ -1205,12 +1207,12 @@ def _pull_args_from_config(args: List[str]) -> List[str]:
1205
1207
config_args = FlexibleArgumentParser ._load_config_file (file_path )
1206
1208
1207
1209
# 0th index is for {serve,chat,complete}
1210
+ # followed by model_tag
1208
1211
# followed by config args
1209
1212
# followed by rest of cli args.
1210
1213
# maintaining this order will enforce the precedence
1211
- # of cli > config > defaults
1212
- args = [args [0 ]] + config_args + ['--dummy-tag' ] + \
1213
- args [1 :index ] + args [index + 2 :]
1214
+ # of cli > config > defaults
1215
+ args = [args [0 ]] + [args [1 ]] + config_args + args [2 :index ] + args [index + 2 :]
1214
1216
1215
1217
return args
1216
1218
0 commit comments