Skip to content

Commit

Permalink
fix: don't import User and Role FAB models, fixes airflow 2.9.0+ (#857)
Browse files Browse the repository at this point in the history
fix: stop importing User/Role FAB models, airflow keeps moving them

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
  • Loading branch information
thesuperzapper committed May 1, 2024
1 parent 0a75a67 commit 912a037
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions charts/airflow/templates/sync/_helpers/sync_users.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@ flask_app = www_app.create_app()
flask_appbuilder = flask_app.appbuilder
{{- end }}

# airflow moves the User and Role models around in different versions
try:
# since 2.7.0
from airflow.auth.managers.fab.models import User, Role
except ModuleNotFoundError:
try:
# from 2.3.0 to 2.6.3
from airflow.www.fab_security.sqla.models import User, Role
except ModuleNotFoundError:
# before 2.3.0
from flask_appbuilder.security.sqla.models import User, Role

# we want type hints, but airflow keeps moving the `User` and `Role` models around
# (╯°□°)╯︵ ┻━┻
from typing import Any
User = Any
Role = Any

#############
## Classes ##
Expand Down

0 comments on commit 912a037

Please sign in to comment.