Skip to content

Fix configuration problem for multiply-nested tools.

With something like:

AlgA ('A',
      tool1 = Tool1('tool1',
                    tool2 = Tool2 ('tool2')))

The configurable for Tool2 corresponding to the private tool wasn't being entered into allConfigurables.

So, when we create the Tool1 configurable, it's actually a public tool, and is given the name ToolSvc.tool1.

When this gets assigned to the tool1 property of the algorithm, PropertyProxy.convertValueToBeSet first runs copyChildAndSetParent to make a copy of the configurable and reset the name of the parent to A. So we get a new configurable with name A.tool1. It then does

obj.allConfigurables[value.name()] = value

to enter the new configurable into allConfigurables.

When we have nested tools such as above, we first make the Tool2 configurable. As above, it has name ToolSvc.tool2. We then assign it to the tool2 property of Tool1. tool1 is still a public tool at this point, so after resetting the parent, tool2 will have the full name ToolSvc.tool1.tool2.

We then assign tool1 to the tool1 property of the algorithm. From here, two things go wrong.

First, we call setParent on tool1 with a parent of A. This changes the name of tool1 to A.tool1. It also recursively calls setParent on tool2 --- but passes it the same parent --- A. As a result, tool2 gets renamed to A.tool2, not A.tool1.tool2, as it should be.

We can fix this by adding the instance name onto the parent in the recursive setParent call.

But that still doesn't work --- the entry for A.tool1.tool2 doesn't get into allConfigurables. That's because the line above only puts the top-most tool (A.tool1) into allConfigurables. We also have to change PropertyProxy.convertValueToBeSet to recursively add all the children.

With these two changes, configurations like the above work as expected.

Also extended test_Configurables.py to test this.

Merge request reports

Loading