Skip to content

[WIP] Move gaudirun to ArgumentParser

Joschka Lingemann requested to merge jlingema/Gaudi:gaudirun into master

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:

  1. import option file here
  2. which leads to execution of the option file in context {}here
  3. execute --option options in context g,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