boolean values in environment variables#9535
boolean values in environment variables#9535christophlingg wants to merge 1 commit intoapache:masterfrom
Conversation
it is not obvious from the docs how to set boolean values, source https://github.com/apache/airflow/blob/master/airflow/configuration.py#L329-L341
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
|
|
|
||
| .. code-block:: bask | ||
|
|
||
| export AIRFLOW__CORE__REMOTE_LOGGING=true |
There was a problem hiding this comment.
It shouldn't matter. the values are read as string by the configparser
There was a problem hiding this comment.
❯ export AIRFLOW__CORE__LOAD_DEFAULT_CONNECTIONS=True
❯ ipython
Python 3.7.4 (default, Aug 13 2019, 15:17:50)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from airflow.configuration import conf
In [2]: conf.getboolean("core", "load_default_connections")
Out[2]: True
In [3]:
Do you really want to exit ([y]/n)? y
❯ export AIRFLOW__CORE__LOAD_DEFAULT_CONNECTIONS=False
❯ ipython
Python 3.7.4 (default, Aug 13 2019, 15:17:50)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from airflow.configuration import conf
In [2]: conf.getboolean("core", "load_default_connections")
Out[2]: False
In [3]:There was a problem hiding this comment.
Check line L330
airflow/airflow/configuration.py
Lines 329 to 341 in 096f5c5
There was a problem hiding this comment.
thanks @kaxil for getting into that. When I set the environmental variables I was not aware that airflow parses booleans that gracefully and supports many variants (1, TRUE, true, t, True, ...). One could avoid concerns by giving an example in the documentation, like I did above.
There was a problem hiding this comment.
Even tRuE should work :) as we convert them to .lower() so it doesn't matter for a user until there is a Typo :)
If you think some docs around that can help ease the confusion, I am happy for you to update the docs in this PR and merge it :)
There was a problem hiding this comment.
Maybe I was thinking too much like a software developer here. And as the parsing is so clever, people won't have issues.
I will close the PR, thanks for your feedback.
Some configuration variables are boolean and it was not clear to me how to set those bools from environmental variables which are all strings. Eventually, I found the mapping in the code.
Make sure to mark the boxes below before creating PR: [x]
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.