https://dagster.io/ logo
#dagster-support
Title
# dagster-support
s

Simon

01/30/2023, 7:53 PM
Hi Dagster team, hope all is well! 🙂 Wanted to check if my understanding is correct that there's no way to access the Op's context in a hook that gets triggered after running (or failing) an Op. Is this correct? Some details about the specific use-case: We're trying to store the state (success and failure) of each Run/partition in our monitoring system and need the partition key for this. In the Ops we can access this via `context.partition_time_window.start`/`context.partition_time_window.end`but I've not been able to find a way to access these or the Op's context from within a hook/`HookContext`.
j

jamie

01/30/2023, 8:59 PM
Hey @Simon have you taken a look at
context.op_config
? that might contain the partition info. I haven’t tested myself, but i believe that’s where it should be. if that doesn’t work, let me know!
s

Simon

01/30/2023, 9:23 PM
Hi @jamie I did check
context.op_config
, it unfortunately only contains the config of the Op (as expected given the name I guess :P)
j

jamie

01/30/2023, 9:24 PM
huh, usually partitioned ops get the partition info from the config. can you send some code snippets of how you’re defining your partitions?
s

Simon

01/30/2023, 9:30 PM
@jamie We're using graph backed assets, it looks something like
Copy code
test_partitions_def = DailyPartitionsDefinition(start_date="2022-04-01")

test_asset = AssetsDefinition.from_graph(
    test_graph,
    partitions_def=test_partitions_def
)
The graph gets passed the config via
@graph(config={...}
. The hook's
context.op_config
contains exactly what's in the config for the Op that the hook is on
j

jamie

01/30/2023, 9:35 PM
i see. the conversion of the graph to assets is likely why it’s not going through config. cc @sandy - do you know how graph backed assets interact with hooks?
s

sandy

01/30/2023, 9:38 PM
Hi Simon - alas, that's correct that there's hooks don't have access to`context.partition_time_window.start`/`context.partition_time_window.end` . You could potentially hack this by accessing the underlying
_step_execution_context
property on the
HookContext
. If you file a GH issue for this, we also might be able to add it at some point
👍 1
s

Simon

01/30/2023, 9:51 PM
@sandy Thanks! I'll have a look at
_step_execution_context
. Will file an issue once I know more/if that works.