【发布时间】:2018-01-03 10:46:05
【问题描述】:
docs 中所述的 Airflow 1.8 版密码验证设置在该步骤失败
user.password = 'set_the_password'
有错误
AttributeError: can't set attribute
【问题讨论】:
docs 中所述的 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 版本
pip install 'sqlalchemy<1.2'
或者在requirements.txt中
sqlalchemy<1.2
【讨论】:
>=1.1 - 只是 SQLA 在 1.1 和 1.2 之间进行了向后不兼容的更改。而且 1.2 的发布时间比 Airflow 的发布时间要晚。
用
固定pip install 'sqlalchemy<1.2'
我正在使用 apache-airflow 1.8.2
【讨论】:
如果有人对 SQLAlchemy 1.2 中的不兼容变化(在@DanT 的回答中提到)实际上 是 感到好奇,这是 SQLAlchemy 处理混合属性的方式的变化。从 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。
【讨论】: