Skip to content

Commit

Permalink
Remove dag parsing from db init command (#22531)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWheating authored Mar 31, 2022
1 parent e7650b8 commit 8079b4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions airflow/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,13 +644,6 @@ def initdb(session: Session = NEW_SESSION):

with create_global_lock(session=session, lock=DBLocks.MIGRATIONS):

dagbag = DagBag()
# Save DAGs in the ORM
dagbag.sync_to_db(session=session)

# Deactivate the unknown ones
DAG.deactivate_unknown_dags(dagbag.dags.keys(), session=session)

from flask_appbuilder.models.sqla import Base

Base.metadata.create_all(settings.engine)
Expand Down Expand Up @@ -1285,6 +1278,17 @@ def resetdb(session: Session = NEW_SESSION):
initdb(session=session)


@provide_session
def bootstrap_dagbag(session: Session = NEW_SESSION):

dagbag = DagBag()
# Save DAGs in the ORM
dagbag.sync_to_db(session=session)

# Deactivate the unknown ones
DAG.deactivate_unknown_dags(dagbag.dags.keys(), session=session)


@provide_session
def downgrade(*, to_revision, from_revision=None, show_sql_only=False, session: Session = NEW_SESSION):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def initial_db_init():
from airflow.utils import db

db.resetdb()
db.bootstrap_dagbag()


@pytest.fixture(autouse=True, scope="session")
Expand Down

0 comments on commit 8079b4c

Please sign in to comment.