-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
load_via_dbt_ls() requires dbt is installed in base airflow environment #670
Comments
🤖 Hello @dylanharper-qz, Nice to meet you! I'm Dosu, an AI bot, here to assist you with your questions, bugs, and help you with your contributions to the Cosmos project. While we wait for a human maintainer, I'll do my best to provide you with some immediate help. I see you've posted an issue about |
🤖 Thank you for bringing this to our attention. The error you're encountering is due to the The A similar issue was encountered in the past (issue #401) and was resolved by a pull request (PR #402). The changes made in the pull request involve the addition of a condition to check if the execution mode is However, since you're still encountering this issue in version 1.2.2, it's possible that your setup doesn't meet these conditions or there might be a different underlying issue. To help us better understand and resolve your issue, could you please provide more information about your setup? Specifically, we would like to know:
This information will help us determine if the issue is with the SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
@dosu-bot, thank you.
|
🤖 Based on the information you've provided and the context from the Cosmos repository, it seems like the issue you're encountering is related to how Cosmos is trying to find the dbt executable. The If your dbt executable is in a virtual environment and not in the system's PATH, To resolve this issue, you could modify the import os
import shutil
def get_system_dbt() -> str:
"""
Tries to identify which is the path to the dbt executable, return "dbt" otherwise.
"""
# Try to find the dbt executable in the system's PATH
dbt_path = shutil.which("dbt")
# If the dbt executable wasn't found in the system's PATH, try to find it in the virtual environment
if dbt_path is None:
venv_path = os.environ.get('VIRTUAL_ENV')
if venv_path is not None:
dbt_path = os.path.join(venv_path, 'bin', 'dbt')
# If the dbt executable wasn't found in the virtual environment either, return "dbt"
return dbt_path or "dbt" This modified function first tries to find the dbt executable in the system's PATH. If it doesn't find it there, it tries to find it in the virtual environment. If it doesn't find it in either of these places, it returns "dbt". In the context shared, you can also set the I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
@dosu-bot I have confirmed that setting Thank you, you have been very helpful. |
🤖 Based on the information you've provided and the similar issues I found in the Cosmos repository, setting The In the context shared, the Additionally, the Here is the relevant code: def validate_dbt_command(self, fallback_cmd: str | Path = "") -> None:
"""
When using LoadMode.DBT_LS, the dbt executable path is necessary for rendering.
Validates that the original dbt command works, if not, attempt to use the fallback_dbt_cmd.
If neither works, raise an exception.
The fallback behaviour is necessary for Cosmos < 1.2.2 backwards compatibility.
"""
if not shutil.which(self.dbt_executable_path):
if isinstance(fallback_cmd, Path):
fallback_cmd = fallback_cmd.as_posix()
if fallback_cmd and shutil.which(fallback_cmd):
self.dbt_executable_path = fallback_cmd
else:
raise CosmosConfigException(
"Unable to find the dbt executable, attempted: "
f"<{self.dbt_executable_path}>" + (f" and <{fallback_cmd}>." if fallback_cmd else ".")
) So, if you are getting the error For more information, you can refer to the following sources: I hope this helps! If you have any other questions, feel free to ask. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Apologies if I'm misunderstanding anything here, we're big fans of Cosmos at Quizlet.
In version 1.2.2, we are seeing this error when using
LoadMode.DBT_LS
:If we add dbt to our default airflow environment, the dag works as expected.
It is required to install dbt outside of the venv described in the docs?
This code seems to be checking for dbt in the airflow environment:
astronomer-cosmos/cosmos/dbt/graph.py
Lines 232 to 233 in 6e41471
The text was updated successfully, but these errors were encountered: