Skip to content
Snippets Groups Projects

[WIP] Move gaudirun to ArgumentParser

Closed Joschka Lingemann requested to merge jlingema/Gaudi:gaudirun into master
1 unresolved thread

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • The use case for --option is to allow, for example, something like

    gaudirun.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)
  • Benedikt Hegner Marked this merge request as a Work In Progress

    Marked this merge request as a Work In Progress

  • Marco Clemencic mentioned in issue #24

    mentioned in issue #24

  • I'm closing this MR because it seems abandoned, and I opened #24

  • Please register or sign in to reply
    Loading