Will Gunadi
05/04/2022, 7:38 PMInvalid --project-dir flag. Not a dbt project. Missing dbt_project.yml file
The container configuration follows this https://docs.dagster.io/deployment/guides/docker#multi-container-docker-deployment
And the config I specify inside the repo is this:
{"project_dir":"/opt/dagster/app/dbt_dev/bb_dbt",
"profiles_dir":"/opt/dagster/app/dbt_profiles",
}
When I docker exec into the _user_code
container, I can see the above directory just fine and the dbt_project.yml is where it should be.
What could be the issue here?
Versions:
Dagster 0.14.13
dbt: 0.20.2prha
05/04/2022, 7:48 PMdagster-dbt
configuration idiosyncracies)Will Gunadi
05/04/2022, 7:50 PMdaniel
05/04/2022, 11:43 PMWill Gunadi
05/05/2022, 12:10 AMdef run_dbt(context, import_ts, table_name):
dbt_result = context.resources.dbt.run(
models=f'incr.{table_name}',
vars=f'{{"import_ts":"{import_ts}"}}')
return dbt_result
What I am curious is where does this "run" command being executed? Which container and in what directory?daniel
05/05/2022, 12:35 AMWill Gunadi
05/05/2022, 2:26 PMbb_dbt = dbt_cli_resource.configured(
{"project_dir":"/opt/dagster/app/dbt_dev/bb_dbt", "profiles_dir":"/opt/dagster/app/dbt_profiles",
}
)
And that bb_dbt resource is being used thusly:
@job(resource_defs={
'dbt': bb_dbt,
})
def a_job():
an_op()
That op (an_op) eventually calls this function (same as above):
def run_dbt(context, import_ts, table_name):
dbt_result = context.resources.dbt.run(
models=f'incr.{table_name}',
vars=f'{{"import_ts":"{import_ts}"}}')
return dbt_result
Also, this is working and tested outside of a docker container.daniel
05/05/2022, 2:27 PMWill Gunadi
05/05/2022, 8:15 PMMegan Beckett
10/27/2022, 9:10 AMdagster_dbt.errors.DagsterDbtCliFatalRuntimeError: Fatal error in the dbt CLI (return code 2): Encountered an error: Runtime Error fatal: Invalid --project-dir flag. Not a dbt project. Missing dbt_project.yml file Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/dbt/main.py", line 129, in main results, succeeded = handle_and_check(args) File "/usr/local/lib/python3.8/site-packages/dbt/main.py", line 191, in handle_and_check task, res = run_from_args(parsed) File "/usr/local/lib/python3.8/site-packages/dbt/main.py", line 218, in run_from_args task = parsed.cls.from_args(args=parsed) File "/usr/local/lib/python3.8/site-packages/dbt/task/base.py", line 184, in from_args move_to_nearest_project_dir(args) File "/usr/local/lib/python3.8/site-packages/dbt/task/base.py", line 171, in move_to_nearest_project_dir nearest_project_dir = get_nearest_project_dir(args) File "/usr/local/lib/python3.8/site-packages/dbt/task/base.py", line 150, in get_nearest_project_dir raise dbt.exceptions.RuntimeException( dbt.exceptions.RuntimeException: Runtime Error fatal: Invalid --project-dir flag. Not a dbt project. Missing dbt_project.yml file
dbt_project.yml
file is there in the DBT project and I have configured where to look for the DBT project directory like this:
Config file:
from dagster._utils import file_relative_path
DBT_PROJECT_DIR = file_relative_path(__file__, "../../striata_sl_dbt")
DBT_PROFILES_DIR = DBT_PROJECT_DIR + "/config"
And assets:
from ..config import DBT_PROJECT_DIR, DBT_PROFILES_DIR
@configured(dbt_cli_resource, config_schema={"target": str})
def custom_dbt_cli_resource(config):
return {
"target": config["target"],
"project-dir": DBT_PROJECT_DIR,
"profiles-dir": DBT_PROFILES_DIR
}
dbt_assets = with_resources(
load_assets_from_dbt_project(
project_dir=DBT_PROJECT_DIR,
node_info_to_group_fn=lambda _: "dbt_assets"),
{
"dbt": custom_dbt_cli_resource
},
)
location_name: dhis2_pipeline
image: image_on_ecr
code_source:
package_name: dhis2_pipeline
When I run dagit
, the dbt project is found and loaded properly. But, on Dagster Cloud, I am getting this issue about not finding the dbt_project.yml
daniel
10/27/2022, 3:15 PMdocker run -it <image> /bin/bash
Sean Lopp
10/27/2022, 3:18 PMtarget
argument. I doubt that is contributing here
I'd be happy to review the Dockerfile if you don't mind sharing itMegan Beckett
10/28/2022, 8:30 AMfrom dagster._utils import file_relative_path
DBT_PROJECT_DIR = file_relative_path(__file__, "../../striata_sl_dbt")
DBT_PROFILES_DIR = DBT_PROJECT_DIR + "/config"
And loads the dbt models as assets with:
@configured(dbt_cli_resource, config_schema={"target": str})
def custom_dbt_cli_resource(config):
return {
"target": config["target"],
"project-dir": DBT_PROJECT_DIR,
"profiles-dir": DBT_PROFILES_DIR
}
dbt_assets = with_resources(
load_assets_from_dbt_project(
project_dir=DBT_PROJECT_DIR,
node_info_to_group_fn=lambda _: "dbt_assets"),
{
"dbt": custom_dbt_cli_resource
},
)
This works when running dagit locally and I referenced the hooli project for the organisation of the folders and dbt project.
@Sean Lopp, this is the dockerfile - very straightforward...
FROM public.ecr.aws/docker/library/python:3.8
WORKDIR /dagster
RUN apt-get update && apt-get install -y git
COPY ./requirements_docker.txt /dagster/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /dagster/requirements.txt
COPY ./dhis2_pipeline /dagster/dhis2_pipeline
COPY ./striata_sl_dbt /dagster/striata_sl_dbt
daniel
10/28/2022, 11:52 AMMegan Beckett
10/28/2022, 12:45 PMlocation_name: dhis2_pipeline
image: image_on_ecr
code_source:
package_name: dhis2_pipeline
daniel
10/28/2022, 2:26 PM2022-10-28 09:30:25 -0500 - dagster.builtin - INFO - Executing command: dbt --no-use-color --log-format json ls --project-dir /Users/dgibson/hooli-data-eng-pipelines/hooli_data_eng/../dbt_project --profiles-dir /Users/dgibson/hooli-data-eng-pipelines/hooli_data_eng/../dbt_project/config --select * --output json
That's the command that's failing, the output might give a clue of where exactly it's looking thoughMegan Beckett
10/31/2022, 10:31 AM