Skip to content

Commit

Permalink
Fix import
Browse files Browse the repository at this point in the history
[2024-12-19T12:09:23.654+0000] {plugins_manager.py:266} ERROR - Failed to import plugin cosmos
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/airflow/plugins_manager.py", line 258, in load_entrypoint_plugins
    plugin_class = entry_point.load()
                   ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/local/airflow/src/astronomer-cosmos/cosmos/plugin/__init__.py", line 13, in <module>
    from cosmos.listeners import dag_run_listener
  File "/usr/local/airflow/src/astronomer-cosmos/cosmos/listeners/dag_run_listener.py", line 13, in <module>
    from cosmos.airflow.dag import DbtDag
ImportError: cannot import name 'DbtDag' from partially initialized module 'cosmos.airflow.dag' (most likely due to a circular import) (/usr/local/airflow/src/astronomer-cosmos/cosmos/airflow/dag.py)
  • Loading branch information
tatiana committed Dec 19, 2024
1 parent eb886e3 commit d2e20d3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cosmos/listeners/dag_run_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from airflow.models.dagrun import DagRun

from cosmos import telemetry
from cosmos.airflow.dag import DbtDag
from cosmos.airflow.task_group import DbtTaskGroup
from cosmos.log import get_logger

logger = get_logger(__name__)
Expand All @@ -35,13 +33,17 @@ class EventStatus:

@functools.lru_cache()
def is_cosmos_dag(dag: DAG) -> bool:
from cosmos.airflow.dag import DbtDag

if isinstance(dag, DbtDag):
return True
return False


@functools.lru_cache()
def total_cosmos_task_groups(dag: DAG) -> int:
from cosmos.airflow.task_group import DbtTaskGroup

cosmos_task_groups = 0
for group_id, task_group in dag.task_group_dict.items():
if isinstance(task_group, DbtTaskGroup):
Expand Down

0 comments on commit d2e20d3

Please sign in to comment.