Skip to content

Глобальное состояние хуков

skip_all_hooks = HooksState.skip module-attribute

stop_all_hooks = HooksState.stop module-attribute

resume_all_hooks = HooksState.resume module-attribute

onetl.hooks.hooks_state.HooksState.skip() classmethod

Temporary stop all onETL hooks. Designed to be used as context manager or decorator.

.. note::

If hooks were stopped by :obj:`~stop_all_hooks`, they will not be resumed
after exiting the context/decorated function.
You should call :obj:`~resume_all_hooks` explicitly.

.. versionadded:: 0.7.0

Examples

.. tabs::

.. code-tab:: py Context manager syntax

    from onetl.hooks import skip_all_hooks

    # hooks are enabled

    with skip_all_hooks():
        # hooks are stopped here
        ...

    # hook state is restored

.. code-tab:: py Decorator syntax

    from onetl.hooks import skip_all_hooks

    # hooks are enabled


    @skip_all_hooks()
    def main():
        # hooks are stopped here
        ...


    main()

onetl.hooks.hooks_state.HooksState.stop() classmethod

Stop all hooks for all classes.

.. versionadded:: 0.7.0

Examples

.. code:: python

from onetl.hooks import stop_all_hooks

# hooks are executed

stop_all_hooks()

# all hooks are stopped now

onetl.hooks.hooks_state.HooksState.resume() classmethod

Resume all onETL hooks.

.. note::

This function does not enable hooks which were disabled by :obj:`onetl.hooks.hook.Hook.disable`,
or stopped by :obj:`onetl.hooks.support_hooks.suspend_hooks`.

.. versionadded:: 0.7.0

Examples

.. code:: python

from onetl.hooks import resume_all_hooks, stop_all_hooks

stop_all_hooks()

# hooks are stopped

resume_all_hooks()

# all hooks are executed now