But where is "graph_asset" defined? Or is this som...
# ask-community
r
But where is "graph_asset" defined? Or is this some kind of default name?
v
In this case
"graph_asset"
would just be the name scoped to the job created by
define_asset_job()
. You could pass any other string to it.
r
What is it labeling though? Suppose I had 2 graphs here and 2 jobs corresponding to these graphs..how would i keep them straight
if i understand you right, here the job "graph_asset" corresponds to the job defined in the assets array in Definitions
in other words is definitions positional? first asset with first job, second with second job, and so on?
v
Try this:
Copy code
my_asset = AssetsDefinition.from_graph(my_graph, keys_by_output_name={"result": AssetKey("my_asset")})
my_job = define_asset_job("my_job", selection=["my_asset"])

my_other_asset = AssetsDefinition.from_graph(my_other_graph, keys_by_output_name={"result": AssetKey("my_other_asset"))
my_other_job = define_asset_job("my_other_job", selection=["my_other_asset"])

defs = Definitions(
    assets=[my_asset, my_other_asset],
    jobs=[my_job, my_other_job],
)
r
Aha, the lineage now is way clearer! Thanks! How does the example in the docs get away without such explicit definition? Because its only one?
v
I think someone from the Dagster team will be better equipped to answer that. I’ve only used explicit definitions.
r
with you on being explicit!!!
j
Hi @Rahul Dave if you don’t provide an explicit selection to
define_asset_job
it will create a job that will materialize all of the assets in your definition. So you could in theory have jobs for each asset by providing the
selection
parameter and then one encompassing job that can materialize every single asset