-
Notifications
You must be signed in to change notification settings - Fork 182
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
Fix running install_deps=True
when using profile_mapping
and ExecutionMode.LOCAL
#658
Comments
🤖 Hello @tatiana, I'm Dosu, a friendly helper bot. I'm here to assist you with your technical difficulties, answer any questions you may have, and help you contribute to our repository. While we wait for a human maintainer to get back to you, feel free to ask me anything. Let's work on this together! Thank you for bringing this issue to our attention. It appears that the problem is related to the environment variables not being set correctly during task execution in the To resolve this, you can modify the def run_command(
self,
cmd: list[str],
env: dict[str, str | bytes | os.PathLike[Any]],
context: Context,
) -> FullOutputSubprocessResult:
"""
Copies the dbt project to a temporary directory and runs the command.
"""
with tempfile.TemporaryDirectory() as tmp_dir:
logger.info(
"Cloning project to writable temp directory %s from %s",
tmp_dir,
self.project_dir,
)
# need a subfolder because shutil.copytree will fail if the destination dir already exists
tmp_project_dir = os.path.join(tmp_dir, "dbt_project")
shutil.copytree(
self.project_dir,
tmp_project_dir,
)
# Set environment variables
for key, value in env.items():
os.environ[key] = str(value)
subprocess_result: FullOutputSubprocessResult = self.subprocess_hook.run_command(cmd, env)
return subprocess_result This modification ensures that the environment variables are set before the command is run, which should resolve the issue of the profile mapping path not being set during task execution. As for the Please let me know if this solution works for you or if you need further assistance. 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. |
…AL` (#659) Extends the local operator when running `dbt deps` with the provides profile flags. This makes the logic consistent between DAG parsing and task running as referenced below https://github.com/astronomer/astronomer-cosmos/blob/8e2d5908ce89aa98813af6dfd112239e124bd69a/cosmos/dbt/graph.py#L247-L266 Closes: #658
…AL` (#659) Extends the local operator when running `dbt deps` with the provides profile flags. This makes the logic consistent between DAG parsing and task running as referenced below https://github.com/astronomer/astronomer-cosmos/blob/8e2d5908ce89aa98813af6dfd112239e124bd69a/cosmos/dbt/graph.py#L247-L266 Closes: #658 (cherry picked from commit 6e41471)
…AL` (#659) Extends the local operator when running `dbt deps` with the provides profile flags. This makes the logic consistent between DAG parsing and task running as referenced below https://github.com/astronomer/astronomer-cosmos/blob/8e2d5908ce89aa98813af6dfd112239e124bd69a/cosmos/dbt/graph.py#L247-L266 Closes: #658 (cherry picked from commit 6e41471)
…AL` (astronomer#659) Extends the local operator when running `dbt deps` with the provides profile flags. This makes the logic consistent between DAG parsing and task running as referenced below https://github.com/astronomer/astronomer-cosmos/blob/8e2d5908ce89aa98813af6dfd112239e124bd69a/cosmos/dbt/graph.py#L247-L266 Closes: astronomer#658
As of Cosmos 1.2.2, when using
profile_mapping
,install_deps=True
and theExecutionMode.LOCAL
to run dbt commands from within Airflow workers, we are not setting the profile mapping path. ATM, this only works if users useprofiles_yml_filepath
.Exception raised:
Although we're handling this properly during DAG parsing:
astronomer-cosmos/cosmos/dbt/graph.py
Lines 247 to 266 in 8e2d590
We are indeed not passing the additional parameters in task execution:
astronomer-cosmos/cosmos/operators/local.py
Lines 209 to 216 in 8e2d590
The goal of this ticket is to make this logic consistent, fixing the issue in the local.py.
Joppe Vos initially reported this issue in the #airflow-dbt Airflow slack channel:
https://apache-airflow.slack.com/archives/C059CC42E9W/p1699365889141509
The text was updated successfully, but these errors were encountered: