I have a little problem, I want to do the typical conditional like
setting_x = Variable.get('setting_x')
variable = setting_x if setting_x else 0
But since the Airflow model throws an exception when the key doesn't exist is impossible to do it without trycatching and that's not very cool.
Is there any solution that I'm missing to solve that case? I've searched in the whole internet of course, but without a solution yet.
Thanks, Angel
You can set the default for the Variable if it doesn't exist when you're retrieving it with the get
method.
variable = Variable.get('setting_x', default_var=0)
https://github.com/apache/airflow/blob/master/airflow/models/variable.py#L127
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With