Hi, I'm hitting a recurring error when trying to r...
# prefect-community
g
Hi, I'm hitting a recurring error when trying to run DbtShellTask:
AttributeError: module 'prefect.tasks' has no attribute 'dbt'
. I've tried to run this locally and within the jupyter-scipy Docker image. Any thoughts why Prefect cannot find the module?
Copy code
# dbt_shell_task.py

import sys
import prefect
from prefect import task, flow, get_run_logger


@flow
def dbt_flow(cmd='dbt run'):

    # Execute specified command
    task = prefect.tasks.dbt.dbt.DbtShellTask(
        command=cmd,
        profile_name='default',
        environment='Development',
        dbt_kwargs={'type': 'bigquery'},
        overwrite_profiles=False,
        profiles_dir='/home/jovyan/.dbt/profiles.yml'
    )
    logger = get_run_logger()
    <http://logger.info|logger.info>("Command Run: %s!", name)
    return task

if __name__ == "__main__":
    cmd = sys.argv[1]
    dbt_flow(cmd)
Copy code
# packages
prefect==2.6.6
prefect-dbt==0.2.4
prefect-shell==0.1.3
dbt-bigquery==1.3.0
dbt-core==1.3.0
dbt-extractor==0.4.1
1
j
Hi Gordon. It looks like you’re mostly using Prefect 2 code, but trying to use DbtShellTask, which looks like it’s part of Prefect 1. I think you need to want to follow something like this example: https://github.com/PrefectHQ/prefect-dbt#execute-a-dbt-cli-command
g
Thanks @Jeff Hale!
👍 1