-
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
[Bug] RuntimeError: Detected recursive loop for /usr/local/airflow/dags/dbt/dbt_venv/lib #1076
Comments
To resolve the
Here’s an example of how you can update your import os
from datetime import datetime
from cosmos import DbtDag, ProjectConfig, ProfileConfig, ExecutionConfig
from cosmos.profiles import GoogleCloudServiceAccountDictProfileMapping
profile_config = ProfileConfig(
profile_name="default",
target_name="dev",
profile_mapping=GoogleCloudServiceAccountDictProfileMapping(
conn_id="google_cloud_default",
profile_args={"schema": "public"},
),
)
execution_config = ExecutionConfig(
execution_mode=ExecutionMode.LOCAL,
dbt_executable_path=f"{os.environ['AIRFLOW_HOME']}/dbt_venv/bin/dbt",
)
my_cosmos_dag = DbtDag(
project_config=ProjectConfig(
"/usr/local/airflow/dags/my_dbt_project",
),
profile_config=profile_config,
execution_config=execution_config,
schedule_interval="@daily",
start_date=datetime(2023, 1, 1),
catchup=False,
dag_id="my_cosmos_dag",
default_args={"retries": 2},
) By ensuring that the |
Hi @oliverrmaa , thanks for the detailed description, this is very helpful! Are you storing the dbt project files in Is Would it be possible to not have |
@oliverrmaa the root cause is that the Airflow DAGs folder contains a Although Cosmos is not introducing this issue, we spiked on the implementation of two functions and a command line that could help clean up the DAGs directory during the deployment, which we shared today: #1115 We made this change available in an Alpha release: https://github.com/astronomer/astronomer-cosmos/releases/tag/astronomer-cosmos-v1.6.0a3. You could try it out installing Cosmos using:
Alec mentioned that it was unclear how this folder was being created since it was not part of the Github repo. Therefore, this tooling would be less useful. For this reason, I'll close this PR without merging it with the main. Currently, these features will not be part of a stable Cosmos release. We can reopen this in the future if you or other community members find value on these methods. Today, we also discussed that currently, your team has a few different ways of deploying to Astro, including: During the call, we reviewed (a) your Astro Therefore, you're facing the problem because of deployments derived from local developers' computers (b). As we discussed, the ideal scenario would be for the virtualenv not to be created inside the dbt folder. During the call, Alec mentioned he had been advised that files in the As of Astro CLI 1.27.1: There is a solution to avoid the problem from happening again - as long as the path of the
By doing this, Airflow should ignore these paths containing recursive loops and be able to parse DAGs, as explained in the docs:
However, suppose developers create Python virtual environments with recursive loops in different paths in the DAGs folder. In that case, the issue will happen again: DAGs will not run on schedule. For this reason, it is essential to review and align with the team on the current deployment processes from local dev machines. Future actions that are outside of the scope of Cosmos could be:
|
Astronomer Cosmos Version
Other Astronomer Cosmos version (please specify below)
If "Other Astronomer Cosmos version" selected, which one?
1.4.3
dbt-core version
1.7.17
Versions of dbt adapters
dbt-bigquery==1.7.4
dbt-core==1.7.17
dbt-extractor==0.5.1
dbt-semantic-interfaces==0.4.4
LoadMode
DBT_LS
ExecutionMode
LOCAL
InvocationMode
SUBPROCESS
airflow version
apache-airflow==2.9.2+astro.1
Operating System
Debian GNU/Linux 11 (bullseye)
If a you think it's an UI issue, what browsers are you seeing the problem on?
No response
Deployment
Astronomer
Deployment details
We have a main production deployment in Astro Cloud which we consider as production. We also do local development via
astro dev start
. We have continuous deployment set up through CircleCI which deploys merged PRs to our master branch to our production deployment viaastro deploy --dags
. For authentication to our data warehouse (Google BigQuery) in production, we useGoogleCloudServiceAccountDictProfileMapping
and for local we useProfileConfig
where our dbt profiles.yml has a hardcoded path to a service account JSON file which is at the same path for each developer.What happened?
We noticed that we are having a RuntimeError constantly (I believe every second according to our Astro production deployment logs):
Detected recursive loop when walking DAG directory /usr/local/airflow/dags: /usr/local/airflow/dags/dbt/dbt_venv/lib has appeared more than once.
We aren't sure whether this error is going to cause parts of our setup to work sub optimally or connected to any other issues we are seeing in our production environment, i.e. like in #1075, or if it will cause further issues in the future.
Relevant log output
How to reproduce
I believe having the same set up should cause this bug to occur, note however, we have 1000+ dbt models so a project of that size may be needed to test.
Here are some relevant snippets for where our dbt_venv will live:
(1) Here is the relevant parts of our dockerfile:
(2) Here is our ExecutionConfig
Anything else :)?
Here is a screenshot of our production deployment logs in Astro UI where we found the bug, as you can see the issue is continuously happening:
Are you willing to submit PR?
Contact Details
oma@forhims.com
The text was updated successfully, but these errors were encountered: