https://dagster.io/ logo
Title
s

Spencer Nelson

02/08/2023, 5:45 PM
I’m trying to think about how I use code that mixes Assets, Ops, Graphs, and Jobs. I know I can use Ops in an Asset-centric workflow by using Graph-Backed Assets, or even with
AssetDefinition.from_op
. So if I have a Job from
define_asset_job
, I can reuse my Ops But can I go the other direction? Can I use assets in a non-asset Job? Can I build a
Graph
out of a pile of Assets?
a

Ansel Boero

02/08/2023, 11:23 PM
I am also interested to. Is it possible to include an op that sends an email for example, as last operation of a job that creates multiple assets using the
define_asset_job
function? Alternatively, what is the best approach to include an op at the end of a job that materializes multiple assets?
r

Rasmus Bonnevie

02/09/2023, 11:11 AM
when I got started with Dagster I assumed this would be a very common pattern, but I've found it quite hard to apply 😞 you can load assets in a script using the asset loader on the
Definitions
, but since the jobs have to be defined prior to the definition object, the jobs are in a sense more limited than the scripts?
s

Spencer Nelson

02/09/2023, 5:51 PM
This seems like a common question. Are we missing something? How do you use Assets and Ops together?
2
s

sean

02/10/2023, 4:08 PM
But can I go the other direction? Can I use assets in a non-asset Job?
You can do whatever you want materialize a non-SDA asset inside an op and represent that with
context.log_event(AssetMaterialization(asset_key="foo"))
Can I build a Graph out of a pile of Assets?
No, dagster graphs (i.e.
GraphDefinition
,
@graph
) are built out of ops, but multiple
@asset
from an implicit graph via references between asset keys. That said, we’re well aware our docs are weak here and we are working to address it-- a new guide will be up soon: https://github.com/dagster-io/dagster/pull/12204
r

Roel Hogervorst

03/10/2023, 3:40 PM
I think I stil miss it. Can I load an asset into a job? Like depend on an asset for another op?
2