簡體   English   中英

氣流認證設置失敗,出現“AttributeError:無法設置屬性”

[英]Airflow authentication setups fails with “AttributeError: can't set attribute”

文檔中描述的Airflow版本1.8密碼身份驗證設置在此步驟失敗

user.password = 'set_the_password'

有錯誤

AttributeError: can't set attribute

最好簡單地使用PasswordUser _set_password的新方法:

 # Instead of user.password = 'password'
 user._set_password = 'password'

這是因為SqlAlchemy更新為版本> = 1.2,引入了向后不兼容的更改。

您可以通過顯式安裝SqlAlchemy版本<1.2來解決此問題。

pip install 'sqlalchemy<1.2'

或者在requirements.txt中

sqlalchemy<1.2

固定的

pip install 'sqlalchemy<1.2'

我正在使用apache-airflow 1.8.2

如果任何人的好奇什么在SQLAlchemy的1.2不兼容的變化(中提到@唐太斯的回答)實際上 ,它是在怎樣的SQLAlchemy涉及混合proprerties的變化。 從1.2開始,方法必須與原始混合方法具有相同的名稱,之前不需要。 Airflow的修復非常簡單。 contrib/auth/backends/password_auth.py的代碼應該改變:

@password.setter
    def _set_password(self, plaintext):
        self._password = generate_password_hash(plaintext, 12)
        if PY3:
            self._password = str(self._password, 'utf-8')

對此:

@password.setter
    def password(self, plaintext):
        self._password = generate_password_hash(plaintext, 12)
        if PY3:
            self._password = str(self._password, 'utf-8')

有關詳細信息,請參閱https://bitbucket.org/zzzeek/sqlalchemy/issues/4332/hybrid_property-gives-attributeerror

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM