:wave: Is it possible in dagster to define an asse...
# ask-community
r
👋 Is it possible in dagster to define an asset selection which, given a set of assets, it selects only the leaf assets, ie the assets which do not have any downstream asset in the dag? example: let’s say that I have an asset selection which contains the assets A, B, C, and the dag is A -> B -> C, how can I get only asset C?
here is some more context: I have a
DbtManifestAssetSelection
which takes all the dbt models that I want to run. All these models have to run before a downstream asset
A
can run. I’ve put this asset selection as
non_argument_deps
for my downstream asset
A
, but then my dag gets overly complicated because there is a direct link between ALL my dbt models to
A
, so ideally I just want to simplify the dag by creating a dependency between the leaves of the dag given from dbt to my asset
A
so the situation right now is something like this: let’s say the dag from dbt is A -> B -> C and my downstream asset is Z, then the dag looks like
Copy code
A -> B -> C
|    |    |
v    v    v
Z    Z    Z
but I would like to get
A->B->C->Z
btw I’ve already asked in dbt workspace if it is possible to select leaves of a dag but in dbt it’s not possible
c
Hi Riccardo. You could do
AssetSelection.keys(...).sinks()
The
sinks
function searches within the existing asset selection and returns all assets that do not have any downstream dependencies within the existing selection.
🎉 1