Wrap pipeline unit type

The last pipeline unit type is named “wrap”. This pipeline unit is called after a final state is accepted by strides.

The wrap pipeline unit can perform logic on already accepted final state. A possible use case for wrap pipeline unit can be addition of another justification based on the packages resolved. This is handy if you want to add a justification that does not impact stack score or its inclusion to the pipeline products (otherwise, a step pipeline unit should be used).


Raising any exception in a wrap causes the pipeline resolution to halt, with a corresponding failure that reports the exception message.

Main usage

  • Add justification to the final pipeline product without affecting the product score or inclusion of the product into the final results

  • Additionally adjust runtime environment recommended back to user

  • Register a callback function that should be called once a certain software stack is found

Real world examples

An example implementation

from typing import Any
from typing import Dict
from typing import Optional
from typing import TYPE_CHECKING

from thoth.adviser.state import State
from thoth.adviser.wrap import Wrap

    from ..pipeline_builder import PipelineBuilderContext

class NoSemanticInterpositionWrap(Wrap):
    """A wrap that recommends to switch to Python 3.8 on RHEL 8.2."""

          "type": "INFO",
          "message": "Consider using UBI or RHEL 8.2 with Python 3.8 that has optimized Python interpreter with "
          "performance gain up to 30%",

    def should_include(cls, builder_context: "PipelineBuilderContext") -> Optional[Dict[str, Any]]:
        """Include this wrap in adviser for RHEL/UBI 8.2."""
        if builder_context.is_included(cls):
            return None

        if not builder_context.is_adviser_pipeline():
            return None

        if (
            builder_context.project.runtime_environment.operating_system.name in ("rhel", "ubi")
            and builder_context.project.runtime_environment.operating_system.version == "8.2"
            and builder_context.project.runtime_environment.python_version != "3.8"
            return {}

        return None

    def run(self, state: State) -> None:
        """Recommend using Python3.8 on RHEL/UBI 8.2."""

The implementation can also provide other methods, such as Unit.pre_run, Unit.post_run or Unit.post_run_report and pipeline unit configuration adjustment. See unit documentation for more info.