Skip to content

How to specify upstream asset dependencies when using AssetsDefinition.from_graph() ? #18290

Answered by benpankow
dagsir[bot] bot asked this question in Q&A
Discussion options

You must be logged in to vote

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={
        "…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@axellpadilla
Comment options

@axellpadilla
Comment options

Answer selected by benpankow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: ops/graphs/jobs Related to Dagster ops, graphs and jobs area: asset Related to Software-Defined Assets
2 participants