Hi Folks :wave: - I'm relatively comfortable using...
# ask-community
m
Hi Folks 👋 - I'm relatively comfortable using the classic approach of python functions as ops composed into graphs and then providing resources via the “to_job” call on the graph but now I need to use a DBT project in addition to python ops. I'm struggling to put together a barebones job which uses DBT to update a table in snowflake, then load that table via a custom IO manager into a python function (op) and do some work on it. I've read through the docs and feel I'm close with what is laid out here: https://docs.dagster.io/integrations/dbt#defining-downstream-dependencies because I can materialize all assets in my DBT project without issue. However I am struggling to put it all together as I'm not yet comfortable with using assets. I am struggling to understand how I would add the downstream, python generated asset to a job with the DBT assets. Is there something more fundamental I skipped over in the docs?
🌈 1
o
hey @Martin O'Leary! the process of building a job out of assets definitely looks a bit different than building a job out of ops, and that docs page doesn't really go into the details of that part of the story. The docs for that bit live here: https://docs.dagster.io/concepts/ops-jobs-graphs/jobs#from-software-defined-assets, and there's also a more built-out example repo showing python assets + dbt assets here: https://github.com/dagster-io/dagster/tree/master/examples/dbt_python_assets. But just at a high level, the shape of the solution will look something like:
Copy code
from dagster import repository, with_resources, define_asset_job

dbt_assets = load_assets_from_dbt_project(..., io_manager_key="my_special_io_manager")

@asset
def my_extra_work_asset(dbt_model_name):
    # do extra work

# define a job that will rematerialize all assets in the repository
rematerialize_all_job = define_asset_job(name="rematerialize_all", selection="*")

@repository
def my_repo():
    return [
        # apply a set of resources to all of the assets
        with_resources([*dbt_assets, my_extra_work_asset], resource_defs="the resources you would have passed into to_job()"),
        rematerialize_all_job,
    ]
the shift in mental model is essentially that now, once an asset is place on the repository, it contains all of the necessary information to materialize, which includes the resources that it will need to access. this frees up the asset-based job definitions to be a lighter-weight selection of the assets that you want to rematerialize (so they no longer contain the resource definitions)
m
That looks exactly like what I'm looking for @owen - thank you! I'm on my phone now but will check this out when I get to me keyboard and validate.
o
great! let me know if you run into any issues getting that set up 🙂
👍 1