Ian Venter
03/22/2023, 2:36 AMfrom dagster_dbt import dbt_cli_resource
import assets as assets
from assets import DBT_PROFILES, DBT_PROJECT_PATH
from dagster import load_assets_from_modules, materialize
#Assets loaded from dbt require a dbt resource, which is responsible for firing off dbt CLI commands.
#Using the 'dbt_cli_resource' resource, we can supply a dbt resource to the dbt project.
#
my_resources = {
"dbt": dbt_cli_resource.configured(
{
"project_dir": DBT_PROJECT_PATH,
"profiles_dir": DBT_PROFILES
},
),
}
all_assets = load_assets_from_modules([assets])
if __name__ == "__main__":
materialize(assets=all_assets, resources=my_resources)
rex
03/22/2023, 2:59 AMmaterialize
and materialize_to_memory
are meant for usage in tests.
The metadata that Dagit reads from is determined by $DAGSTER_HOME
, so if you want this script to write to the same store as your Dagit instance, $DAGSTER_HOME
should be set and be the same value in the process that runs your script and in the process that runs your webserver.sandy
03/22/2023, 5:25 PMdagster asset materialize
command line interfaceIan Venter
03/25/2023, 9:22 AM