@@ -227,9 +227,19 @@ def initialize_parameters(bmk):
227
227
228
228
#print('Args:', args)
229
229
# Get parameters from configuration file
230
- aux = bmk .parser .parse_args (['conffile' ])
231
- #print(aux.config_file)
232
- fileParameters = bmk .read_config_file (aux .config_file )#args.config_file)
230
+ # Reads parameter subset, just checking if a config_file has been set
231
+ # by comand line (the parse_known_args() function allows a partial
232
+ # parsing)
233
+ aux = bmk .parser .parse_known_args ()
234
+ try : # Try to get the 'config_file' option
235
+ conffile_txt = aux [0 ].config_file
236
+ except AttributeError : # The 'config_file' option was not set by command-line
237
+ conffile = bmk .conffile # use default file
238
+ else : # a 'config_file' has been set --> use this file
239
+ conffile = os .path .join (bmk .file_path , conffile_txt )
240
+
241
+ print ("Configuration file: " , conffile )
242
+ fileParameters = bmk .read_config_file (conffile )#aux.config_file)#args.config_file)
233
243
# Get command-line parameters
234
244
args = bmk .parser .parse_args ()
235
245
#print ('Params:', fileParameters)
@@ -254,7 +264,6 @@ def get_default_neon_parser(parser):
254
264
"""
255
265
# Logging Level
256
266
parser .add_argument ("-v" , "--verbose" , type = str2bool ,
257
- default = argparse .SUPPRESS ,
258
267
help = "increase output verbosity" )
259
268
parser .add_argument ("-l" , "--log" , dest = 'logfile' ,
260
269
default = None ,
@@ -308,6 +317,10 @@ def get_common_parser(parser):
308
317
parser for command-line options
309
318
"""
310
319
320
+ # Configuration file
321
+ parser .add_argument ("--config_file" , dest = 'config_file' , default = argparse .SUPPRESS ,
322
+ help = "specify model configuration file" )
323
+
311
324
# General behavior
312
325
parser .add_argument ("--train_bool" , dest = 'train_bool' , type = str2bool ,
313
326
default = True ,
@@ -585,20 +598,9 @@ def parse_from_common(self):
585
598
586
599
self .parser = parser
587
600
588
- subparsers = self .parser .add_subparsers ()
589
- self .parser_a = subparsers .add_parser ('conffile' , help = 'a help' )
590
- #parser_a.add_argument('bar', type=int, help='bar help')
591
-
592
601
# Set default configuration file
593
- #self.parser.add_argument("--config_file", dest='config_file', type=str,
594
- # default=os.path.join(self.file_path, self.default_model),
595
- # help="specify model configuration file")
596
-
597
- self .parser_a .add_argument ("--config_file" , dest = 'config_file' , type = str ,
598
- default = os .path .join (self .file_path , self .default_model ),
599
- help = "specify model configuration file" )
600
-
601
-
602
+ self .conffile = os .path .join (self .file_path , self .default_model )
603
+
602
604
603
605
def parse_from_benchmark (self ):
604
606
"""Functionality to parse options specific
0 commit comments