sko*_*ozz 1 airflow airflow-scheduler
我有一个小问题,我想做典型的有条件的
setting_x = Variable.get('setting_x')
variable = setting_x if setting_x else 0
Run Code Online (Sandbox Code Playgroud)
但是由于Airflow模型会在密钥不存在时引发异常,因此如果不进行尝试捕获就无法做到这一点,而且这不是很酷。
有什么解决方案我想解决吗?我已经搜索了整个互联网,但是还没有解决方案。
谢谢,天使
如果使用该get方法检索变量时不存在该变量,则可以设置该变量的默认值。
variable = Variable.get('setting_x', default_var=0)
https://github.com/apache/incubator-airflow/blob/master/airflow/models.py#L4409
| 归档时间: |
|
| 查看次数: |
2310 次 |
| 最近记录: |