[WIP] Move gaudirun to ArgumentParser
Moving to the ArgumentParser
allows to use parse_known_args
which in turn allows users to register their own parsers in option files (for simple configurations that may be useful to supply via command line arguments, such as the name of an input file).
One previous use-case cannot be replicated with the ArgumentParser:
OptionParser
allows to mix positional arguments with options. This was used with the --option
which allows to append single lines of python code to the Gaudi options. I'm not sure I understand the use-case, but if it is meant to customize the options, it looks to me that it is broken because the scopes for files and --option
options are different. The logic as I understand is:
- import option file here
- which leads to execution of the option file in context
{}
here - execute
--option
options in contextg,l
here
Simplified, we do something like the following (if in --option
we try to modify / use something from an option file or the other way around) which leads to a NameError:
g, l = {}, {}
exec "exec('a = 1', {});print a" in g, l
As I mentioned I may have misunderstood the use-case of --option
in which case it needs to be seen if the actual use-case can be covered with ArgumentParser
(i.e. I don't see why the ordering of options files and --option
lines matters when the scope is different anyway).
Merge request reports
Activity
The use case for
--option
is to allow, for example, something likegaudirun.py my_options.py --option 'MessageSvc(OutputLevel=DEBUG)'
About the order, it is really important because the python context is different, but the configurables are in a global variable and changing the order of two option lines makes a difference.
233 229 if argv != sys.argv[1:]: 234 230 print '# Running', sys.argv[0], 'with arguments', argv 235 231 236 opts, args = parser.parse_args(args=argv) 232 args, _ = parser.parse_known_args(args=argv) mentioned in issue #24