https://dagster.io/ logo
Title
u

Umar Hussain

01/10/2023, 6:37 PM
Hi Dagster! Probably a simple one but what's the correct way to reference a dbt asset inside a
selection
clause for a job?
# dbt_project.yml
models:
  retail_pipeline_dbt:
    stg_ulta:
      +schema: stg_ulta
# 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"],
)
# 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=[?])
:dagster-bot-resolve: 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
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

sandy

01/10/2023, 9:33 PM
glad that you were able to figure this out!
💯 1
t

Thomas Weit

02/14/2023, 10:13 AM
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

sandy

02/15/2023, 12:41 AM
This should work:
dbt_assets = load_assets_from_dbt_project(...)
my_job = define_asset_job("fdjskl", selection=dbt_assets)
t

Thomas Weit

02/15/2023, 10:22 AM
Definetely tried that before and it didn't worked. Anyway, works like expected now. Thanks sandy 🙂