Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix AstroCustomXcomBackend circular import issue (#1942)
When using `AstroCustomXcomBackend` and Python SDK 1.5, we were raising the exception: ``` Traceback (most recent call last): File "/usr/local/bin/airflow", line 5, in <module> from airflow.__main__ import main File "/usr/local/lib/python3.9/site-packages/airflow/__init__.py", line 55, in <module> settings.initialize() File "/usr/local/lib/python3.9/site-packages/airflow/settings.py", line 567, in initialize import_local_settings() File "/usr/local/lib/python3.9/site-packages/airflow/settings.py", line 524, in import_local_settings import airflow_local_settings File "/usr/local/airflow/airflow_local_settings.py", line 10, in <module> from airflow.models.baseoperator import BaseOperator File "/usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py", line 75, in <module> from airflow.models.taskinstance import TaskInstance, clear_task_instances File "/usr/local/lib/python3.9/site-packages/airflow/models/taskinstance.py", line 93, in <module> from airflow.models.xcom import XCOM_RETURN_KEY, LazyXComAccess, XCom File "/usr/local/lib/python3.9/site-packages/airflow/models/xcom.py", line 835, in <module> XCom = resolve_xcom_backend() File "/usr/local/lib/python3.9/site-packages/airflow/models/xcom.py", line 818, in resolve_xcom_backend clazz = conf.getimport("core", "xcom_backend", fallback=f"airflow.models.xcom.{BaseXCom.__name__}") File "/usr/local/lib/python3.9/site-packages/airflow/configuration.py", line 809, in getimport return import_string(full_qualified_path) File "/usr/local/lib/python3.9/site-packages/airflow/utils/module_loading.py", line 33, in import_string module = import_module(module_path) File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/usr/local/lib/python3.9/site-packages/astro/custom_backend/astro_custom_backend.py", line 6, in <module> from astro.custom_backend.serializer import deserialize, serialize File "/usr/local/lib/python3.9/site-packages/astro/custom_backend/serializer.py", line 12, in <module> if airflow.__version__ >= "2.3": AttributeError: partially initialized module 'airflow' has no attribute '__version__' (most likely due to a circular import) ``` Relates to: apache/airflow#31379 Closes: #1939
- Loading branch information