Lazy-load Alembic in db_manager imports#65655
Conversation
|
A bit of extra validation context from local repro/testing:
So the issue appears to be the eager Alembic import on the DB manager import path, and the lazy import in this PR removes the noise without changing the actual migration call sites. |
|
@hkc-8010 This PR has been converted to draft because it does not yet meet our Pull Request quality criteria. Issues found:
What to do next:
Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. There is no rush — take your time and work at your own pace. We appreciate your contribution and are happy to wait for updates. If you have questions, feel free to ask on the Airflow Slack. Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. |
What this PR does
Avoids eagerly importing Alembic when
airflow.utils.db/airflow.utils.db_managerare imported.Today,
airflow.utils.db_managerimportsfrom alembic import commandat module import time. Becauseairflow.utils.dbimportsRunDBManager, that path loads Alembic during a normal import and emits the noisyalembic.runtime.pluginsINFO lines like:This PR defers importing
alembic.commanduntil the DB migration operations actually need it.Why
This keeps normal Airflow imports quiet without suppressing logs globally and without changing Alembic behavior during real migration operations.
Related issue
Closes #65652
Testing
pytest airflow-core/tests/unit/utils/test_db_manager.py -qpython -m pytest tests/unit/utils/test_db_manager.py -qimport airflow.utils.db_managerimport airflow.utils.db