Hi Dagster team, hope all is well! :slightly_smili...
# ask-community
s
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
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
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
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
@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
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
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
@sandy Thanks! I'll have a look at
_step_execution_context
. Will file an issue once I know more/if that works.