Robert Lawson
08/23/2023, 1:37 PMParam "command" is not a str. Got ['build', '--vars', '{"key": "value"}'] which is type <class 'list'>.
dbt_build_invocation = dbt.cli(["build", "--vars", json.dumps(dbt_vars)], context=context)
yield from dbt_build_invocation.stream()
rex
08/23/2023, 2:24 PMDbtCliResource
?Robert Lawson
08/23/2023, 2:27 PMfrom dagster_dbt import (
dbt_cli_resource,
load_assets_from_dbt_project,
dbt_assets,
DbtCliResource,
DagsterDbtTranslator
)
.........
def my_dbt_assets(context: OpExecutionContext, dbt: DbtCliResource):
dbt_vars = {"key": "value"}
<http://context.log.info|context.log.info>("Running my_dbt_assets")
# dbt_build_invocation = dbt.cli(" ".join(["build", "--vars", json.dumps(dbt_vars)]), context=context)
# yield from dbt_build_invocation.stream()
run_command = " ".join(["run", "--vars", json.dumps(dbt_vars)])
<http://context.log.info|context.log.info>(f"Running dbt command NO CONTEXT: {run_command}")
# yield from dbt.cli(run_command, context=context).stream()
yield from dbt.cli(run_command).stream()
yield from dbt.cli("test").stream()
Robert Lawson
08/23/2023, 2:28 PM~/.local/lib/python3.10/site-packages/dagster_dbt/cli/resources.py
Robert Lawson
08/23/2023, 2:28 PM" ".join([the_commands])
and removing the context
argRobert Lawson
08/23/2023, 2:29 PMjson.dumps
rex
08/23/2023, 2:31 PMdbt_cli_resource
, not DbtCliResource
. dbt_cli_resource
is deprecated and is the old resource.rex
08/23/2023, 2:32 PMRobert Lawson
08/23/2023, 2:32 PMRobert Lawson
08/23/2023, 2:32 PM# "dbt": dbt_cli_resource.configured(
# {
# "project_dir": DBT_PROJECT_PATH,
# "profiles_dir": DBT_PROFILES,
# }
# ),
Thanks!rex
08/23/2023, 2:46 PMRobert Lawson
08/23/2023, 2:47 PMrex
08/23/2023, 2:49 PM: DbtCliResource
🙂Robert Lawson
08/23/2023, 2:49 PMRobert Lawson
08/23/2023, 2:49 PMRobert Lawson
08/23/2023, 2:50 PMrex
08/23/2023, 2:51 PMRobert Lawson
08/23/2023, 3:10 PMdocker compose exec dagit cat /opt/dagster/dagster_home/modules/batch_puller/batch_puller/models/batch_product_data/stg_batch_data.sql
... this shows up to date sql!
But then in the dagit ui I go to deployment and reload the module, and when I check the definition for stg_batch_data it's still out of date... maybe a result of having previously used load_assets_from_dbt_project
?rex
08/23/2023, 3:14 PMload_assets_from_dbt_project
such as:
• Random file contention
• Incurs a ton of latency when compiling the manifest for large projects
• Incurs repeated latency since it must be done for each run/code location/etc
So we don't really recommend using it. But we do give you an escape hatch if you want to use this behavior for local development: https://dagster.slack.com/archives/C04CW71AGBW/p1690395671541379?thread_ts=1690388053.337689&cid=C04CW71AGBWRobert Lawson
08/23/2023, 3:15 PMrex
08/23/2023, 3:18 PMload_assets_from_dbt_project
, then you should recompile your dbt manifest using your CLI. e.g.
dbt parse
Dagster uses this manifest to understand the state of your dbt project (which is why you pass it into @dbt_assets
)