GaudiConfig2 job options dump cannot handle ToolArray; does not include default-configured tools
With these old-style options:
from Configurables import MyGaudiAlgorithm
MyGaudiAlgorithm()
A job options dump contains the (default) configuration of all tools held by MyGaudiAlgorithm
:
$ gaudirun.py options.py -n -o opts.py --all-opts
# setting LC_ALL to "C"
$ cat opts.py | grep PrivTool
'PrivToolHandle': 'MyTool/PrivToolHandle',
'MyGaudiAlgorithm.PrivToolHandle': {'AuditFinalize': False,
With these GaudiConfig2
options:
import GaudiConfig2.Configurables as C
def main():
return [C.MyGaudiAlgorithm()]
A job options dump does not work:
$ gaudirun.py Module:main -n -o opts-gaudiconfig2.py --all-opts
# setting LC_ALL to "C"
Traceback (most recent call last):
File "/home/apearce/stack-g/Gaudi/Gaudi/scripts/gaudirun.py", line 584, in <module>
c.writeconfig(opts.output, opts.all_opts)
File "/home/apearce/stack-g/Gaudi/Gaudi/python/Gaudi/Main.py", line 422, in writeconfig
write[ext](filename, all)
File "/home/apearce/stack-g/Gaudi/Gaudi/python/Gaudi/Main.py", line 416, in <lambda>
".py": lambda filename, all: open(filename, "w").write(self.generatePyOutput(all) + "\n"),
File "/home/apearce/stack-g/Gaudi/Gaudi/python/Gaudi/Main.py", line 369, in generatePyOutput
optDict[c][p] = parseOpt(allOpts[key])
File "/home/apearce/stack-g/Gaudi/Gaudi/python/Gaudi/Main.py", line 312, in parseOpt
return eval(s)
File "<string>", line 1, in <module>
NameError: name 'PublicToolHandleArray' is not defined
This patch gets past the problem (no feeling for how reasonable this patch is):
diff --git a/Gaudi/python/Gaudi/Main.py b/Gaudi/python/Gaudi/Main.py
index 33111ce71..61030e655 100644
--- a/Gaudi/python/Gaudi/Main.py
+++ b/Gaudi/python/Gaudi/Main.py
@@ -308,6 +308,7 @@ def parseOpt(s):
m = quoted_string.match(s)
if m:
return m.group(1).replace('\\"', '"')
+ from GaudiKernel.GaudiHandles import PrivateToolHandleArray, PublicToolHandleArray
return eval(s)
(The PrivateToolHandleArray
import is not necessary for this example, but I've found it necessary when working with other configurations.)
With the patch, the dump works but no tool configuration is in the dump:
$ gaudirun.py Module:main -n -o opts-gaudiconfig2.py --all-opts
$ cat opts-gaudiconfig2.py | grep PrivTool
'PrivToolHandle': 'MyTool/PrivToolHandle',
/cc @clemenci