With code, how do you update an airflow variable?

前端 未结 1 703
被撕碎了的回忆
被撕碎了的回忆 2020-12-06 10:23

I need to update a variable I have made in Airflow programmatically but I can not find the answer on how to do that with code.

I have retrieved my variable with this

相关标签:
1条回答
  • 2020-12-06 11:05

    Use Variable.set instead of Variable.set_val. set_val() is a setter for the val attribute and not intended for outside use. This should do what you want:

    Variable.set("column_number", int(column_number) + 1)
    

    It will make the actual update to the database, along with handling session and serialization for you if needed.

    Reference: https://github.com/apache/incubator-airflow/blob/1.10.1/airflow/models.py#L4558-L4569

    0 讨论(0)
提交回复
热议问题