Skip to content
Snippets Groups Projects
Commit 457b89f6 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

[config_file] Make it an optional argument rather than an option

parent 4f3c96b9
No related branches found
No related tags found
1 merge request!36Suggests configuration file should be the default "way" with `verify.py`
Pipeline #
...@@ -76,7 +76,7 @@ def test_basic(): ...@@ -76,7 +76,7 @@ def test_basic():
'result_directory = "%s"' % test_dir, 'result_directory = "%s"' % test_dir,
]) ])
args = parse_arguments(['-c', test_config_file.name]) args = parse_arguments([test_config_file.name])
assert args.zt_norm is True assert args.zt_norm is True
assert args.verbose == 1 assert args.verbose == 1
...@@ -117,7 +117,7 @@ def test_compare_to_cmdline_basic(): ...@@ -117,7 +117,7 @@ def test_compare_to_cmdline_basic():
'result_directory = "%s"' % test_dir, 'result_directory = "%s"' % test_dir,
]) ])
args_file = parse_arguments(['-c', test_config_file.name]) args_file = parse_arguments([test_config_file.name])
# now do the same with command-line arguments, ensure result is equal # now do the same with command-line arguments, ensure result is equal
args_cmdline = parse_arguments([ args_cmdline = parse_arguments([
...@@ -159,7 +159,7 @@ def test_compare_to_cmdline_resources(): ...@@ -159,7 +159,7 @@ def test_compare_to_cmdline_resources():
'preferred_package = "bob.bio.base"', 'preferred_package = "bob.bio.base"',
]) ])
args_file = parse_arguments(['-c', test_config_file.name]) args_file = parse_arguments([test_config_file.name])
# now do the same with command-line arguments, ensure result is equal # now do the same with command-line arguments, ensure result is equal
args_cmdline = parse_arguments([ args_cmdline = parse_arguments([
...@@ -204,7 +204,7 @@ def test_compare_to_cmdline_skip(): ...@@ -204,7 +204,7 @@ def test_compare_to_cmdline_skip():
'preferred_package = "bob.bio.base"', 'preferred_package = "bob.bio.base"',
]) ])
args_file = parse_arguments(['-c', test_config_file.name]) args_file = parse_arguments([test_config_file.name])
# now do the same with command-line arguments, ensure result is equal # now do the same with command-line arguments, ensure result is equal
args_cmdline = parse_arguments([ args_cmdline = parse_arguments([
......
...@@ -47,8 +47,7 @@ def command_line_parser(description=__doc__, exclude_resources_from=[]): ...@@ -47,8 +47,7 @@ def command_line_parser(description=__doc__, exclude_resources_from=[]):
####################################################################################### #######################################################################################
############## options that are required to be specified ####################### ############## options that are required to be specified #######################
config_group = parser.add_argument_group('\nParameters defining the experiment. Most of these parameters can be a registered resource, a configuration file, or even a string that defines a newly created object') config_group = parser.add_argument_group('\nParameters defining the experiment. Most of these parameters can be a registered resource, a configuration file, or even a string that defines a newly created object')
config_group.add_argument('-c', '--configuration-file', config_group.add_argument('configuration_file', metavar='PATH', nargs='?', help = 'A configuration file containing one or more of "database", "preprocessor", "extractor", "algorithm" and/or "grid"')
help = 'A configuration file containing one or more of "database", "preprocessor", "extractor", "algorithm" and/or "grid"')
config_group.add_argument('-d', '--database', metavar = 'x', nargs = '+', config_group.add_argument('-d', '--database', metavar = 'x', nargs = '+',
help = 'Database and the protocol; registered databases are: %s' % utils.resource_keys('database', exclude_resources_from)) help = 'Database and the protocol; registered databases are: %s' % utils.resource_keys('database', exclude_resources_from))
config_group.add_argument('-p', '--preprocessor', metavar = 'x', nargs = '+', config_group.add_argument('-p', '--preprocessor', metavar = 'x', nargs = '+',
...@@ -169,7 +168,7 @@ def _take_from_config_or_command_line(args, config, keyword, default, required=T ...@@ -169,7 +168,7 @@ def _take_from_config_or_command_line(args, config, keyword, default, required=T
setattr(args, keyword, val) setattr(args, keyword, val)
elif required: elif required:
raise ValueError("Please specify a %s either on command line (via --%s) or in the configuration file (via --configuration-file)" %(keyword, keyword)) raise ValueError("Please specify a %s either on command line (via --%s) or in a configuration file" %(keyword, keyword))
def initialize(parsers, command_line_parameters = None, skips = []): def initialize(parsers, command_line_parameters = None, skips = []):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment