Neuraxio / Neuraxle

The world's cleanest AutoML library ✨ - Do hyperparameter tuning with the right pipeline abstractions to write clean deep learning production pipelines. Let your pipeline steps have hyperparameter spaces. Design steps in your pipeline like components. Compatible with Scikit-Learn, TensorFlow, and most other libraries, frameworks and MLOps environments.

Home Page:https://www.neuraxle.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: Create `_HasAssertsMixin` to do things like `self._assert(1 == 1, error_msg, context, level=None)`.

guillaume-chevalier opened this issue · comments

class _HasAssertsMixin:
    def _assert(
            self, truth_value, err_msg, context: ExecutionContext = None, level: ExecutionPhase = ExecutionPhase.TEST
    ):
        if not truth_value:
            self._log_err(err_msg)
        if context is None or level is None or context.execution_phase <= level):
            assert truth_value, err_msg
            

class MyStep(_HasAssertsMixin, _HasLoggerMixin, BaseStep):

    def _fit_transform_data_container(
            self, data_container: DataContainer, context: ExecutionContext
    ) -> ('BaseStep', DataContainer): 
        self._assert(1 == 1, f"this is in error: {1 == 1}.", context, level=None)
        return self, data_container