Skip to content

CPAlgorithms: print the correct block name when the YAML is misconfigured

Baptiste Ravina requested to merge ravinab/athena:empty_blocks into main

When a custom block is configured in YAML, but is not properly set up with AddConfigBlocks, the following error message is triggered

File "/build_AB/x86_64-el9-gcc13-opt/python/AnalysisAlgorithmsConfig/ConfigText.py", line 163, in configure
    raise ValueError(f"Unkown block {blockName} in yaml file")
ValueError: Unkown block  in yaml file

which is particularly unhelpful.

In those cases, we are looking at a dictionary with key the empty string and value another dictionary. The empty string is here passed to the print function as blockName. This MR instead picks the (unique) key of the sub-dictionary, which should really have been the blockName had it been correctly set up. This turns the above error message into e.g.

File "/build_AB/x86_64-el9-gcc13-opt/python/AnalysisAlgorithmsConfig/ConfigText.py", line 165, in configure
    raise ValueError(f"Unkown block {blockName} in yaml file")
ValueError: Unkown block KLFitter in yaml file

from which I can now easily fix the YAML file

AddConfigBlocks:
    # - modulePath: 'TopCPToolkit.KLFitterConfig'
    #   functionName: 'KLFitterConfig'
    #   algName: 'KLFitter'
    #   pos: 'Output'

Merge request reports