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 Converting to draft — this PR doesn't yet meet our Pull Request quality criteria.
See the linked criteria for how to fix each item, then mark the PR "Ready for review". This is not a rejection — just an invitation to bring the PR up to standard. No rush. 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. |
|
Follow-up after investigating the draft conversion / CI failures:
This follow-up push addresses both:
Local validation on Python
|
|
@potiuk Following up on this one when you have a moment. The CI-related issues from your earlier draft-conversion note were investigated and addressed in the May 2 follow-up, and the PR is ready for another pass. I’d really appreciate a quick re-review when you get a chance. Thank you! |
1e26d47 to
4de238c
Compare
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.
To preserve existing test and patching behavior,
airflow.utils.db_manager.commandremains available via a lazy proxy.Related issue
Closes #65652
Testing
ruff check airflow-core/src/airflow/utils/db_manager.py airflow-core/tests/unit/utils/test_db_manager.py3.10container:python -m pytest airflow-core/tests/unit/utils/test_db_manager.py -qpython -m pytest providers/edge3/tests/unit/edge3/models/test_db.py -qimport airflow.utils.db_managerimport airflow.utils.dbGen-AI disclosure
This PR was prepared with assistance from generative AI tools. I reviewed the generated changes, validated the behavior locally, and take responsibility for the final code and testing.