Skip to content
Snippets Groups Projects
  • Nils Krumnack's avatar
    2a9da035
    CP Algorithm Blocks: replace "references" with two-pass configuration · 2a9da035
    Nils Krumnack authored
    Given that the first iteration of the configuration block design
    invoked criticism of the "reference" design for tracking containers I
    now changed it, so that instead of first allocating references to
    determine what the intermediate containers are, I just run through the
    entire configuration twice.  The second run-through then can rely on
    what it learned in the first run-through to determine what will happen
    further down in the sequence.
    
    This requires routing a number of calls through the ConfigAccumulator
    object, but it definitely makes writing the actual blocks more
    straightforward, and it should also allow for more flexibility if we
    need to redesign the ConfigAccumulator in the future (which also
    became simpler with this change).
    2a9da035
    History
    CP Algorithm Blocks: replace "references" with two-pass configuration
    Nils Krumnack authored
    Given that the first iteration of the configuration block design
    invoked criticism of the "reference" design for tracking containers I
    now changed it, so that instead of first allocating references to
    determine what the intermediate containers are, I just run through the
    entire configuration twice.  The second run-through then can rely on
    what it learned in the first run-through to determine what will happen
    further down in the sequence.
    
    This requires routing a number of calls through the ConfigAccumulator
    object, but it definitely makes writing the actual blocks more
    straightforward, and it should also allow for more flexibility if we
    need to redesign the ConfigAccumulator in the future (which also
    became simpler with this change).
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ConfigSequence.py 1.38 KiB
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration

class ConfigSequence:
    """a sequence of ConfigBlock objects

    This could in principle just be a simple python list, and maybe we
    change it to that at some point (10 Mar 22).  Having it as its own
    class allows to implement some helper functions.

    This implements an interface similar to ConfigBlock, but it
    doesn't derive from it, as ConfigBlock will likely gain
    functionality in the future that wouldn't work for a sequence (or
    wouldn't work in the same way).

    """

    def __init__ (self) :
        self._blocks = []


    def append (self, block) :
        """append a configuration block to the sequence"""

        self._blocks.append (block)


    def makeAlgs (self, config) :
        """call makeAlgs() on all blocks

        This will create the actual algorithm configurables based on
        how the blocks are configured right now.
        """
        for block in self._blocks:
            block.makeAlgs (config)


    def fullConfigure (self, config) :
        """do the full configuration on this sequence

        This sequence needs to be the only sequence, i.e. it needs to
        contain all the blocks that will be configured, as it will
        perform all configuration steps at once.
        """
        self.makeAlgs (config)
        config.nextPass ()
        self.makeAlgs (config)