Hebo Yang
08/09/2022, 6:27 PMHebo Yang
08/09/2022, 6:33 PMclaire
08/09/2022, 6:48 PM@asset
, you could use AssetsDefinition.from_op
Hebo Yang
08/09/2022, 7:12 PMHebo Yang
08/09/2022, 7:15 PMclaire
08/09/2022, 7:28 PMsource_asset = SourceAsset(key="asset_one")
@op(ins={"upstream": In(Nothing)})
def asset_two():
return 1
@graph
def my_graph(upstream):
return asset_two(upstream)
graph_asset = AssetsDefinition.from_graph(
my_graph, keys_by_input_name={"upstream": AssetKey("asset_one")}
)
If you want to define a non-argument dependency for a graph backed asset, you'll need to define a `Nothing` input on the op that has the upstream asset dependency.Hebo Yang
08/09/2022, 8:02 PMgraph_ins = dict((key, In(Nothing)) for key in source_asset_keys)
@graph(
ins=graph_ins
)
def my_graph():
This is the error
dagster._core.errors.DagsterInvalidDefinitionError: @graph 'my_graph' decorated function does not have parameter(s) 'source_asset_key1', which are in provided input_defs. @graph decorated functions should only have keyword arguments that match input names and, if system information is required, a first positional parameter named 'context'.
Hebo Yang
08/09/2022, 8:03 PMHebo Yang
08/09/2022, 8:13 PMclaire
08/09/2022, 8:40 PM@graph
decorated function must contain explicit argument names and pass them to ops within the function. This is because Dagster flattens graphs to build a flat mapping of ops, so any input to an op within the graph must be mapped to a graph input.
You could try to programmatically define the graph: https://docs.dagster.io/concepts/ops-jobs-graphs/graphs#using-graphdefinitionsHebo Yang
08/12/2022, 10:27 PM_build_all_node_defs
“Detected conflicting node definitions with the same name”. This is due to the node_defs having “build_dependencies” with asset inputs and somehow another node_def was generated (I guess from dependencies parameter) which doesn’t have the asset inputs
• If I include them, I get another error Invalid dependencies: node "xxx" not found in node list
. I guess I’d need to somehow include source input assets to GraphDefinition?claire
08/12/2022, 10:32 PM