https://dagster.io/ logo
Title
s

Sandeep Aggarwal

08/26/2021, 3:55 AM
How to use hooks with new graph API? I am using
execute_in_process
to run the graph and looking for a way to extract out information (error message/exception) in case pipeline fails.
a

alex

08/27/2021, 2:05 PM
cc @chris / @yuhan
👀 1
c

chris

08/27/2021, 2:09 PM
We don't allow you to pass hooks to
graph.execute_in_process
. However, you could create an ephemeral job, provide hooks to that, and then call execute_in_process:
from .my_hooks import my_hook
from .my_graphs import my_graph

def test_my_graph_with_hook():
    ephemeral_job = my_graph.to_job(hook_defs={my_hook})
    result = ephemeral_job.execute_in_process()
    assert result.success
s

Sandeep Aggarwal

08/30/2021, 4:00 AM
Thanks @chris. I will give this a try.
@chris I tried the above approach and it works as expected. Thanks for you suggestion. A small follow up question: Is Dagster run id available in hook context somewhere?