Draft: athena.py: add support for running CA modules

Closed Frank Winklmeier requested to merge fwinkl/athena:athenaCA2 into 23.0

Status quo for running CA modules

  1. directly as executable: python Control/AthenaExamples/AthExHelloWorld/python/HelloWorldConfig.py
  2. via athena: athena --CA AthExHelloWorld/HelloWorldConfig.py [MyFlag.Value=42], which essentially does the above via ThinCAWrapper.sh (can also run .pkl files)

Typical driver scripts:

  • can implement their own CLI, e.g. Run3DQTestingDriver
  • that's useful in order to give the user all relevant command line options; we couldn't do that in plain athena so far; but its command line parser has recently been re-implemented in argparse: !59440 (merged)
  • but a lot of code duplication and minimal feature set is not guaranteed

Proposed change

Teach athena how to run CA modules. The main difference to the already existing --CA option is that the user does not have to write the __main__ "function" as athena takes care of setting up the initial set of flags and MainServicesCfg. It then merges the user-given CA and runs it.

Best explained via HelloWorldConfig:

athena.py AthExHelloWorld.HelloWorldConfig.HelloWorldCfg
athena.py --evtMax=30 AthExHelloWorld.HelloWorldConfig.HelloWorldCfg
athena.py -c 'flags.MyFlag.Value=42' AthExHelloWorld.HelloWorldConfig.HelloWorldCfg
athena.py HelloWorldConfig.HelloWorldCfg    # search in local run directory

If only a module name is given, athena will try to "guess" the Cfg function by using the first function in the module that ends with "Cfg":

athena.py AthExHelloWorld.HelloWorldConfig

(It might be better to have an explicit convention though. E.g. only look for mainCfg or similar).


  • all framework details hidden from user
  • reduces unnecessary __main__ boilerplate for simple CAs and their testing
  • similar CLI and "feel" for legacy and CA with same feature sets across all jobs
  • do not rely on driver scripts to implement necessary features (e.g. --debug, LD_PRELOAD)
  • other driver scripts (e.g. athenaHLT) can implement a different MainServicesCfg without impacting the user job options
  • fully-fledged standalone CA drivers are of course still possible (e.g. I am not suggesting to replace Run3DQTestingDriver, etc.)


  • yet another way on how to run a CA (we may want to get rid of the athena --CA mode as it's almost nowhere used)
  • if the user-CA needs to modify the flags, it has to clone them first
  • some of the athena command line arguments don't make sense for CA modules
Edited by Frank Winklmeier

Merge request reports