PrefectHQ / prefect-dbt

Collection of Prefect integrations for working with dbt with your Prefect flows.

Home Page:https://prefecthq.github.io/prefect-dbt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TargetConfigs' credentials gets dropped upon loading a DbtCliProfile

ahuang11 opened this issue · comments

commented
from prefect import flow
from prefect_gcp import GcpCredentials
from prefect_dbt.cli import BigQueryTargetConfigs, DbtCliProfile

ENV = "abc"

@flow
def test_flow():
    credentials = GcpCredentials.load('gcp-credentials')
    bq_target_dict = {
        'schema': f'zone_hawk_{ENV}',
        'project': 'my_gcp_project',
        'threads': 20,
        'credentials': credentials
    }

    bq_target_configs = BigQueryTargetConfigs(**bq_target_dict)
    bq_target_configs.save(f'bq-target-configs-{ENV}', overwrite=True)

    target_configs = BigQueryTargetConfigs.load(f'bq-target-configs-{ENV}')
    dbt_cli_dict = {
        'name': 'bigbird',
        'target': f'{ENV}',
        'target_configs': target_configs
    }
    dbt_cli_profile = DbtCliProfile(**dbt_cli_dict)
    dbt_cli_profile.save(f'dbt-cli-profile-{ENV}', overwrite=True)
    print(dbt_cli_profile)

    dbt_cli_profile2 = DbtCliProfile.load(f"dbt-cli-profile-{ENV}")
    return dbt_cli_profile2

test_flow()

Returns:


DbtCliProfile(name='bigbird', target='abc', target_configs=TargetConfigs(extras=None, type='bigquery', threads=20), global_configs=None)

Expected:


DbtCliProfile(name='bigbird', target='abc', target_configs=BigQueryTargetConfigs(extras=None, type='bigquery', threads=20, project='my_gcp_project', credentials=GcpCredentials(service_account_file=None, service_account_info=SecretDict('{'type': '**********', 'auth_uri': '**********', 'client_id': '**********', 'token_uri': '**********', 'project_id': '**********', 'private_key': '**********', 'client_email': '**********', 'private_key_id': '**********', 'client_x509_cert_url': '**********', 'auth_provider_x509_cert_url': '**********'}'), project='myproject')), global_configs=None)