DagsterDocs
Quick search

Hooks

@dagster.success_hook(name: Union[str, None, Callable[[...], Any]] = None, required_resource_keys: Optional[Set[str]] = None) → Union[dagster.core.definitions.hook.HookDefinition, dagster.core.definitions.decorators.hook._Hook, Callable[[Callable[[HookContext], Any]], Union[dagster.core.definitions.hook.HookDefinition, dagster.core.definitions.decorators.hook._Hook]]][source]

Create a hook on step success events with the specified parameters from the decorated function.

Parameters
  • name (Optional[str]) – The name of this hook.

  • required_resource_keys (Optional[Set[str]]) – Keys for the resources required by the hook.

Examples

@success_hook(required_resource_keys={'slack'})
def slack_message_on_success(context):
    message = 'solid {} succeeded'.format(context.solid.name)
    context.resources.slack.send_message(message)

@success_hook
def do_something_on_success(context):
    do_something()
@dagster.failure_hook(name: Optional[str] = None, required_resource_keys: Optional[Set[str]] = None) → Union[dagster.core.definitions.hook.HookDefinition, dagster.core.definitions.decorators.hook._Hook, Callable[[Callable[[HookContext], Any]], Union[dagster.core.definitions.hook.HookDefinition, dagster.core.definitions.decorators.hook._Hook]]][source]

Create a hook on step failure events with the specified parameters from the decorated function.

Parameters
  • name (Optional[str]) – The name of this hook.

  • required_resource_keys (Optional[Set[str]]) – Keys for the resources required by the hook.

Examples

@failure_hook(required_resource_keys={'slack'})
def slack_message_on_failure(context):
    message = 'solid {} failed'.format(context.solid.name)
    context.resources.slack.send_message(message)

@failure_hook
def do_something_on_failure(context):
    do_something()