-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
provide context class based on type hint #16759
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
3011279
to
5450524
Compare
|
||
# TODO - i dont know how to move this check to Definition time since we don't know if the op is | ||
# part of a graph-backed asset until we have the step execution context, i think | ||
if context_annotation is AssetExecutionContext and not is_sda_step: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to move this check to definition time, but i dont know if we can. At definition time, I dont know of a way to know if
@op
def my_op(context: AssetExecutionContext)
is being used in a job or in a graph-backed asset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this makes sense
nit: would reframe the comment before land to something like "would be nice to ... currently doesnt seem possible"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok cool, will update
f8b50e1
to
c355260
Compare
5450524
to
c385c3f
Compare
c355260
to
4715a30
Compare
c385c3f
to
f45c313
Compare
4715a30
to
c925179
Compare
f45c313
to
6c91460
Compare
|
||
# TODO - i dont know how to move this check to Definition time since we don't know if the op is | ||
# part of a graph-backed asset until we have the step execution context, i think | ||
if context_annotation is AssetExecutionContext and not is_sda_step: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this makes sense
nit: would reframe the comment before land to something like "would be nice to ... currently doesnt seem possible"
note I would classify these new errors as breaking changes so, make sure it waits for the 1.5 release and get documented accordingly |
6c91460
to
f9601c3
Compare
yes, i agree. I think the last release branch before 1.5 has been cut, so this should be good to go in any time. i'll make a note to give this behavior change a callout in the changelog |
b447c3b
to
c240643
Compare
e373310
to
75c8b69
Compare
75c8b69
to
d81f8f3
Compare
Summary & Motivation
Introduces the logic to determine which kind of context to provide to which kind of step.
Follows these rules:
note: We error when
AssetExecutionContext
type hint is provided to@op
because we will likely require anAssetsDefinition
in the__init__
ofAssetExecutionContext
once we begin to split methods out (see here). It will be easier to make a change allowing theAssetExecutionContext
type annotation than it will be to disallow it, so I think we should error in this case for nowFor ops in graph-backed assets, we do:
The reasoning behind
@graph_asset @op + no type annotation -> OpExecutionContext
is best explained with an example:Imagine you have an op that is used in both a job and a graph-backed asset
When executing
my_fun_job
,my_fun_op
will receive anOpExecutionContext
and run as expected. When materializingmy_fun_asset
,my_fun_op
will receive anAssetExecutionContext
. It will fire a deprecation warning, but still calldescribe_op
on the internally heldop_execution_context
. When we deprecate the__get_attr__
behavior here,my_fun_op
will instead error.How I Tested These Changes
new unit tests