https://dagster.io/ logo
#dagster-feedback
Title
# dagster-feedback
t

Tamas Foldi

09/02/2022, 1:25 AM
OK, after spending some time, I still cannot this figure it out, so let me post again. How can I pass a value from a config file to avoid hard coding the dbt project location?
Copy code
from dagster import with_resources, define_asset_job, repository
from dagster_dbt import dbt_cli_resource, load_assets_from_dbt_project

dbt_assets = with_resources(
    load_assets_from_dbt_project("dbt/my-project"),
    {"dbt": dbt_cli_resource},
)
s

sandy

09/02/2022, 4:27 AM
you could do something like:
Copy code
from dagster import with_resources, define_asset_job, repository, config_from_yaml_files
from dagster_dbt import dbt_cli_resource, load_assets_from_dbt_project

config = config_from_yaml_files("my_project_config.yaml")
dbt_assets = with_resources(
    load_assets_from_dbt_project(config["dbt_project_dir"]),
    {"dbt": dbt_cli_resource},
)
and put the following in my_project_config.yaml
Copy code
dbt_project_dir: fdsjklfds
👍 1
or load from an environment vairable
t

Tamas Foldi

09/02/2022, 2:30 PM
thanks, make sense and helps a lot! but shouldn’t we have the config file available as a preloaded object? like why should I load/parse
configuration.yaml
again, if dagster loads it anyway?
s

sandy

09/02/2022, 3:17 PM
dagster's config system is focused on "run config", which is config that's loaded at the time you launch a run. in this case, the config instead needs to be loaded at the "definition-time", i.e. the time you're telling dagster what assets you expect to exist