sqlmesh.core.hooks API documentation

Edit on GitHub

# sqlmesh.core.hooks

View Source

     1from __future__ import annotations
     2
     3from sqlmesh.utils import UniqueKeyDict, registry_decorator
     4
     5
     6class hook(registry_decorator):
     7    """Specifies a function is a hook and registers it the global hooks registry.
     8
     9    Registered hooks can be used in pre or post processing of models.
    10
    11    Example:
    12        from sqlmesh.core.hooks import hook
    13
    14        @hook()
    15        def echo(
    16            context: ExecutionContext,
    17            start: datetime,
    18            end: datetime,
    19            latest: datetime,
    20            **kwargs,
    21        ) -> None:
    22            print(kwargs)
    23
    24    Args:
    25        name: A custom name for the macro, the default is the name of the function.
    26    """
    27
    28    registry_name = "hooks"
    29
    30
    31HookRegistry = UniqueKeyDict[str, hook]

class hook(sqlmesh.utils.registry_decorator): View Source

     7class hook(registry_decorator):
     8    """Specifies a function is a hook and registers it the global hooks registry.
     9
    10    Registered hooks can be used in pre or post processing of models.
    11
    12    Example:
    13        from sqlmesh.core.hooks import hook
    14
    15        @hook()
    16        def echo(
    17            context: ExecutionContext,
    18            start: datetime,
    19            end: datetime,
    20            latest: datetime,
    21            **kwargs,
    22        ) -> None:
    23            print(kwargs)
    24
    25    Args:
    26        name: A custom name for the macro, the default is the name of the function.
    27    """
    28
    29    registry_name = "hooks"

Specifies a function is a hook and registers it the global hooks registry.

Registered hooks can be used in pre or post processing of models.

###### Example:

> from sqlmesh.core.hooks import hook

> @hook() def echo( context: ExecutionContext, start: datetime, end: datetime, latest: datetime, **kwargs, ) -> None: print(kwargs)

###### Arguments:

- name: A custom name for the macro, the default is the name of the function.

##### Inherited Members

sqlmesh.utils.registry_decorator
  registry_decorator
  registry
  get_registry
  set_registry