Madison Schott
07/06/2021, 7:53 PMfatal: Not a dbt project (or any of the parent directories). Missing dbt_project.yml file
Kevin Kho
Madison Schott
07/06/2021, 8:04 PMMadison Schott
07/06/2021, 8:04 PMKevin Kho
Madison Schott
07/06/2021, 8:11 PMwith Flow(name="dbt_flow") as f:
task = DbtShellTask(
profile_name='w_dev',
log_stderr=True,
environment='dev',
dbt_kwargs = {
"type": "snowflake",
"database": x,
"warehouse": x,
"schema": x,
"threads": 200
},
profiles_dir='/Users/madison/.dbt'
)(command='dbt run -m tag:daily')
Madison Schott
07/06/2021, 8:11 PMKevin Kho
Kevin Kho
Kevin Kho
profiles.yml
and dbt_project.yml
in that folder? Read a bit and checking that my understanding is rightMadison Schott
07/06/2021, 8:36 PMMadison Schott
07/06/2021, 8:37 PMMadison Schott
07/06/2021, 8:37 PMKevin Kho
Madison Schott
07/06/2021, 8:51 PMKevin Kho
dbt run
doesn’t work. But I think I understand it now. profiles.yml
is in the profiles_dir
, but dbt run
looks for the dbt_project.yml
in the directory where it runs. So you have dbt run
running in the actual project folder, and it looks for the profiles.yml
in the profiles_dir
.Kevin Kho
profiles_dir
, but dbt run
is not running where you expect it to be. There are two ways I think you can fix this. First, is run the Prefect Agent in the dbt project directory that contains the dbt_project.yml
. It will run the dbt run
on this folder.Kevin Kho
helper script
to navigate to the correct directory. You can try helper_script = "cd /abspath/to/folder"
, and point it to the folder that contains the dbt_project.yml
Madison Schott
07/07/2021, 2:21 PMCA Lee
07/16/2021, 4:32 AMreturn_all
and log_stderr
to True
, but still not seeing any output.
[2021-07-16 04:30:25+0000] INFO - prefect.FlowRunner | Beginning Flow run for 'dbt_flow'
[2021-07-16 04:30:25+0000] INFO - prefect.TaskRunner | Task 'DbtShellTask': Starting task run...
[2021-07-16 04:30:54+0000] INFO - prefect.TaskRunner | Task 'DbtShellTask': Finished task run for task with final state: 'Success'
[2021-07-16 04:30:54+0000] INFO - prefect.FlowRunner | Flow run SUCCESS: all reference tasks succeeded
Kevin Kho
CA Lee
07/17/2021, 4:21 AMKevin Kho
stream_output=True
CA Lee
07/22/2021, 2:24 AMDbtShellTask
?
From the docs:
@task(max_retries=3, retry_delay=timedelta(seconds=10))
However, if I try to wrap the shell task using the Prefect task decorator, I get the below error:
ValueError: Could not infer an active Flow context while creating edge to <Task: DbtShellTask>. This often means you called a task outside a `with Flow(...)` block. If you're trying to run this task outside of a Flow context, you need to call `DbtShellTask(...).run(...)`
This was the code I attempted:
from datetime import timedelta
from prefect import task, Flow
from prefect.tasks.dbt import DbtShellTask
FLOW_NAME = "[daily] [2300] dbt run"
@task(max_retries=3, retry_delay=timedelta(seconds=10))
def dbt_run():
DbtShellTask(
profile_name="jinlee",
environment="dev",
profiles_dir="/home/vscode/.dbt",
helper_script="cd /workspaces/flowstate/transform",
return_all=True,
log_stderr=True,
stream_output=True
)(command='dbt run')
with Flow(
FLOW_NAME,
) as flow:
dbt_run()
flow.run()
Appending .run()
behind the call to DbtShellTask
didn't work as well.Kevin Kho
kwargs
that the @task
decorator does so I think you can do
DbtShellTask(
profile_name="jinlee",
environment="dev",
profiles_dir="/home/vscode/.dbt",
helper_script="cd /workspaces/flowstate/transform",
return_all=True,
log_stderr=True,
stream_output=True,
max_retries=3,
....
)(command='dbt run')
Kevin Kho
.run()
so it would be
@task(max_retries=3, retry_delay=timedelta(seconds=10))
def dbt_run():
DbtShellTask(
profile_name="jinlee",
environment="dev",
profiles_dir="/home/vscode/.dbt",
helper_script="cd /workspaces/flowstate/transform",
return_all=True,
log_stderr=True,
stream_output=True
).run(command='dbt run')
with Flow(
FLOW_NAME,
) as flow:
dbt_run()
flow.run()