Hi Dagster! Probably a simple one but what's the c...
# ask-community
u
Hi Dagster! Probably a simple one but what's the correct way to reference a dbt asset inside a
selection
clause for a job?
Copy code
# dbt_project.yml
models:
  retail_pipeline_dbt:
    stg_ulta:
      +schema: stg_ulta
Copy code
# dagster_project/assets/dbt.py

dbt_assets = load_assets_from_dbt_project(
    project_dir=DBT_PROJECT_PATH,
    profiles_dir=DBT_PROFILES,
    key_prefix=["ulta_dbt"],
)
Copy code
# dagster_project/assets/__init__.py

from dagster import define_asset_job
from .dbt import dbt_assets 

asset_job = define_asset_job(name='dbt_job', selection=[?])
🤖 1
I've tried various variations of
ulta_dbt/stg_ulta/ulta
with no luck scoured this resource as well : https://docs.dagster.io/0.15.6/integrations/dbt will happily edit the page with an example
ah figured it out! looking through the db was useful
from dagster import AssetKey
then
Copy code
asset_job = define_asset_job(name='dbt_job', selection=[AssetKey(['ulta_dbt', 'stg_ulta', 'ulta']).to_user_string()]
the source code is bril, very self documenting! thanks
s
glad that you were able to figure this out!
💯 1
t
Hi, is it also possible to include all dbt assets from
load_assets_from_dbt_project()
into
define_asset_job()
inside the
selection
clause? Couldn't figure it out yet. Thanks.
s
This should work:
Copy code
dbt_assets = load_assets_from_dbt_project(...)
my_job = define_asset_job("fdjskl", selection=dbt_assets)
t
Definetely tried that before and it didn't worked. Anyway, works like expected now. Thanks sandy 🙂