Skip to content

Define (in)equality operations for Configurable

With the Run 3 configurable behaviour, testing equality two Configurables that are identically named and configured was returning False, because they were different objects, and no equality operator was defined.

I've now created equality/inequality operators for Configurable, which should test that all properties are identical (including any tools held in ToolHandle properties -- I assume that services are safely identified by name). This allows me to merge ComponentAccumulators containing identical algorithms successfully, as was intended.

Defining the hash with recursion into childrens' properties in a __hash__ method caused frequent generation of default configurables from ToolHandles that resulted in two types of issues:

  1. Immediate crash due to incorrect C++ initialisation of the ToolHandle, and therefore failure to access the right class in ConfigurableDb
  2. Inconsistency between default configurable and a configured instance to be set, which was treated as an error mode.

So, for now the main operation is in a getStrDescriptor method instead, meaning that the default python hashing still applies when Configurables are placed in sets or used as keys to a dict. We may wish to implement proper hashing, but possibly after the Gaudi Configurable updates in gaudi/Gaudi!721 (merged).

Edited by Teng Jian Khoo

Merge request reports

Loading