How to provide deps
to graph_asset
s?
#15443
Answered
by
clairelin135
clairelin135
asked this question in
Q&A
-
Currently, |
Beta Was this translation helpful? Give feedback.
Answered by
clairelin135
Jul 20, 2023
Replies: 2 comments 1 reply
-
Here's an example: from dagster import graph_asset, asset, AssetIn, op, Nothing, In
@asset
def upstream():
...
@op(ins={"upstream": In(Nothing)})
def my_op():
return ...
@graph_asset(
ins={"upstream": AssetIn(dagster_type=Nothing)},
)
def my_graph_asset(upstream):
return my_op(upstream)
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
clairelin135
-
If you're looking to construct a set of deps programmatically instead of hardcoding a set of arguments to your function, you can do something like this: from typing import Sequence
from dagster import AssetIn, AssetKey, In, Nothing, graph_asset, materialize, op
deps = [AssetKey("a"), AssetKey("b")]
@op(ins={dep.to_python_identifier(): In(Nothing) for dep in deps})
def inner(**kwargs):
pass
@graph_asset(ins={dep.to_python_identifier(): AssetIn(dep) for dep in deps})
def my_graph_asset(**kwargs):
return inner(**kwargs) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an example: