-
Hey, is it possible to speciy upstream asset depedencies when using AssetsDefinition.from_graph() ? The question was originally asked in Dagster Slack. |
Beta Was this translation helpful? Give feedback.
Answered by
benpankow
Nov 28, 2023
Replies: 1 comment 2 replies
-
Yes - inputs to the graph are assumed to map to upstream asset dependencies. For example, given the following graph: @op(ins={"usernames": In(List[str])})
def process_users() -> List[str]:
...
@op(ins={"transatctions": In(Dict[str, int])})
def process_transactions() -> Dict[str, str]:
...
@op(
ins={"processed_users": In(List[str]), "processed_transactions": In(Dict[str, str])},
out={"results": Out(int)}
)
def process_results() -> int:
...
@graph
def my_graph():
return process_results(process_users(), process_transactions()) You can attach asset keys to the inputs as follows: assets = AssetsDefinition.from_graph(
my_graph,
keys_by_input_name={
"usernames": AssetKey("usernames"),
"transactions": AssetKey("transactions"),
},
keys_by_output_name={"results": AssetKey("processed_results")},
) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
benpankow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes - inputs to the graph are assumed to map to upstream asset dependencies. For example, given the following graph:
You can attach asset keys to the inputs as follows: