Skip to content

Expand always_last semantics in hook definitions to allow attaching more hooks at the end of the stage #3057

@vkarak

Description

@vkarak

Currently, only a single hook in a stage can set always_last=True. This quite restrictive if you combine mixins and library tests. We should allow multiple hooks to define always_last in which case these hooks will be "accumulated" at the end of the stage in reverse MRO order. Here is an example:

class A(...):
    @run_before('run', always_last=True)
    def hook_a(self): pass

    @run_before('run')
    def hook_b(self): pass

class B(A):
    @run_before('run', always_last=True)
    def hook_c(self): pass

    @run_before('run')
    def hook_d(self): pass

The execution order of the pre-run hooks in this case should be:

hook_b, hook_d, hook_c, hook_a

Currently this is not allowed and if we remove the always_last from everywhere, the execution order will be:

hook_a, hook_b, hook_c, hook_d

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions