-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow HookContext to access Output Metadata #20025
Labels
Comments
I've created a PR for this here: #20027 |
smackesey
added a commit
that referenced
this issue
Mar 19, 2024
## Summary & Motivation Please refer to the following issue/project spec for context and alternative solutions: #20025. Context: > Upon hook execution, one can access output values via the HookContext (using HookContext's `op_output_values`), but there is currently no way to access output metadata in the same way. Enabling this would allow users to pass information more dynamically to their hooks with respect to each individual ops Output metadata. One application of this is in dynamically applying tags to runs based on the metadata of the last failed/successful run. _Transparency note: Long-time Dagster user, first time Dagster contributor, thanks in advance for your support!_ ## How I Tested These Changes - Ran `make ruff` and `make pyright` before committing - Successfully ran `python -m pytest python_modules/dagster/dagster_tests/core_tests/` - Installed these changes locally with `pip install -e dagster/python_modules/dagster` and confirmed successful cases --------- Co-authored-by: Sean Mackesey <s.mackesey@gmail.com>
PedramNavid
pushed a commit
that referenced
this issue
Mar 28, 2024
## Summary & Motivation Please refer to the following issue/project spec for context and alternative solutions: #20025. Context: > Upon hook execution, one can access output values via the HookContext (using HookContext's `op_output_values`), but there is currently no way to access output metadata in the same way. Enabling this would allow users to pass information more dynamically to their hooks with respect to each individual ops Output metadata. One application of this is in dynamically applying tags to runs based on the metadata of the last failed/successful run. _Transparency note: Long-time Dagster user, first time Dagster contributor, thanks in advance for your support!_ ## How I Tested These Changes - Ran `make ruff` and `make pyright` before committing - Successfully ran `python -m pytest python_modules/dagster/dagster_tests/core_tests/` - Installed these changes locally with `pip install -e dagster/python_modules/dagster` and confirmed successful cases --------- Co-authored-by: Sean Mackesey <s.mackesey@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What's the use case?
Upon hook execution, one can access output values via the HookContext (
HookContext.op_output_values
, but there is currently no way to access output metadata in the same way. Enabling this would allow users to pass information more dynamically to their hooks, flexible with respect to each individual ops Output metadata.One application of this is in dynamically applying tags to runs based on the metadata of the last failed/successful run.
Ideas of implementation
If a hook is present, we currently initialize a
step_output_capture
dict here:dagster/python_modules/dagster/dagster/_core/execution/context/system.py
Lines 565 to 569 in 29f6aa7
then, we capture the step output value here:
dagster/python_modules/dagster/dagster/_core/execution/plan/execute_step.py
Lines 573 to 574 in 29f6aa7
and finally, the hook accesses this the
step_output_capture
dict here:dagster/python_modules/dagster/dagster/_core/execution/context/hook.py
Lines 160 to 186 in 29f6aa7
Implementation:
Option 1: One proposed solution would be to change what gets stored in
step_context.step_output_capture
, to include both{"value": output.value
,"metadata": output.metadata}
. This is a relatively simple patch, but it will break nearly all applications that currently callHookContext.op_output_values
, since we would be returning adict
now, instead of a single output value.Option 2: My preferred solution is to replicate the
step_output_capture
behaviour with the_output_metadata
property currently available here:dagster/python_modules/dagster/dagster/_core/execution/context/system.py
Line 571 in 29f6aa7
We could then add the following line:
step_context.output_metadata[step_output_handle] = output.metadata
toexecute_step.py
and a
solid_output_metadata
/op_output_metadata
method tohooks.py
Additional information
N/A
Message from the maintainers
Impacted by this issue? Give it a 👍! We factor engagement into prioritization.
The text was updated successfully, but these errors were encountered: