Hi! I need help. I am trying to use `define_asset...
# ask-community
r
Hi! I need help. I am trying to use
define_asset_job
with both source & regular assets. I have an asset group with both types of assets in it. f I use
AssetSelection.groups
I get the error:
Asset selection specified both regular assets and source assets. This is not currently supported. Selections must be all regular assets or all source assets.
I'm even more confused because I have a different job that points to another group mixing both types of assets. That one loads successfully. šŸ˜•
šŸ¤– 1
I think I may be misunderstanding what source assets are. I have a dbt project and I assumed that all assets loaded with
load_assets_from_dbt_project
would be source assets. When I look at the job that is working, the dbt assets are coming up as regular assets, but not on the job that is not working.
so, the dbt assets that are explicitly used as inputs on dagster software-defined assets get categorized as "SourceAsset", causing this issue.
how can I work around it?
s
Hi Remi, thanks for reaching out. We recently started allowing
define_asset_job
to specify source assets, but it is a (temporary) limitation that we canā€™t allow both observable source and regular assets to be included in the same job, so selections including both will error. This is not meant to happen unless you explicitly specify a key for both a source asset and regular asset. Looks like the issue with
groups
was just an oversight, it should resolve only to regular assets. We are releasing tmrw and I can patch this for that release.
r
thanks for the quick reply @sean Actually, I just solved out my issue! I was mistakenly using
SourceAsset
to reference dbt models instead of
AssetIn
.
s
ah great-- well you found a bug in any case
r
yeah I see that šŸ™‚
I was doing:
Copy code
dbt_asset = SourceAsset(key=["warehouse", DBT_SCHEMA, "dbt_asset"])

@asset
def es_index_profiles_v3b(context,
                          dbt_asset):
    ...
but I meant:
Copy code
dbt_asset = AssetIn(key=["warehouse", DBT_SCHEMA, "dbt_asset"])

@asset
def es_index_profiles_v3b(context,
                          dbt_asset):
    ...
I'm still unclear what
SourceAsset
really is
s
A
SourceAsset
represents a data asset that you want to use as an input but that Dagster doesnā€™t know how to compute. e.g. maybe the result of a request from some web api
r
I see. So it's similar to dbt sources right? I can declare it to document that a dagster depends on an external asset.
s
Iā€™m not very familiar with dbt so I canā€™t speak to its similarity, but yes, you can ā€œdeclare it to document that dagster depends on an external assetā€.
r
thank you. I appreciate the help @sean!