In Assette, a Decorator Block is a special type of block that allows you to apply additional logic or transformations to data before it is processed by dependent blocks. When a Decorator Block is added as a dependency to a Data Block, it will always execute before the Data Block, regardless of where it appears in the dependency list. This ensures that any transformations or setup performed in the Decorator Block are in place before the main processing begins.
Execution Order for Decorator Blocks #
When a Data Block has multiple dependencies, the execution flow is adjusted so that Decorator Blocks are always executed first.
For example, consider the following configuration:
Block 1 → Block 2 → Block 3, Block 4, Dec1 (Decorator Block)
Even though the dependencies are listed together, the actual execution order will be:
Block 1 → Dec1 (Decorator Block) → Block 2 → Block 3, Block 4
This ensures that all logic in Dec1
is applied before Block 2
begins execution.
Stacking Multiple Decorator Blocks #
It is possible to attach multiple Decorator Blocks to a single Data Block. When this is done, the Decorator Blocks will execute in the order in which they are listed as dependencies. If one Decorator Block depends on another, Assette will automatically respect that dependency chain and execute them accordingly.
For example:
Block 1 → DecA (Decorator Block), DecB (Decorator Block), Block 2
Execution order will be:
Block 1 → DecA → DecB → Block 2
If the execution order between Decorator Blocks is important, you should define explicit dependencies between the Decorator Blocks themselves to ensure the correct sequence.
Passing Parameters to Decorator Blocks #
Decorator Blocks can receive parameters from other blocks. This is useful when the Decorator Block requires specific values or context from upstream blocks in order to execute correctly. For example, you can configure a parameter in Block 1
and pass it into Dec1
so that it can influence how the decorator logic is applied.
Example use case:
A setup block calculates a date range.
The calculated date range is passed as a parameter to a Decorator Block.
The Decorator Block uses this date range to filter or transform data before the main processing block runs.
Best Practices
Always define dependencies explicitly between multiple Decorator Blocks if the execution order matters.
Use parameter passing to make Decorator Blocks more flexible and reusable across multiple Data Blocks.
Keep Decorator Block logic modular so that it can be reused without modification in different workflows.