Guy McCombe
07/26/2023, 3:10 PM@dbt_assets
decorator to be able to specify a target and a selection, but I can't get past this error message - any tips? (error & code in replies)Guy McCombe
07/26/2023, 3:10 PMGuy McCombe
07/26/2023, 3:10 PMfrom tennis.constants import dbt_config
manifest_path = Path(dbt_config["project_dir"]) / "target" / "manifest.json"
assert manifest_path.exists()
@dbt_assets(
manifest=manifest_path,
select="tag:atp",
)
def atp_assets(context: OpExecutionContext, dbt_atp: DbtCliResource):
yield from dbt_atp.cli(["build"], context=context).stream()
atp_cli_resource = DbtCliResource(
project_dir=dbt_config["project_dir"],
target="atp",
)
Guy McCombe
07/26/2023, 3:12 PMrex
07/26/2023, 3:15 PMrex
07/26/2023, 3:15 PMGuy McCombe
07/26/2023, 3:19 PMGuy McCombe
07/26/2023, 3:23 PMGuy McCombe
07/26/2023, 3:25 PMJulius
07/26/2023, 3:40 PMJulius
07/26/2023, 3:40 PMGuy McCombe
07/26/2023, 3:41 PMJulius
07/26/2023, 3:42 PMDBT_PROJECT_PATH = file_relative_path(__file__, "dbt")
DBT_PROFILES = file_relative_path(__file__, "dbt/config")
Julius
07/26/2023, 3:42 PMJulius
07/26/2023, 3:42 PMGuy McCombe
07/26/2023, 3:44 PM@dbt_assets(...)
def atp_assets(context: OpExecutionContext, dbt: DbtCliResource):
yield from dbt.cli(["build", "--profiles-dir", DBT_PROFILES], context=context).stream()
Guy McCombe
07/26/2023, 3:44 PMJulius
07/26/2023, 3:45 PMGuy McCombe
07/26/2023, 3:45 PMrex
07/26/2023, 4:04 PM--profiles-dir
as config on the `DbtCliResource`:
atp_cli_resource = DbtCliResource(
project_dir=dbt_config["project_dir"],
global_config_flags=["--profiles-dir", DBT_PROFILES],
target="atp",
)
(2) Currently your profiles.yml
is in dbt/config
. If you put your it in the root of your dbt project, in dbt/
then this should work without needing to do (1)Julius
07/26/2023, 4:11 PMDBT_PROJECT_PATH = file_relative_path(__file__, "dbt")
DBT_PROFILES = file_relative_path(__file__, "dbt/config")
resources = {
"dbt": DbtCliResource(
project_dir=DBT_PROJECT_PATH,
profiles_dir=DBT_PROFILES,
global_config_flags=["--no-use-colors"],
profile="gnm_dwh",
target="dev",
),
}
I'm already do this, so it different from global_config_flags and global_config_flags. Its working on my local but I got that error when using Cloud versionJulius
07/26/2023, 4:12 PMGuy McCombe
07/28/2023, 5:43 PMUsage: dbt [OPTIONS] COMMAND [ARGS]...
Try 'dbt -h' for help. Error: No such option: --profiles-dir
when specifying the profiles dir in global_config_flags
rex
07/28/2023, 9:14 PM--profiles-dir
is not global config.
• I have an open PR in dbt core that is along this same vein: https://github.com/dbt-labs/dbt-core/pull/7920. Should probably try to get that in and make --profile-dir
global config as well.
• If you don’t want to specific --profiles-dir
for every single command that you invoke, you could probably just set DBT_PROFILE_DIR
as an env var to replicate global config: https://docs.getdbt.com/docs/core/connect-data-platform/connection-profiles#2-use-the-dbt_profiles_dir-environ[…]able-to-change-the-default-location