Hooks
- @dagster.success_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[AbstractSet[str]]) – Keys for the resources required by the hook.
 - Examples: - @success_hook(required_resource_keys={'slack'})
 def slack_message_on_success(context):
 message = 'op {} succeeded'.format(context.op.name)
 context.resources.slack.send_message(message)
 @success_hook
 def do_something_on_success(context):
 do_something()
- @dagster.failure_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[AbstractSet[str]]) – Keys for the resources required by the hook.
 - Examples: - @failure_hook(required_resource_keys={'slack'})
 def slack_message_on_failure(context):
 message = 'op {} failed'.format(context.op.name)
 context.resources.slack.send_message(message)
 @failure_hook
 def do_something_on_failure(context):
 do_something()
- classdagster.HookDefinition [source]
- Define a hook which can be triggered during a op execution (e.g. a callback on the step execution failure event during a op execution). - Parameters: - name (str) – The name of this hook.
- hook_fn (Callable) – The callback function that will be triggered.
- required_resource_keys (Optional[AbstractSet[str]]) – Keys for the resources required by the hook.
 
- classdagster.HookContext [source]
- The - contextobject available to a hook function on an DagsterEvent.- propertyhook_def [source]
- The hook that the context object belongs to. 
 - propertyinstance [source]
- The instance configured to run the current job. 
 - propertyjob_name [source]
- The name of the job where this hook is being triggered. 
 - propertylog [source]
- Centralized log dispatch from user code. 
 - propertyop_config [source]
- The parsed config specific to this op. 
 - propertyop_exception [source]
- The thrown exception in a failed op. 
 - propertyop_output_metadata [source]
- The applied output metadata. - Returns a dictionary where keys are output names and the values are: - the applied output metadata in the normal case
- a dictionary from mapping key to corresponding metadata in the mapped case
 
 - propertyop_output_values [source]
- The computed output values. - Returns a dictionary where keys are output names and the values are: - the output values in the normal case
- a dictionary from mapping key to corresponding value in the mapped case
 
 - propertyrequired_resource_keys [source]
- Resources required by this hook. 
 - propertyresources [source]
- Resources available in the hook context. 
 - propertyrun_id [source]
- The id of the run where this hook is being triggered. 
 - propertystep_key [source]
- The key for the step where this hook is being triggered. 
 
- dagster.build_hook_context [source]
- Builds hook context from provided parameters. - build_hook_contextcan be used as either a function or a context manager. If there is a provided resource to- build_hook_contextthat is a context manager, then it must be used as a context manager. This function can be used to provide the context argument to the invocation of a hook definition.- Parameters: - resources (Optional[Dict[str, Any]]) – The resources to provide to the context. These can either be values or resource definitions.
- op (Optional[OpDefinition, PendingNodeInvocation]) – The op definition which the hook may be associated with.
- run_id (Optional[str]) – The id of the run in which the hook is invoked (provided for mocking purposes).
- job_name (Optional[str]) – The name of the job in which the hook is used (provided for mocking purposes).
- op_exception (Optional[Exception]) – The exception that caused the hook to be triggered.
- instance (Optional[DagsterInstance]) – The Dagster instance configured to run the hook.
 - Examples: - context = build_hook_context()
 hook_to_invoke(context)
 with build_hook_context(resources={"foo": context_manager_resource}) as context:
 hook_to_invoke(context)