Hi folks, I am experimenting with the AssetsDefini...
# ask-community
c
Hi folks, I am experimenting with the AssetsDefinition.from_graph, but somehow got the error like this: dagster._check.CheckError: Invariant failed. Description: All leaf nodes within graph 'option_name_process' must generate outputs which are mapped to outputs of the graph, and produce assets. The following leaf node(s) are non-asset producing ops: {'upload_processed_option_names'}. This behavior is not currently supported because these ops are not required for the creation of the associated asset(s). the graph has three very basic ops, i think it is complaining that the leaf node op is not asset producing, so my question is what qualifies as asset producing op ?
d
I am experimenting with SDA as well and getting same error with a contrived example:
Copy code
@op
def op1():
    return "hello"


@op
def op2(my_str: str):
    return "hello there"


@graph
def test_graph():
    op2(op1())

test_asset = AssetsDefinition.from_graph(test_graph)

@repository
def test_repo():
    return [
        test_asset,
        define_asset_job(
            name="test_asset_job"
        )
    ]
Copy code
UserWarning: Error loading repository location test_repo.py:dagster._check.CheckError: Invariant failed. Description: All leaf nodes within graph 'test_graph' must generate outputs which are mapped to outputs of the graph, and produce assets. The following leaf node(s) are non-asset producing ops: {'op2'}. This behavior is not currently supported because these ops are not required for the creation of the associated asset(s).
c
your graph function might need to explicitly capture/return the value you're returning from op2 and define your output as an out in the graph function decorator like this:
Copy code
@graph(out={"first_asset": GraphOut(), "second_asset": GraphOut()})
def two_assets_graph(upstream_asset):
    one, two = two_outputs(upstream_asset)
    return {"first_asset": one, "second_asset": two}


two_assets = AssetsDefinition.from_graph(two_assets_graph)
👍 2
j
Hi! Carter is correct, the graph itself becomes the asset, so it needs to return the value for the asset. Looks like our docs miss that in a couple cases, so i'll go through and clean it up
🙏 1
👍 1
131 Views