Skip to content

Hooks global state

skip_all_hooks = HooksState.skip module-attribute

stop_all_hooks = HooksState.stop module-attribute

resume_all_hooks = HooksState.resume module-attribute

skip() classmethod

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

Note

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

Added in 0.7.0

Examples:

from onetl.hooks import skip_all_hooks

# hooks are enabled

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

# hook state is restored
from onetl.hooks import skip_all_hooks

# hooks are enabled


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


main()

stop() classmethod

Stop all hooks for all classes.

Added in 0.7.0

Examples:

from onetl.hooks import stop_all_hooks

# hooks are executed

stop_all_hooks()

# all hooks are stopped now

resume() classmethod

Resume all onETL hooks.

Note

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

Added in 0.7.0

Examples:

from onetl.hooks import resume_all_hooks, stop_all_hooks

stop_all_hooks()

# hooks are stopped

resume_all_hooks()

# all hooks are executed now